How-to guides

Standard runtimeDownload PDF (1.7 MB)

Read from a connection#

Standard supports the SQL sources below. Write the query in the source's own SQL dialect.

Family Connections
Relational SQL Server, PostgreSQL, MySQL, Oracle, DB2, SAP HANA, TimescaleDB
Warehouses Snowflake, Redshift, Google BigQuery, Athena, Teradata, Exasol, Firebolt, SkySQL
Document / search Cosmos DB, Elasticsearch, Cassandra
Lakehouse Groundzero lakehouse
sql
SELECT customer, SUM(amount) AS revenue
FROM sales.orders
GROUP BY customer
HAVING SUM(amount) > 1000
ORDER BY revenue DESC

Rules of thumb:

  • Qualify tables with their schema (sales.orders). Lineage uses the qualified name.
  • Put filters, joins and aggregations in the SQL. The source is better at them than Prep code.
  • Select only the columns you need.

Other connection types

Sources that are not SQL (for example object storage queries) use their own query body. They run in a DuckDB or Spark runtime rather than Standard; the designer will not offer Standard for them.

Query lakehouse tables#

Create a connection of type Groundzero lakehouse, then query tables as schema.table.

sql
SELECT region, COUNT(*) AS orders, SUM(amount) AS revenue
FROM sales.orders
WHERE order_date >= DATE '2026-01-01'
GROUP BY region

Reads are scoped to the caller: the lakehouse access policies that apply to you also apply to your result, and cached rows are only reused after the policy check passes.

Standard reads, it does not write

A Standard dataset runs a read query. To write to lakehouse tables, use a DuckDB or Spark job.

Work with datasets, outputs and previews#

A run returns one page. The fields to know:

  • totalRecords: rows available across all pages.
  • hasMore: true while more pages remain.
  • pageStart, pageEnd, pageNumber: the window you received.
  • schema: one entry per column with columnName and dataType.

Request the next page by increasing pageNumber. Page size defaults to 1000 and is capped at 1000 rows.

json
{
  "ConnectionName": "SalesWarehouse",
  "DataSourceQuery": "SELECT * FROM sales.orders ORDER BY order_id",
  "TransformationQuery": "outputDF = queryData",
  "pageSize": 500,
  "pageNumber": 3
}

Always ORDER BY when paging

Pages are cut from the result in the order the source returns it. Add an explicit ORDER BY so that page 2 never repeats rows from page 1.

Saved datasets can be used as the source of visualizations and dashboards, and appear in the lineage graph with their source tables.

Use parameters and placeholders#

Two kinds of placeholder exist.

Server-side placeholders are replaced by the engine before the query runs.

Placeholder Becomes
${USR} The signed-in user name, as a quoted string
${USRGRPS} The user's groups, comma-joined, as one quoted string
${SITENM} The site name, as a quoted string
${CLNTNM} The client name, as a quoted string
${RGN} The region, as a quoted string
${STRTTM} The request time YYYY-MM-DD HH:MM:SS, wrapped for code (see the warning below)
sql
SELECT order_id, customer, amount
FROM sales.orders
WHERE sales_rep = ${USR}

Write the placeholder without quotes

${USR}, ${SITENM}, ${CLNTNM}, ${RGN} and ${USRGRPS} already expand to a single-quoted literal. Writing '${USR}' produces doubled quotes and a syntax error. ${STRTTM} expands to the timestamp wrapped in double and single quotes, which is meant for Prep code (a Python string), not for SQL.

Single braces are replaced too

The engine also replaces {USR}, {SITENM}, {CLNTNM}, {RGN}, {USRGRPS}, {STRTTM} and {ERR} written with single braces. Avoid those exact names in Python format strings in Prep code.

Filter placeholders {{filter.prop}} are filled in by the dashboard or visualization that reads your dataset. If a filter has no value, the run fails with Filter 'name' has no value before it reaches the source.

Filter without changing the query text#

Dashboards can send filters as data. Groundzero adds them to the query's WHERE clause using parsed expressions, never string concatenation, and keeps cache entries stable across filter changes.

json
{
  "ConnectionName": "SalesWarehouse",
  "DataSourceQuery": "SELECT o.region, o.amount FROM sales.orders AS o",
  "TransformationQuery": "outputDF = queryData",
  "pageSize": 100,
  "filters": [
    {"column": "region", "table": "o", "op": "in", "values": ["EMEA", "APAC"]},
    {"column": "amount", "table": "o", "op": "gte", "values": [100]}
  ]
}

When filters is present, send the base query without those filters. Fixed predicates may stay in the query. See the API reference for the operators.

Reshape results with Prep code#

Prep is ordinary Python with pandas available as pd.

python
orders = pd.DataFrame(queryData)
orders["order_date"] = pd.to_datetime(orders["order_date"])
orders["month"] = orders["order_date"].dt.strftime("%Y-%m")
outputDF = orders.groupby("month", as_index=False)["amount"].sum()

outputDF may be a DataFrame, a Series, a list of dictionaries, a list of plain values, a dictionary (one row) or a single value. Anything that is not a DataFrame or list of dictionaries is converted to rows (see the API reference).

Schedule with ETL jobs#

A Standard dataset answers requests on demand; it is not itself scheduled. To run work on a schedule, create an ETL job on the Python (pandas), DuckDB or Spark runtime and attach a schedule. A scheduled run may be given a stop time; the run then ends at that moment. Job runs go through the statuses Queued, Running, Success, Failed and Aborted, and write logs you can read from the job's run page.

Install extra packages (custom runtime)#

Standard datasets cannot import additional packages. For jobs, create a custom runtime.

  1. Prepare a requirements.txt with one pip requirement per line.
  2. Upload it in the custom runtime screen and choose the base runtime to extend and a tag name.
  3. Groundzero builds the runtime from that base and installs your packages.
  4. Watch the build status move from QUEUED to IN PROGRESS and then SUCCESS or FAILURE.
  5. Choose the new runtime when you create the job.
splink
sqlglot
snowflake-connector-python

Pin versions (package==1.2.3) for repeatable builds.

Tune performance#

Order of effect, biggest first.

  1. Push work to the source. Filter, join and aggregate in SQL.
  2. Keep Prep a pass-through when possible. Real Prep must see every source row, so Groundzero fetches the full result before it paginates. A pass-through keeps server-side paging.
  3. Select fewer columns and rows. Cached payloads larger than 8 MiB are not cached.
  4. Use structured filters so one cached base serves many filter choices.
  5. Prefer the lakehouse connection for large tables: reads are columnar and go straight to object storage.
  6. For results beyond what fits in a page-by-page workflow, move to DuckDB or Spark.

Logging and errors#

Standard returns errors in the response body with status: "error", an errorCode and a message. An exception inside Prep code returns the exception text, with totalRecords set to the number of source rows and an empty page. Test Prep logic locally with a small list of dictionaries first (see the last example in the gallery). For jobs, open the run's log view.