Table version clause (`AT(...)`, `FOR SYSTEM_TIME AS OF`, `VERSION AS OF`) is displayed after the alias and doesn't reparse
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
調査の方向性
The parse order is in parse_table_factor, where maybe_parse_table_version runs before maybe_parse_table_alias. The write order is in the TableFactor::Table arm of Display, which emits alias, index hints and WITH (...) before the version. Read the dialect trait methods and the existing version tests first, then check PR #2486 for overlap. Done means a round-trip check passes for the Snowflake, MsSql, Databricks and BigQuery inputs, with the position chosen per dialect.
索引モデルが issue の本文から書いたものです。
説明
The parser reads the version clause before the alias and table hints, but Display writes it after them, so the output doesn't parse:
Snowflake: SELECT * FROM my_table AT(OFFSET => -60*5) AS T WHERE T.flag = 'valid'
-> displays as: SELECT * FROM my_table AS T AT(OFFSET => -60 * 5) WHERE T.flag = 'valid'
-> reparse: Expected: identifier, found: ( at Line: 1, Column: 31
MsSql: SELECT * FROM t FOR SYSTEM_TIME AS OF '2014-01-01' AS x WITH (NOLOCK)
-> displays as: SELECT * FROM t AS x WITH (NOLOCK) FOR SYSTEM_TIME AS OF '2014-01-01'
-> reparse: Expected: one of UPDATE or SHARE, found: SYSTEM_TIME at Line: 1, Column: 40
Databricks: SELECT * FROM events VERSION AS OF 123 AS e
-> displays as: SELECT * FROM events AS e VERSION AS OF 123
-> reparse: Expected: end of statement, found: VERSION at Line: 1, Column: 27
The Snowflake input is the example from https://docs.snowflake.com/en/sql-reference/constructs/at-before. SQL Server documents table_or_view_name [ FOR SYSTEM_TIME <system_time> ] [ [ AS ] table_alias ] ... [ WITH ( <table_hint> ... ) ] (https://learn.microsoft.com/en-us/sql/t-sql/queries/from-transact-sql), and Databricks puts the temporal spec in table_name, before table_alias (https://docs.databricks.com/aws/en/sql/language-manual/sql-ref-syntax-qry-select-table-reference).
BigQuery documents the opposite order, table_name [ as_alias ] [ FOR SYSTEM_TIME AS OF ... ] (https://cloud.google.com/bigquery/docs/reference/standard-sql/query-syntax#from_clause), and with BigQueryDialect SELECT * FROM t AS x FOR SYSTEM_TIME AS OF '2020-01-01' is rejected (Expected: one of UPDATE or SHARE, found: SYSTEM_TIME), while the other order parses and displays as the rejected form. So the right position seems to be dialect dependent.
Parser: maybe_parse_table_version runs before maybe_parse_table_alias in parse_table_factor. Display: the TableFactor::Table arm writes alias, index hints, WITH (...), then the version. The open PR #2486 mentions this in passing and leaves it for a separate change.
Tested on main ce12f1f6 (also 0.63.0; on 0.58.0 the Databricks input is a parse error).
Found with a property-based fuzzer (round trip check); I used AI assistance for triage and verified every case above.
- 主要言語
- Rust
- スター
- 3.5k
- フォーク
- 805
- 平均マージ
- 2日 3時間
- マージ済み PR(30日)
- 116
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドなし
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
apache/datafusion-sqlparser-rs のほかの issue
-
PostgreSQL
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
apache/datafusion-sqlparser-rs#2862 ·
メンテナーはふだん 1 日以内に返信
-
PostgreSQL
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
apache/datafusion-sqlparser-rs#2861 ·
メンテナーはふだん 1 日以内に返信
-
PostgreSQL
難易度 2/5 1〜3時間 初心者へのやさしさ 77/100
apache/datafusion-sqlparser-rs#2858 ·
メンテナーはふだん 1 日以内に返信
-
PostgreSQL
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
apache/datafusion-sqlparser-rs#2857 ·
メンテナーはふだん 1 日以内に返信
-
DuckDB Prolific Author
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
apache/datafusion-sqlparser-rs#2807 ·
メンテナーはふだん 1 日以内に返信
apache/datafusion-sqlparser-rs の issue をすべて見る
似ている issue
-
area:schema documentation
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
ElectronicWave/Elemental#252 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
dekobon/big-code-analysis#1887 ·
メンテナーはふだん 1 日以内に返信
-
Shell中文符号输入异常オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 82/100
メンテナーはふだん 1 日以内に返信