apache / apache/datafusion-sqlparser-rs

ClickHouse table function is recognized as TableFactor::Table

Đang mở
#2,027 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
Rust
Star
3.5k
Fork
772
Merge trung bình
4 ngày 9 giờ
Pull request đã merge (30 ngày)
17

Mô tả

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()`).

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Hướng nghiên cứu

Bắt đầu trong src/parser/mod.rs, tại phần xử lý Function và TableFunction được liên kết trong issue, sau đó so sánh việc phân tích cú pháp của SELECT * FROM test và SELECT * FROM test(). Xác nhận hành vi đã hoàn tất bằng đầu ra của parser cho thấy dạng ident() của ClickHouse được phân biệt phù hợp với một tham chiếu bảng thông thường.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
rust, sql
Lĩnh vực
compilers, databases
Loại issue
Lỗi
Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
55/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.