surfacevisualizationto_vegalite
Visualizationpipeline · returns table

TO_VEGALITE

Generate a Vega-Lite chart from data using LLM

Table-in, table-out — composes downstream of SELECTs.

visualizationllmpipeline-composabletext

Syntax

THEN TO_VEGALITE {{ prompt }}
THEN TO_VEGALITE({{ prompt }})

Arguments

nametypedescription
promptVARCHAR
_tableTABLE

About

PIPELINE cascade for generating Vega-Lite chart SQL with structural caching. Uses table_sql_execute mode - the LLM generates SQL that: - Reads from _input_table (the pipeline input) - Adds 'format' and 'config' columns for chart rendering - Can include aggregations, filters, or transformations - Is cached by schema fingerprint (same columns = reuse SQL) Usage: SELECT month, revenue FROM sales THEN TO_VEGALITE 'line chart with points showing revenue trend' Returns data with format/config columns that the UI renders as a chart.

Examples

Generates Vega-Lite chart config rows that reference the input schema

SELECT
  *
FROM
  (
    VALUES
      ('A', 10),
      ('B', 20)
  ) AS t (category, amount) THEN TO_VEGALITE ('bar chart of amount by category') THEN PYTHON (
    'import json; config = df.iloc[0]["config"]; config = json.loads(config) if isinstance(config, str) else config; result = pd.DataFrame({"ok":[df.iloc[0]["format"] == "vega-lite" and "mark" in config and config["x"] == "category"]})'
  )

Nearby rabbit holes

same domain
Climb back to The Looking Glass