SQL (Apache Spark SQL) Syntax Support in Transformation Flow Operators

Learn about the SQL (Apache Spark SQL) syntax elements and features supported by transformation flow operators, including supported statements, clauses, functions, and advanced capabilities.

Transformation flow operators use SQL (Apache Spark SQL) to enable powerful data transformations. Understanding the supported syntax elements helps you write effective queries for your data processing workflows. The table below provides a comprehensive overview of all supported SQL (Apache Spark SQL) features available in transformation flow operators.

For more information on SQL (Apache Spark SQL), see SQL Reference Guide for Apache SparkInformation published on non-SAP site.

Category Supported Details

Statements

SELECT queries only

Top-level statement must always be a SELECT query (no DDL/DML)

FROM Clause

Tables, views, subqueries, table-valued functions

Fully-qualified names (catalog.db.table), aliases

Joins

INNER, LEFT [OUTER], RIGHT [OUTER], FULL [OUTER], CROSS, LEFT SEMI, LEFT ANTI, NATURAL

Join conditions using ON or USING

Filtering

WHERE with boolean expressions

=, <, <=, <>, !=, IN, BETWEEN, LIKE, IS NULL, EXISTS / NOT EXISTS, AND, OR, NOT

LIKE Predicate

[NOT] LIKE pattern [ESCAPE char]

% matches any sequence of characters, _ matches any single character

Sorting & Pagination

ORDER BY, SORT BY, LIMIT

ASC/DESC, NULLS FIRST/LAST. ORDER BY: global sort. SORT BY: per-partition sort (Spark-specific)

Grouping & Aggregation

GROUP BY, HAVING, GROUPING SETS

Standard aggregate functions (COUNT, SUM, AVG, MIN, MAX, ...). SELECT aliases can be used in GROUP BY

Window Functions

func(...) OVER (...)

PARTITION BY, ORDER BY, ROWS/RANGE frames. Frame bounds: UNBOUNDED PRECEDING, N PRECEDING, CURRENT ROW, N FOLLOWING, UNBOUNDED FOLLOWING. Named window definitions: WINDOW w AS (...) reusable via OVER w

Expressions

Arithmetic, comparisons, logical, CASE, CAST, scalar subqueries

+, -, *, /, %. CASE WHEN ... THEN ... [ELSE ...] END. CAST(expr AS type) / TRY_CAST(expr AS type). Nested expressions with parentheses

Identifiers

Unquoted or backtick-quoted

Backticks for reserved words or names with spaces/special characters

Literals

String, numeric, boolean, NULL, date, timestamp, interval

'string' (single-quoted), 42 (INT), 42L (BIGINT), 3.14 (DECIMAL), TRUE/FALSE, NULL, DATE '2024-01-31', TIMESTAMP '2024-01-31 10:00:00', INTERVAL 5 DAY, INTERVAL 1 YEAR 2 MONTHS

Set Operators

UNION, INTERSECT, EXCEPT, MINUS

Set operators combine two input relations into a single one. [ALL] preserves duplicates; without it, duplicates are removed. MINUS is a Spark alias for EXCEPT

Inline Table

VALUES

Inline table is a temporary table created using a VALUES clause. Example: VALUES (v1, v2), (v3, v4) AS alias (col1, col2)

Advanced

PIVOT, UNPIVOT, subqueries in FROM or WHERE

PIVOT: aggregate values based on specific column values. UNPIVOT: transform columns into rows (reverse of PIVOT). Subqueries as derived tables in FROM or as IN/EXISTS/scalar expressions

Hints

Partition hints, join type hints

Syntax: /*+ hint */. Partition: COALESCE(n), REPARTITION(n, col), REBALANCE(col). Join type: BROADCAST(t), MERGE(t), SHUFFLE_REPLICATE_NL(t)