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

Abierto
#2,961 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
55/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
rust, sql

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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.

Lenguaje dominante
Rust
Estrellas
3.5k
Forks
805
Merge medio
2 d 3 h
PR fusionados (30 d)
116

Preparar el entorno

  • Sin Dockerfile ni archivo de Docker Compose
  • Tiene una plantilla de pull request
  • Sin guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de apache/datafusion-sqlparser-rs

Todos los issues de apache/datafusion-sqlparser-rs

Issues similares

Más issues de Rust

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.