Transform rows to columns with smart pivot/cross-tabulation
Table-in, table-out — composes downstream of SELECTs.
THEN PIVOT {{ prompt }}THEN PIVOT({{ prompt }})| name | type | description |
|---|---|---|
| prompt | VARCHAR | — |
| _table | TABLE | — |
Crosstabulates region values into pivoted revenue columns
SELECT
*
FROM
(
VALUES
('Widget', 'North', 10),
('Widget', 'South', 20),
('Gadget', 'North', 5),
('Gadget', 'South', 8)
) AS t (product, region, revenue) THEN PIVOT ('revenue by region for each product') THEN PYTHON (
'result = pd.DataFrame({"ok":[len(df) in (2, 3) and "North" in df.columns and "South" in df.columns and int(df.loc[df["product"] == "Widget", "North"].iloc[0]) == 10]})'
)Apply theme styling to a chart specification
Analyze query results with LLM based on a prompt
Remove duplicate rows
Add LLM-computed columns to query results
Filter query results using LLM-based semantic matching
Group by column and aggregate another
Transform rows to columns with smart pivot/cross-tabulation
Table-in, table-out — composes downstream of SELECTs.
THEN PIVOT {{ prompt }}THEN PIVOT({{ prompt }})| name | type | description |
|---|---|---|
| prompt | VARCHAR | — |
| _table | TABLE | — |
Crosstabulates region values into pivoted revenue columns
SELECT
*
FROM
(
VALUES
('Widget', 'North', 10),
('Widget', 'South', 20),
('Gadget', 'North', 5),
('Gadget', 'South', 8)
) AS t (product, region, revenue) THEN PIVOT ('revenue by region for each product') THEN PYTHON (
'result = pd.DataFrame({"ok":[len(df) in (2, 3) and "North" in df.columns and "South" in df.columns and int(df.loc[df["product"] == "Widget", "North"].iloc[0]) == 10]})'
)Apply theme styling to a chart specification
Analyze query results with LLM based on a prompt
Remove duplicate rows
Add LLM-computed columns to query results
Filter query results using LLM-based semantic matching
Group by column and aggregate another