-
Notifications
You must be signed in to change notification settings - Fork 472
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
Added support for ClickHouse #377
base: master
Are you sure you want to change the base?
Conversation
Hey @foxy-eyed, thanks for the PR! Overall, looks great. Have you tried clickhouse-activerecord? It looks like they both have ~60k downloads, and I think we could use the SQL adapter if it works. |
Hi @ankane, thank you for feedback! I saw My understanding is, that ClickHouse is made for (and good for) processing big analytical data, like user activity, events etc into reports. In real-time.
Also support of different response format (https://clickhouse.com/docs/en/interfaces/formats/) would be handy, but But if someone already uses I added detection of driver dependency and created classes for both drivers with common interface, blazer adapter now can work with both. Please take a look, what do you think? Should we keep both? |
The main benefit of |
It looks like queries work with data_sources:
my_source:
url: clickhouse://playground:[email protected]:8443/datasets?ssl=true However, Also, it looks like neither library typecasts date and time columns, which is needed for charting, and With that additional info, I'm leaning towards |
It looks like dataset issue, not ruby drivers.
My bad, forgot to check charting. Unfortunately, I couldn't make it work with Now it looks like |
Now I am little confused)
@ankane what do you think? |
Let me think on this for a bit. I don't really want to support multiple adapters, so it'll likely be 1 or 2. |
@ankane hi!) |
Let's go with option 2 since date/time columns already work. A few other notes:
|
@ankane hi!
I'm not sure I got it right, but as I see none of ClickHouse types (
All other comments — done ✅ |
Looks great! For times, we'll want Blazer to display them in |
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.
@ankane I believe I fixed last thing from your notes)
I was hoping to use custom type casting as described here and overwrite default behaviour (parse DateTime
columns as Time
). But it can affect main app if it uses ClickHouse
for business logic.
That is why I came to a decision to process rows in adapter and apply conversion DateTime#to_time
after type casting.
def convert_time_columns(row, date_time_columns) | ||
time_values = row.slice(*date_time_columns).transform_values!(&:to_time) | ||
row.merge(time_values) | ||
rescue NoMethodError |
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.
We cannot be absolutely sure that we handle DateTime
object here, because built-in types can be overwritten. If conversion to Time
fails, we return initial object.
Hi @ankane, this adapter would be extremely useful as clickhouse is a very popular column store often utilized as analytics data store. Are there any blockers for this pr? Thanks. |
I also have a PR open and e-mailed @ankane about this a while back. It seems like for now the priorities are not with this gem, which is perfectly fine of course. So I'd recommend forking Blazer if you want to keep updating it. The downside is missing out on various PRs, so maybe it is an idea to create a maintained fork and to start pulling in PRs from here if @ankane is no longer able or interested in developing this gem. If there isn't such a fork already of course. |
@abuisman I've forked the project and added Clickhouse support from this branch (including a small bugfix which handles the situation when schema doesn't have any tables). My plan is to selectively merge some PRs from blazer and rewrite a couple components to make it easier extending the project (for example, I'm using bootstrap 5 and stimulus for interactions). It's still a work in progress, but feel free to share your thoughts, here is the fork |
ClickHouse adapter implementation (resolves #378).
Requires
click_house
Ruby driver to interact with clickhouse-server via HTTP interface.Adapter methods:
Readme instructions also added.