apache / apache/datafusion-sqlparser-rs

[Postgres] Parsing sequence of `SHOW` and `SET` is a bit off

Open
#1,994 0 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

```rust
Parser::parse_sql(&PostgreSqlDialect {}, "SHOW search_path; SHOW timezone; SET search_path TO public;").unwrap()
```

The above results in:

```rust
[
ShowVariable {
variable: [
Ident {
value: "search_path",
quote_style: None,
span: Span(Location(1,6)..Location(1,17)),
},
Ident {
value: "SHOW",
quote_style: None,
span: Span(Location(1,19)..Location(1,23)),
},
Ident {
value: "timezone",
quote_style: None,
span: Span(Location(1,24)..Location(1,32)),
},
Ident {
value: "SET",
quote_style: None,
span: Span(Location(1,34)..Location(1,37)),
},
Ident {
value: "search_path",
quote_style: None,
span: Span(Location(1,38)..Location(1,49)),
},
Ident {
value: "TO",
quote_style: None,
span: Span(Location(1,50)..Location(1,52)),
},
Ident {
value: "public",
quote_style: None,
span: Span(Location(1,53)..Location(1,59)),
},
],
},
]
```

Its `Display` impl results in `"SHOW search_path SHOW timezone SET search_path TO public"`

Contributor guide

No contributing guide indexed for this repository

Research direction

Reproduce the issue with Parser::parse_sql, PostgreSqlDialect, and the SHOW/SET sequence shown here. Inspect how the PostgreSQL dialect parses these statements and how their Display output is produced. Done means the statements parse as separate statements and display without absorbing later commands into the first SHOW variable.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.