Redshift dialect: `regtype 'int4'` parses as a column with an alias, not a typed literal

Abierto
#2,962 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
48/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
rust, sql
Área
databases

Línea de trabajo

The bug is in how the parser decides between a typed string literal and an alias, so start where it handles the Regclass type, which already parses as a typed string. Check how the Redshift dialect is gated, then run select regtype 'int4', select regproc 'version' and select regclass 'pg_user' under that dialect to compare. Done when the first two parse as typed literals with the expected type and the existing parser tests still pass.

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

Descripción

Redshift

Redshift, like Postgres, accepts the generic typed-literal form type 'string' for any type name. sqlparser parses it as a typed string only for types it knows, such as regclass. For other type names it reads the type as a column and the string as an alias.

select regtype 'int4'
  • sqlparser 0.64.0: ExprWithAlias { expr: Identifier("regtype"), alias: Ident { value: "int4", quote_style: Some('\'') } }, i.e. the column regtype aliased as 'int4'.
  • Redshift: one row, integer, i.e. the literal 'int4' cast to regtype.

Other forms behave the same way: select "regtype" 'int4' returns integer and select regproc 'version' returns version on Redshift, while sqlparser parses both as aliased columns. select regclass 'pg_user' already parses as a typed string because sqlparser has a Regclass data type.

Postgres documents the syntax under "Constants of Other Types" (https://www.postgresql.org/docs/8.0/sql-syntax.html#SQL-SYNTAX-CONSTANTS-GENERIC), and Redshift is based on PostgreSQL 8.0.2 (https://docs.aws.amazon.com/redshift/latest/dg/c_redshift-and-postgres-sql.html).

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.