clickhouse icon indicating copy to clipboard operation
clickhouse copied to clipboard

Default value for columns

Open volfgox opened this issue 6 years ago • 1 comments

Does this gem support defining default value as what is descried in clickhouse documentation metioned bellow?

CREATE [TEMPORARY] TABLE [IF NOT EXISTS] [db.]name [ON CLUSTER cluster]
(
    name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1],
    name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2],
    ...
) ENGINE = engine

I saw Clickhouse::Connection::Query::Table#to_sql and think it is not supported.

volfgox avatar Sep 17 '18 05:09 volfgox

I've just made an alternative, very similar to this one:

ClickHouse.connection.create_table('visits', engine: 'MergeTree(date, (year, date), 8192)') do |t|
  t.UInt16  :year
  t.Date    :date
  t.UInt16  :id, 16, default: 0, ttl: 'date + INTERVAL 1 DAY'
end

shlima avatar Nov 09 '19 02:11 shlima