Oracle: qualify quotes USER, UID, ORA_ROWSCN and CONNECT_BY_ISLEAF/ISCYCLE as if they were columns
メンテナーはふだん 1 日以内に返信
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 35/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 停滞
調査の方向性
Start with Oracle dialect definitions, especially Oracle.PSEUDOCOLUMNS and the no-parentheses handling used for SYSDATE, then trace how qualify resolves these names against the schema. Reproduce with the supplied snippet and Oracle dialect. Done when the five names remain unquoted and are not treated as columns; an open linked pull request is already addressing this issue.
索引モデルが issue の本文から書いたものです。
説明
Oracle's PSEUDOCOLUMNS covers ROWNUM, ROWID, LEVEL, OBJECT_ID and OBJECT_VALUE. It does not cover a few other pseudo-columns and no-paren functions. qualify therefore treats them as ordinary columns and quotes them. A quoted name means a column with that name to Oracle, so the rewritten query fails with ORA-00904.
LEVEL shows the expected behaviour in the same query.
Fully reproducible code snippet
Read and write dialect are both oracle. Checked on 30.36.0 and on main (a7124cf).
import sqlglot
from sqlglot.optimizer.qualify import qualify
schema = {"t": {"id": "INT", "parent_id": "INT"}}
for sql in [
"SELECT USER, UID FROM t",
"SELECT ORA_ROWSCN FROM t",
"SELECT id, LEVEL, CONNECT_BY_ISLEAF, CONNECT_BY_ISCYCLE FROM t "
"START WITH parent_id IS NULL CONNECT BY NOCYCLE PRIOR id = parent_id",
]:
tree = qualify(sqlglot.parse_one(sql, read="oracle"), schema=schema,
dialect="oracle", validate_qualify_columns=False)
print(tree.sql(dialect="oracle"))
Output:
SELECT "USER" AS "USER", "UID" AS "UID" FROM "T" "T"
SELECT "ORA_ROWSCN" AS "ORA_ROWSCN" FROM "T" "T"
SELECT "T"."ID" AS "ID", LEVEL AS "LEVEL", "CONNECT_BY_ISLEAF" AS "CONNECT_BY_ISLEAF", "CONNECT_BY_ISCYCLE" AS "CONNECT_BY_ISCYCLE" FROM "T" "T" START WITH ...
Expected: USER, UID, ORA_ROWSCN, CONNECT_BY_ISLEAF and CONNECT_BY_ISCYCLE stay unquoted, the way LEVEL does. They should also not be treated as columns of t.
A possible fix: add ORA_ROWSCN, CONNECT_BY_ISLEAF and CONNECT_BY_ISCYCLE to Oracle.PSEUDOCOLUMNS; the last two only apply under CONNECT BY, like LEVEL. USER and UID are functions rather than pseudo-columns, so they may fit better as no-paren functions, the way SYSDATE is handled. Happy to open a PR.
Official Documentation
- Pseudocolumns: https://docs.oracle.com/en/database/oracle/oracle-database/19/sqlrf/Pseudocolumns.html
- ORA_ROWSCN: https://docs.oracle.com/en/database/oracle/oracle-database/19/sqlrf/ORA_ROWSCN-Pseudocolumn.html
- Hierarchical query pseudocolumns: https://docs.oracle.com/en/database/oracle/oracle-database/19/sqlrf/Hierarchical-Query-Pseudocolumns.html
- USER: https://docs.oracle.com/en/database/oracle/oracle-database/19/sqlrf/USER.html
- UID: https://docs.oracle.com/en/database/oracle/oracle-database/19/sqlrf/UID.html
- 主要言語
- Python
- スター
- 9.8k
- フォーク
- 1.5k
- 平均マージ
- 10時間 54分
- マージ済み PR(30日)
- 310
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
tobymao/sqlglot のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
ClickHouse: quantile is read as the exact Quantile, though ClickHouse's quantile is approximateオープン
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
メンテナーはふだん 1 日以内に返信
-
ClickHouse: DAY_OF_WEEK is read as DayOfWeek, so every call is written back as toDayOfWeek(t, 3)オープン
難易度 3/5 1〜2日 初心者へのやさしさ 68/100
メンテナーはふだん 1 日以内に返信
-
INTERVAL '1 day ago' loses "ago" and becomes a positive interval対応中かも @treysp が 2 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 35/100
メンテナーはふだん 1 日以内に返信
tobymao/sqlglot の issue をすべて見る
似ている issue
-
Make the "%" unit spacing the same in the web and in A10対応中かも @kragent66-glitch が今日担当しました。 オープンbug good first issue
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
maiychrus25/OpenTea-DX-OS#226 · コメント 1 件 ·
-
ci severity: low
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
TMHSDigital/Spackle#205 ·
メンテナーはふだん 1 日以内に返信
-
pkg:lgm type:chore upstream-gaussx
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
jejjohnson/pyrox#610 ·
メンテナーはふだん 1 日以内に返信
-
changelog investigate
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
ramnes/notion-sdk-py#523 ·
-
feature-request
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
open-telemetry/opentelemetry-python#5994 ·
メンテナーはふだん 2 日以内に返信