Skip to content

Conversation

@alexander-beedie
Copy link
Contributor

@alexander-beedie alexander-beedie commented Jan 8, 2026

There's a bug in Pipe SQL parsing with identifiers followed by the |> operator.

Fix

parse_identifiers needs to break on Token::VerticalBarRightAngleBracket as well, otherwise it continues to consume the following tokens as Ident (until one of the other break conditions is encountered).

Example

FROM t |> DROP c |> RENAME a AS x

Without the fix the DROP section consumes the RENAME tokens as identifiers:

Drop { columns: [
    Ident { value: "c" },
    Ident { value: "RENAME" },
    Ident { value: "a" },
    Ident { value: "AS" },
    Ident { value: "x" }]
}

After the fix the identifier boundary is respected, and the operations parse correctly:

Drop { columns: [Ident { value: "c" }] }
Rename { mappings: [
    IdentWithAlias { ident: Ident { value: "a" }, alias: Ident { value: "x" } }]
}

Also

Updated the pipe operator tests with some new coverage for the above, and a helper that additionally validates queries that start "FROM <tbl>" (in addition to "SELECT * FROM <tbl>") with the pipe operator.

@alexander-beedie alexander-beedie changed the title Fix identifier parsing not breaking on the pipe operator Fix identifier parsing not breaking on the |> pipe operator Jan 8, 2026
dialects.verified_stmt(
"SELECT * FROM users |> UNION (SELECT * FROM admins), (SELECT * FROM guests)",
);
// 'select' pipe operator
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if its possible can we use the previous format of explicitly writing out the test cases and expected results? I imagine that might be more verbose but its useful readability wise to know the cases that are being covered and what the tests do at a glance

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants