-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Ecto support based on ClickhouseEcto #69
base: master
Are you sure you want to change the base?
Conversation
lib/pillar/ecto/conn_mod.ex
Outdated
use DBConnection | ||
|
||
def connect(_) do | ||
conn = Pillar.Connection.new("http://localhost:8123") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For all Ecto requests will be used 1 connection?
Is pool needed here? Like in BulkInsertBuffer
module
@@ -0,0 +1,371 @@ | |||
defmodule Pillar.Ecto.QueryBuilder do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At all it looks great for me, thanks for this improvement! ❤️
I would like to see some tests, for example as you provided in description.
Could you add
- insert test
- select test
- join test
and add into 'readme.md' information, that there is experimental support of Ecto.Schema's
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I also want to add some more macros for custom clickhouse functions
OMG @sofakingworld I got a first version working which also supports parameterised query - so no fear for SQL injection! Parameterised like this: https://clickhouse.com/docs/en/interfaces/http#cli-queries-with-parameters |
DateTime mapping back to ecto model does not work yet, looking into it |
DateTime works now! |
end) | ||
end) | ||
|> List.flatten() | ||
|> Enum.reverse() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if you considered using execute/5
callback to build the query instead of prepare/5
to avoid reconstructing params? That's how plausible/chto
ended up working.
I would be interested to see where this approach leads though :) I tried it only briefly and gave up before making it work...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did not, I didn't even know plausible/chto existed :O
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gonna try chto now, maybe I can drop/close my work here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ruslandoga was chto always public or has it been made public recently? I am wondering how I missed it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's always been public in https://github.com/ruslandoga/chto and moved under Plausible org recently. However "always" in this case is just a few months.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
damn, how did it never come up for me, arg.
Just tested it briefly and seems to work with out issues so far for me. (I am currently struggling with some fragments implementations in this PR).
I am not sure how my work would compare to your library, feels like your stuff is way more reliable & major than what I have done so far. (I have never worked with Ecto under the hood prior to this PR)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
way more reliable & major
The only known user so far is Plausible. So I'm not sure if it's indeed reliable for use cases outside of https://github.com/plausible/analytics ...
It would be great to have more users :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be great to have more users :)
I'm willing to use it. It would be nice if we have a place to chat, maybe on ClickHouse's Slack. I've seen @Zarathustra2 there - where I've found this MR - but I'm not sure if you are there too, @ruslandoga.
87d3426
to
e30960d
Compare
This is based on ClickhouseEcto.
Currently parameters are not being supported that needs to be added as well.
Also needs some tests...
Example: