apache / apache/datafusion-sqlparser-rs

`SHOW` statements silently dropping quoted strings

Aperta
#616 4 commenti 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
Rust
Stelle
3.5k
Fork
772
Merge medio
4g 9h
PR unite (30g)
17

Descrizione

When parsing generic `SHOW` statements such as `SHOW FUNCTIONS` or `SHOW PARAMETERS`, the parser creates a `ShowVariable` AST with each of the tokens after `SHOW` added as a `variable` node. This should allow functionality like `SHOW FUNCTIONS LIKE '%date%'` to be written by processing the AST even if the lexer doesn't understand what the query means.

However, this query `SHOW FUNCTIONS LIKE '%date%'` is parser to:

~~~json
[
{
"ShowVariable": {
"variable": [
{
"value": "FUNCTIONS",
"quote_style": null
},
{
"value": "LIKE",
"quote_style": null
}
]
}
}
]
~~~

Where the value in quotes is removed.

I think this is probably because `SHOW` queries, not followed by a well-known token (e.g. `SHOW VARIABLES`, `SHOW COLUMNS`) defaults to a variation of `SHOW VARIABLE`, and the tokens afterwards are expected to be formatted like Identifiers, but a quoted string doesn't match this expectation. If that is the case, I expect an error to be raised rather than silently dropping part of the query.

Thanks

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Direzione di ricerca

Riproduci SHOW FUNCTIONS LIKE '%date%' e segui il parser generico delle istruzioni SHOW che costruisce l’AST ShowVariable. Confronta la gestione dei token tra virgolette con l’AST mostrato; il lavoro è completato quando il valore tra virgolette viene preservato oppure il parser segnala un errore invece di scartarlo silenziosamente.

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

Valutazione

Stack tecnologico
rust, sql
Ambito
compilers, databases
Tipo di issue
Bug
Difficoltà
3/5
Tempo stimato
1-2 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.