Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Casts should accept Postgres type names and list types, e.g. `x::int4`, `$1::int8[]`

Chiusa
#6,155 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Una pull request collegata è già stata integrata.

  • #6191 di @jarohen — integrata

Valutazione

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

Direzione di ricerca

Start with the SQL grammar that defines cast targets and array types, and with CastArgsVisitor where visitArrayType is still abstract. Check how the existing scalar type names are matched so the Postgres aliases (int4, float8, bool, jsonb) can map onto them. Done when the statements in the issue (SELECT 1::int4, SELECT 'a'::text[], $1::BIGINT ARRAY, $1::int8[]) parse and cast without errors.

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

Descrizione

npgsql pgwire

Casts using Postgres's own type names — int4, float8, bool, jsonb, text[] and the like — are parse errors, and casts to a list type fail in either spelling, though the SQL-standard spellings of scalar types work.

  • SQL ported from Postgres, and some generated SQL, uses these names

  • The SQL-standard spellings of scalar types already work
    CAST(x AS INTEGER), x::BIGINT, x::DOUBLE PRECISION all parse, so for scalars this is a gap in the accepted names rather than in the types.

Symptoms

Seen on main at 13aef89, via psql.

  • Postgres type names fail to parse as a cast target, via :: or CAST(... AS ...): int2, int4, int8, float4, float8, bool, bpchar, name, json, jsonb.

    SELECT 1::int4
    ERROR:  08P01: Errors parsing SQL statement:
      - line 1:10 no viable alternative at input '1::int4'
    
  • <type>[] fails to parse

    SELECT 'a'::text[]
    ERROR:  08P01: Errors parsing SQL statement:
      - line 1:16 mismatched input '[' expecting {<EOF>, ';'}
    
  • <type> ARRAY parses, then fails with an internal error — literals and parameters alike ([1,2]::BIGINT ARRAY, CAST([1,2] AS BIGINT ARRAY), $1::VARCHAR ARRAY).

    ERROR:  Method xtdb/sql/CastArgsVisitor.visitArrayType(Lxtdb/antlr/Sql$ArrayTypeContext;)Ljava/lang/Object; is abstract
    DETAIL:  {"category":"fault","code":"xtdb.error/unknown", ...}
    

Problem

  • SQL written for Postgres has to be rewritten before XTDB will run it, when the only difference is the spelling of a type it already supports.

  • There is no working way to cast to a list type
    $1::int8[] is how a Postgres client pins an array parameter's type, and neither it nor the SQL-standard $1::BIGINT ARRAY works.

Out of scope

  • json / jsonb as cast targets
    XTDB has no text-to-document cast, so '{"a": 1}'::jsonb has no meaning to give it yet, and an identity cast would leave the string a string.
    That wants its own card.

  • Arrays of timestamptz and interval
    Their scalar casts aren't expressed as a target type, so there's nothing to apply per element.


Generated by Claude Code

Lingua principale
Clojure
Stelle
3.1k
Fork
193
Merge medio
1g 18h
PR unite (30g)
56

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

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 xtdb/xtdb

Tutte le issue di xtdb/xtdb

Issue simili

Altre issue su Clojure

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.