parse_drop silently discards TEMPORARY and PERSISTENT for most object types

Aperta
#2,779 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
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
rust, sql
Ambito
compilers

Direzione di ricerca

Start in src/parser/mod.rs at Parser::parse_drop, where TEMPORARY and PERSISTENT are consumed before the object type is read. Use the existing Statement::Drop and DROP SECRET branches, which keep these flags, as the model. Done means DROP TEMPORARY FUNCTION keeps its flag in a dialect that supports it, and the other object types reject the keyword with a parse error. Check the dialect tests for MySQL, Generic and DuckDB.

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

Descrizione

Databricks DuckDB Hive MySQL Spark

parse_drop consumes TEMPORARY (MySQL, Generic, DuckDB) and PERSISTENT (DuckDB) before it reads the object type. Only Statement::Drop and DROP SECRET keep these flags. Every other branch drops them, so the statement parses without error but loses the keyword when printed:

Input Dialect Output
DROP TEMPORARY FUNCTION f Generic DROP FUNCTION f
DROP TEMPORARY TRIGGER tr ON t Generic DROP TRIGGER tr ON t
DROP TEMPORARY PROCEDURE p Generic DROP PROCEDURE p
DROP PERSISTENT TABLE t DuckDB DROP TABLE t

The same applies to POLICY, CONNECTOR, DOMAIN, EXTENSION and OPERATOR.

In most cases the input isn't valid SQL anyway, so it should fail instead of being accepted. DROP TEMPORARY FUNCTION is real syntax in Spark/Databricks and Hive, so there the parser drops meaningful information.

Expected

Reject TEMPORARY/PERSISTENT for object types that don't support them, and keep the flag where a dialect does support it, e.g. DROP TEMPORARY FUNCTION.

Code

src/parser/mod.rs, Parser::parse_drop

Spotted while reviewing #2434

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.