Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[client-v2] Variant Type Support #1926

Open
chernser opened this issue Nov 11, 2024 · 0 comments
Open

[client-v2] Variant Type Support #1926

chernser opened this issue Nov 11, 2024 · 0 comments

Comments

@chernser
Copy link
Contributor

chernser commented Nov 11, 2024

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

@chernser chernser added this to the Priority Backlog milestone Nov 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant