PNixx / clickhouse-activerecord

A Ruby database ActiveRecord driver for ClickHouse

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support for Materialized columns

AlexKichkailo opened this issue · comments

In ClickHouse, it is possible to define materialized columns for a table.

Is there any way to create a materialized column using create_table?

I imagine the syntax could be similar to the syntax for column default. something like

t.boolean :a
t.boolean :b
t.boolean :c
t.boolean :materialized_column,  materialize: -> { 'a OR b OR c' }

One idea @PNixx --It would be nice to include a way and an example of a plain SQL migration defined in a migrations up and down method using the underlying connection to create a materialized view. I imagine the connection is probably available, although I don't know if I saw any examples of running queries directly.

I'm using a materialized view with a group_by and toStartOfInterval with some data for graphs. This would be a difficult migration to write through ActiveRecord, but it would be nice to keep even plain SQL migrations in the set of migrations to build the database.