alecStewart1

alecStewart1

Using Ash with DuckDB/MotherDuck: Possible and/or Useful?

Hey friends!

I had this thought given an actual real world problem at work.

Generally whenever you have some kind of front-facing app that consumes data from somewhere, usually an API of sorts, if you’re using data from your own company or somewhere else the data the API uses is stored in some kind of database somewhere.

The most basic example is:

Hosted database → something like an API that’ll get data from it → application

And that’s actually fine for a lot of cases. Obviously there’s stuff like caching and backing up your data that has to be thought of, but the general flow of data is pretty simple in a broad sense.

However there’s one thing I thought of to consider, especially in a case at work.

What if the API is only used to get data from a database? If you’re not actually updating or removing anything from the database, this is maybe where you might have a usecase for using an OLAP. It’s optimized for analyzing data as opposed to transacting with it.

There’s several solution, but the one I’m focused on is DuckDB or MotherDuck (it’s DuckDB under the hood).

If I wanted to use Ash with Motherduck, Ash to model the entities for manipulating for analysis or whatever with the API, could I create a custom Data layer that will connection to a running instance of DuckDB? Or would this get a little hairy?

Marked As Solved

zachdaniel

zachdaniel

Creator of Ash

You can definitely do that kind of thing :slight_smile:

The method would range from the very simple, using generic actions to just do “whatever you want”: Generic Actions — ash v3.29.3

To very complex, like writing a custom data layer. There are some examples out there of non-relational or unconventional data layers, like ash_csv, ash_cubdb and ash_sanity etc.

Also Liked

alecStewart1

alecStewart1

Awesome! I think for our cases using generic actions might work, however I feel like it would be more elegant to use a custom data layer. duckdbex would likely be used for this. Looks like it’s not too hard, but I’d have to make sure I understand how everything works and not just copy paste stuff from other custom data layers.

However I did remember that there is a PostgreSQL extension for analytics, which embeds DuckDB into PostgreSQL, so maybe creating a postgrex extension like geo_postgis might be easier considering that it doesn’t seem like pg_analytics introduces any new types like PostGIS does.

I think it’ll be a matter of how we want to structure things, but thanks you, Zach! You’re always super helpful.

Where Next?

Popular in Questions Top

nobody
How to bind a phoenix app to a specific ip address? could not find anything about that, nowhere, unfortunately, but for me this is quite...
New
WestKeys
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New
baxterw3b
Hi guys, i’m new in the Elixir world, and i have to say, that i love it! i’m having some problem to understand anonymous functions with ...
New
greenz1
I have a phoenix application from which a user can download multiple(5-6) files of size 1MB. I couldn’t find anything related to sending ...
New
ovidiubadita
Hey all, I discovered Elixir and I love it. I always wanted to learn a functional programming and I intended to go for Haskell, but afte...
New
JulienCorb
I am trying to implement my new.html.eex file to create new posts on my website. new.html.eex: <h1>Create Post</h1> <%= ...
New
ycv005
I have followed this StackOverflow post to install the specific version of Erlang. And When I am running mix ecto.setup then getting fol...
New
Qqwy
Original source of discussion: This topic on the Pragmatic Programmers’ Functional Web Development with Elixir, OTP, and Phoenix forum. ...
New
fayddelight
I tried installing elixir 1.11.2 erlang 23.3.4 via asdf in my zsh shell. Enabled the versions locally and globally. When I list them ...
New
rms.mrcs
Hi, I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list. ...
New

Other popular topics Top

TunkShif
This post is an instruction guide to help you setup your Neovim for Elixir development from scratch. It includes general information on h...
274 41989 114
New
shahryarjb
Hello, I have map which I want to convert it to string like this: the map: %{last_name: "tavakkoli", name: "shahryar"} the string I ne...
New
josevalim
Hi everyone, One of the features added to Elixir early on to help integration with Erlang code was the idea of overridable function defi...
New
joeerl
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New
Qqwy
Original source of discussion: This topic on the Pragmatic Programmers’ Functional Web Development with Elixir, OTP, and Phoenix forum. ...
New
vrod
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors: [WARN] - (starship::utils): Executing command ...
New
alice
Hey, Just curious what are the main benefits of Elixir compared to Clojure? When is Elixir more useful than Clojure and vice versa? Th...
New
saif
Hello everyone, Long time lurker first time poster here. I’ve recently begun working on Elixir full-time again! :raised_hands: It’s been...
New
romenigld
I am trying to run a deploy with docker and I successfully runned with this command: docker build -t romenigld/blog-prod . but when I t...
New
openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New

Latest on Elixir Forum

Elixir Forum

We're in Beta

About us Mission Statement