Skip to content

Clickhouse uses protobuf defaults but docs state Clickhouse does not #2134

Open
@electrachong

Description

@electrachong

Hi,

The docs currently state:

Default values defined in a protobuf schema like this

syntax = "proto2";

message MessageType {
 optional int32 result_per_page = 3 [default = 10];
}

are not applied; the table defaults are used instead of them.

However, we tested this with version ClickHouse server version 23.5.3 revision 54462, with the following steps

  1. Add a new column with a default.
ALTER TABLE tablename ON CLUSTER clustername ADD COLUMN IF NOT EXISTS test_id Int32 DEFAULT -1;
  1. Query existing or new records - they show -1 for the column as expected.
  2. Update the protobuf schema to add the new fields:
  optional int32 test_id = 195;
  1. Write new records specifying the updated schema.
  2. Query the new records - now they show 0 for the column. Expected: -1
  3. Change the protobuf schema to set a default:
  optional int32 test_id = 195 [default = -1];
  1. Write new records specifying the updated schema.
  2. Query the new records - now they show -1 for the column.

This leads us to believe the protobuf default is used instead of the Clickhouse column default. I'm not sure whether this applies to nullable columns as well as non-nullable columns. Is this a bug with the clickhouse server or inaccurate documentation?

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions