Redshift dialect: `--` and `/*` inside an operator should start a comment

Aperta
#2,961 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
55/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
rust, sql

Direzione di ricerca

Start from the tokenizer's operator lexing, where HashMinus (#-) and PGSquareRoot (|/, ||/) are produced, and check how the Redshift dialect handles them compared with Postgres. Reproduce with select 2 #--' 3, pg_backend_pid() --' and select 9 |/*'*/ 2, which should produce a comment rather than a token. Done when both queries parse as a comment-terminated operator, matching the Postgres rule that -- and /* cannot appear inside an operator.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Redshift

Postgres-family lexers never let -- or /* be part of an operator; the operator ends there and a comment starts. sqlparser lexes #- (and |/, ||/) as one token first, which leaves the rest of the comment marker behind.

select 2 #--'
 3, pg_backend_pid() --'
  • sqlparser 0.64.0: HashMinus, Minus, then the string '\n 3, pg_backend_pid() --'; parses as SELECT 2 #- -'...'.
  • Redshift: two columns, 1 (that is, 2 # 3) and 1073905994.

The same happens with /*: select 9 |/*'*/ 2, pg_backend_pid() --' returns 11 and the pid on Redshift, while sqlparser lexes PGSquareRoot, Mul, a string, and fails to parse.

Postgres documents the rule under "Operators" (https://www.postgresql.org/docs/8.0/sql-syntax.html#SQL-SYNTAX-OPERATORS): "-- and /* cannot appear anywhere in an operator name, since they will be taken as the start of a comment." Postgres's own dialect in sqlparser likely has the same gap.

Lingua principale
Rust
Stelle
3.5k
Fork
805
Merge medio
2g 3h
PR unite (30g)
116

Preparare l'ambiente

  • Nessun Dockerfile né file Docker Compose
  • Ha un modello di pull request
  • Nessuna guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di apache/datafusion-sqlparser-rs

Tutte le issue di apache/datafusion-sqlparser-rs

Issue simili

Altre issue su Rust

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.