Skip to content

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

@Fergus-Boydell

Description

@Fergus-Boydell

Bug

Queries using the new LAG/LEAD SQL pushdown (added in v1.6.14 via #10407) fail against ClickHouse with:

Error: Unknown data type family: STRING. Maybe you meant: ['String','Ring']

Root Cause

BaseQuery.js defines the default type template as:

types: {
  string: 'STRING',
  ...
}

ClickHouseQuery.ts overrides several types (boolean, timestamp, etc.) in sqlTemplates() but does not override string. ClickHouse type names are case-sensitive and require String, not STRING.

When LAG/LEAD pushdown generates the full SQL sent to ClickHouse, it includes internal columns:

CAST(NULL, 'STRING') AS __user, CAST(NULL, 'STRING') AS __cubejoinfield,

ClickHouse rejects STRING as an unknown type.

Expected Behavior

The query should execute successfully against ClickHouse.

Suggested Fix

Add the string type override in ClickHouseQuery.ts sqlTemplates():

templates.types.string = 'String';

Environment

  • Cube version: v1.6.14
  • Database: ClickHouse
  • API: SQL API (PostgreSQL wire protocol)

Reproduction

Run any query using LAG() or LEAD() window functions via the Cube SQL API against a ClickHouse data source.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions