punya opened a new issue, #3041: URL: https://github.com/apache/datafusion-sqlparser-rs/issues/3041
`|> SELECT DISTINCT` is misparsed, and the `|> DISTINCT` operator is not parsed. BigQuery supports both ([pipe syntax](https://cloud.google.com/bigquery/docs/reference/standard-sql/pipe-syntax)): the SELECT operator "supports standard output modifiers like `SELECT AS STRUCT` and `SELECT DISTINCT`", and `|> DISTINCT` is "similar to using a `|> SELECT DISTINCT *` clause". ### `|> SELECT DISTINCT` `PipeOperator::Select` has no `distinct` field, and the parser reads `DISTINCT` as a column name. `|> SELECT DISTINCT k` becomes a select item `distinct AS k`. In DataFusion: ```sql SELECT * FROM (VALUES (1, 10), (1, 20)) AS t("distinct", v) |> SELECT DISTINCT k; ``` returns two rows, `1` and `1`, under a column named `k`: no deduplication, and `k` is an alias rather than a column. Without a column named `distinct`, the query fails with `No field named distinct`. Expected: `PipeOperator::Select` carries an `Option<Distinct>` (as `Select::distinct` does), parsed the same way as in a standard `SELECT`. ### `|> DISTINCT` ```sql SELECT * FROM t |> DISTINCT ``` fails with `Expected: one of SELECT or EXTEND or SET ...`. Expected: a `PipeOperator::Distinct` variant. Seen on 0.63.0 and on `main` (`parse_pipe_operators` in `src/parser/mod.rs`). Follow-up to #1758; the DataFusion side is apache/datafusion#14660. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
