parse_drop silently discards TEMPORARY and PERSISTENT for most object types

Ouverte
#2,779 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Les mainteneurs répondent en général sous 1 jour

Personne n'a encore pris cette issue.

Évaluation

Difficulté
3/5
Temps estimé
1-2 jours
Accessibilité débutants
55/100
Type d'issue
Bug
Clarté
Plutôt claire
Activité
Active
Stack technique
rust, sql
Domaine
compilers

Piste de recherche

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.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

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

Langage dominant
Rust
Étoiles
3.5k
Forks
805
Merge moyen
2 j 3 h
PR mergées (30 j)
116

Préparer son environnement

  • Aucun Dockerfile ni fichier Docker Compose
  • Propose un modèle de pull request
  • Aucun guide de contribution

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de apache/datafusion-sqlparser-rs

Toutes les issues de apache/datafusion-sqlparser-rs

Issues similaires

Plus d'issues Rust

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.