PostgreSqlDialect: `*=` and `@@@` are split into two tokens,

オープン
#2,809 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
55/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
活発
技術スタック
postgresql, rust

調査の方向性

Start by running the reproduction with PostgreSqlDialect and Parser::parse_sql on SELECT a *= b and SELECT a @@@ b, then find where the tokenizer groups operator characters into operator tokens. The issue lists the operators to support (*=, *<>, *<, *<=, *>, *>=, @@@) and the OPERATOR(pg_catalog.*=) form. Done means each statement parses as a single operator and to_string() round-trips without splitting.

索引モデルが issue の本文から書いたものです。

説明

PostgreSQL

version 0.63.0, PostgreSqlDialect.

PostgreSQL's lexer reads a run of operator characters as one operator (manual, "Lexical Structure", "Operators"; src/backend/parser/scan.l). However, sqlparser only recognizes a specific list, so operators end up split.

The composite type comparison operators (manual, "Composite Type Comparison")::

SELECT a *= b    -- Expected: an expression, found: =
SELECT a *<> b   -- Expected: an expression, found: <>
SELECT a *< b    -- Expected: an expression, found: <
SELECT a *<= b   -- Expected: an expression, found: <=
SELECT a *> b    -- Expected: an expression, found: >
SELECT a *>= b   -- Expected: an expression, found: >=

The @@@ operator doesn't cause an error but is parsed incoretory.

SELECT a @@@ b   -- parses as a @@ (@b); to_string() gives: SELECT a @@ @b
`SELECT 'a b'::tsvector @@@ 'a'::tsquery;   -- t
SELECT 'a b'::tsvector @@ @ 'a'::tsquery;  -- ERROR: operator does not exist

I ran into similar issues trying to write it as OPERATOR() which failed similiarly:

SELECT a OPERATOR(pg_catalog.*=) b    -- Expected: ), found: =
SELECT a OPERATOR(pg_catalog.@@@) b   -- Expected: ), found: @

The * operators are valid on PostgreSQL 18.6, on values of a record type:

SELECT a *= b, a = b, a *< b, a *<> b
FROM (SELECT ROW(1.0) a, ROW(1.00) b) s;   -- f | t | f | t

How to reproduce:

use sqlparser::{dialect::PostgreSqlDialect, parser::Parser};
for sql in ["SELECT a *= b", "SELECT a @@@ b"] {
    println!("{:?}", Parser::parse_sql(&PostgreSqlDialect {}, sql).map(|s| s
}
主要言語
Rust
スター
3.5k
フォーク
805
平均マージ
2日 3時間
マージ済み PR(30日)
116

環境構築

  • Dockerfile・Docker Compose ファイルなし
  • プルリクエストのテンプレートあり
  • コントリビューションガイドなし

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

apache/datafusion-sqlparser-rs のほかの issue

apache/datafusion-sqlparser-rs の issue をすべて見る

似ている issue

Rust の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。