镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

[client-v2] Variant Type Support  #1926

Closed

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

Activity

  1. added this to the Priority Backlog milestone on Nov 11, 2024
  2. self-assigned this
    on Jan 13, 2025
  3. mshustov commented on Feb 9, 2025

    @mshustov
    Member

    @chernser closed by #2077?

  4. chernser commented on Feb 10, 2025

    @chernser
    ContributorAuthor

    @mshustov it requires some more work - I left it open.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions