Skip to content

Pipe syntax: |> SELECT DISTINCT is misparsed and |> DISTINCT is not supported #3041

Backlog

Description

@punya

|> SELECT DISTINCT is misparsed, and the |> DISTINCT operator is not parsed. BigQuery supports both (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:

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

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions