Skip to content

ClickHouse: Support tuple element access by index #2573

Description

@s5dsn-eqee

ClickHouse allows accessing tuple elements by 1-based index with dot syntax:

https://clickhouse.com/docs/sql-reference/data-types/tuple#addressing-tuple-elements

SELECT t.1 FROM (SELECT (1, 'a') AS t)
SELECT (1, 'a').1
SELECT tuple(1, 'a').2
SELECT arr[1].1 FROM t

All of these fail with ClickHouseDialect:

sql parser error: Expected: end of statement, found: .1 at Line: 1, Column: 9

The tokenizer reads .1 after an identifier, ) or ] as a float literal instead of a period followed by an integer, so the compound field access parser never sees it. Expected AST is Expr::CompoundFieldAccess with AccessExpr::Dot(Expr::Value(Number(1))), which is the shape the parser already produces for x . 1 written with spaces.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions