apache / apache/datafusion-sqlparser-rs

`SHOW` statements silently dropping quoted strings

Open
#616 4 comments 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
3.5k
Forks
772
Avg merge
4d 9h
Merged PRs (30d)
17

Description

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

Contributor guide

No contributing guide indexed for this repository

Research direction

Reproduce SHOW FUNCTIONS LIKE '%date%' and trace the generic SHOW statement parser that builds the ShowVariable AST. Compare its handling of quoted tokens with the shown AST; done means the quoted value is preserved or the parser reports an error instead of silently dropping it.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust, sql
Domain
compilers, databases
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.