Skip to content

fix(clickhouse-driver): override generic string type in sqlTemplates - #11544

Open
AngelaMCarlos wants to merge 1 commit into
cube-js:masterfrom
AngelaMCarlos:fix-clickhouse-string-type-template
Open

fix(clickhouse-driver): override generic string type in sqlTemplates#11544
AngelaMCarlos wants to merge 1 commit into
cube-js:masterfrom
AngelaMCarlos:fix-clickhouse-string-type-template

Conversation

@AngelaMCarlos

Copy link
Copy Markdown

Description

Fixes #10415.

ClickHouse type names are case-sensitive: CAST(x, 'STRING') fails with Unknown data type family: STRING. Maybe you meant: ['String','Ring'].

ClickHouseQuery.sqlTemplates() overrides boolean and timestamp but not string, so any generated SQL that casts to the generic string type fails against ClickHouse:

  • LAG/LEAD SQL API pushdown (since v1.6.14): internal columns are emitted as CAST(NULL, 'STRING') AS __user, CAST(NULL, 'STRING') AS __cubejoinfield (ClickHouse: CAST(NULL, 'STRING') fails — ClickHouseQuery missing string type override #10415).
  • count measures over composite primary keys with the Tesseract planner (v1.7): the key concatenation is emitted as count(concat(CAST(pk1, 'STRING'), CAST(pk2, 'STRING'), ...)), so any such measure returns HTTP 400. Reproduced on v1.7.19 with a plain REST query on a cube whose dimensions declare two primary_key: true columns and a type: count measure without sql.

This one-line change adds templates.types.string = 'String'; next to the existing overrides, aligning the ClickHouse dialect with its case-sensitive type names.

Check List

  • Tests has been run in packages where changes made if available — not run locally (one-line dialect override, submitted via web editor); happy to add a sqlTemplates assertion to clickhouse-query.test.ts if maintainers want one
  • Linter has been run for changed code — change matches the surrounding style
  • Tests for the changes have been added if not covered yet
  • Docs have been added / updated if required — no doc impact

ClickHouse type names are case-sensitive: CAST(x, 'STRING') fails with
"Unknown data type family: STRING". sqlTemplates() overrides boolean and
timestamp but not string, so any generated SQL casting to the generic
string type fails - LAG/LEAD SQL API pushdown, and count measures over
composite primary keys with the Tesseract planner.

Fixes cube-js#10415
@AngelaMCarlos
AngelaMCarlos requested a review from a team as a code owner August 13, 2026 12:49
@github-actions github-actions Bot added javascript Pull requests that update Javascript code pr:community Contribution from Cube.js community members. labels Aug 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

javascript Pull requests that update Javascript code pr:community Contribution from Cube.js community members.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ClickHouse: CAST(NULL, 'STRING') fails — ClickHouseQuery missing string type override

1 participant