Skip to main content

Module pipe_syntax

Module pipe_syntax 

Source
Expand description

P10: SQL Pipe Syntax — FROM t |> WHERE x |> SELECT y → standard SQL.

Spark 4.0 introduced pipe syntax for SQL readability. This module provides a pre-processor that converts pipe syntax to standard SQL before parsing.

§Syntax

-- Pipe syntax
FROM orders |> WHERE amount > 100 |> SELECT customer_id, amount

-- Equivalent standard SQL
SELECT customer_id, amount FROM orders WHERE amount > 100

§Supported Pipe Operators

  • |> WHERE <condition> — filter rows
  • |> SELECT <columns> — project columns
  • |> GROUP BY <columns> — group rows
  • |> ORDER BY <columns> — sort rows
  • |> LIMIT <n> — limit output rows
  • |> JOIN <table> ON <condition> — join with another table
  • |> LEFT JOIN <table> ON <condition> — left join
  • |> RIGHT JOIN <table> ON <condition> — right join
  • |> INNER JOIN <table> ON <condition> — inner join
  • |> CROSS JOIN <table> — cross join

Enums§

PipeSyntaxError
Errors that can occur during pipe syntax processing.

Functions§

has_pipe_syntax
Check if SQL contains pipe syntax.
process_pipe_syntax
Pre-process SQL to convert pipe syntax to standard SQL.