Skip to content

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

Open

Description

@preston-footprint

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions