Skip to content

[client-v2] Variant Type Support  #1926

@chernser

Description

@chernser

Description

Variant type example definition:

CREATE TABLE external_projects ( id Variant(UUID, UInt32, String), name String) Engine=MergeTree ORDER BY ()

Binary Encoded as: [ord number of type from definition when types are sorted alphabetically (String = 0)][... encoded value of selected type]

This type is similar to Tuple, but only one value is present at a time.
Variants can be accessed by sub column names. This should be implemented as ability of ClickHouseBinaryReader:

      // for query select id, name from external_projects 
      String id = reader.getString("id.String"); // should return string value or throw exception that value missing or null if nullable column
      String id = reader.getInteger("id.String"); // should throw exception about type mismatch even if column is nullable

There should be possibility to get variant type. This requires to add getValueType method.

When encoding POJO:

  • Most suitable type is selected
  • Numbers are not converted to strings
  • Strings not converted to DateTime values and vice versa

Variant Type Documentation

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions