Skip to content

Set column options codec #46

@encodedrose

Description

@encodedrose

Problem: Creating a column with a codec type throws an error.

Migration Repro:

    ClickHouse.connection.create_table('visits', engine: 'MergeTree ORDER BY date') do |t|
      t.Date     :date, compression_codec: 'CODEC(DoubleDelta, ZSTD(1))'
    end

Error:

Caused by:
NoMethodError: undefined method `compression_codec=' for #<ClickHouse::Definition::Column:0x0000000105b5abe8 @type="Date", @name=:date, @extensions=[{:compression_codec=>"CODEC(DoubleDelta, ZSTD(1))"}]> (NoMethodError)

        params.each { |k, v| public_send("#{k}=", v) }
                             ^^^^^^^^^^^

In addition to compression_codec, trying to use: compression:, codec:, and codec_expression: all failed.

I was able to work around the issue by using raw SQL.

    ClickHouse.connection.create_table('visits', engine: 'MergeTree ORDER BY date') do |t|
      t << "date Date CODEC(DoubleDelta, ZSTD(1))"
    end

It'd be great feature to have this as supported for DSL statements.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions