Skip to content

Make clickhouse tuples work#2337

Open
alrevuelta wants to merge 1 commit intoapache:mainfrom
alrevuelta:tuples-clickhouse
Open

Make clickhouse tuples work#2337
alrevuelta wants to merge 1 commit intoapache:mainfrom
alrevuelta:tuples-clickhouse

Conversation

@alrevuelta
Copy link
Copy Markdown

@alrevuelta alrevuelta commented May 8, 2026

closes #2338

@alrevuelta alrevuelta force-pushed the tuples-clickhouse branch from d63268b to db8e97a Compare May 8, 2026 15:29
@alrevuelta
Copy link
Copy Markdown
Author

note. this PR does not address tuple.-1 which seems to be valid clickhouse syntax.

Extracts an element from a tuple by index or name.

For access by index, an 1-based numeric index is expected. For access by name, the element name can be provided as a string (works only for named tuples).

Negative indexes are supported. In this case, the corresponding element is selected, numbered from the end. For example, tuple.-1 is the last element in the tuple.

An optional third argument specifies a default value which is returned instead of throwing an exception when the accessed element does not exist. All arguments must be constants.

This function has zero runtime cost and implements the operators x.index and x.name.

source: https://clickhouse.com/docs/sql-reference/functions/tuple-functions#tupleelement

Comment thread src/tokenizer.rs
// After a Word, RBracket, or RParen, `.<digit>` is split into `Period`
// and a separate integer `Number`, so the parser can build a
// CompoundFieldAccess instead of seeing a single decimal literal.
dialects.tokenizes_to(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure I follow the patch/tests - are we saying that without this PR, a sql like t.1 tokenizes to something other than what's being asserted (if so what does the previous behavior tokenized to)?

Comment thread src/dialect/clickhouse.rs
true
}

/// See <https://clickhouse.com/docs/sql-reference/functions/tuple-functions#tupleelement>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this behavior differ from parse_compound_expr handling (if so how, on a first glance they look identical syntax wise)?

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Clickhouse tuples not supported

2 participants