apache / apache/datafusion-sqlparser-rs

ClickHouse table function is recognized as TableFactor::Table

Open
#2,027 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
3.5k
Forks
772
Avg merge
4d 9h
Merged PRs (30d)
17

Description

See https://clickhouse.com/docs/sql-reference/table-functions.

For example:
```sql
SELECT * FROM test;
SELECT * FROM test();
```

They produce:

> pre_visit_table_factor: Table { name: ObjectName([Identifier(Ident { value: "test", quote_style: None, span: Span(Location(1,16)..Location(1,20)) })]), alias: None, args: None, with_hints: [], version: None, with_ordinality: false, partitions: [], json_path: None, sample: None, index_hints: [] }

and

> pre_visit_table_factor: Table { name: ObjectName([Identifier(Ident { value: "test", quote_style: None, span: Span(Location(1,16)..Location(1,20)) })]), alias: None, args: Some(TableFunctionArgs { args: [], settings: None }), with_hints: [], version: None, with_ordinality: false, partitions: [], json_path: None, sample: None, index_hints: [] }

The second version produces `args: Some(TableFunctionArgs { args: [], settings: None })`.

As I see it's because [`Function`](https://github.com/apache/datafusion-sqlparser-rs/blob/b8539a52af7419b86d9c2fc51ba247d022f7a6f8/src/parser/mod.rs#L13498) is only recognized after a `LATERAL` keyword, and [`TableFunction`](https://github.com/apache/datafusion-sqlparser-rs/blob/b8539a52af7419b86d9c2fc51ba247d022f7a6f8/src/parser/mod.rs#L13511) is only for the `TABLE()` syntax (but not for `ident()`).

Contributor guide

No contributing guide indexed for this repository

Research direction

Start in src/parser/mod.rs at the Function and TableFunction handling linked in the issue, then compare parsing for SELECT * FROM test and SELECT * FROM test(). Confirm the completed behavior with parser output showing the ClickHouse ident() form distinguished appropriately from a plain table reference.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust, sql
Domain
compilers, databases
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.