How-to guides
Browse databases, tables and columns#
Expand Databases in the tree to see each database (the system database
audit is listed first), then Tables, a table and its Columns. A column
is shown as name (type). Hover over a database or table and click Open row
actions for its menu.

| Node | Menu items |
|---|---|
| Databases | Import Schema, Restore Database, Mark stale backups failed |
| A database | Properties, Export schema, Backup Database, Restore Database |
| A table | Add table on cursor, Properties, Data policy, Table Access Manager |
- Add table on cursor types
database.tableat the cursor of the active query tab. - Export schema downloads a text file with the column definitions of every table in a database, without data. Import Schema takes such a file and a database name and creates the database with one empty table per entry; tables that already exist are skipped.
- The editor's autocomplete suggests the warehouse, databases, tables (as
tableanddatabase.table), columns and connection names from the tree, plus common SQL keywords and functions.
Write queries#
Every query names its tables as database.table. Run a statement with the
Run query button; there is no keyboard shortcut. The whole tab is sent, not
only the selected text, so keep one statement per tab and open a new tab with
+ for the next one.

Use block comments
Before a query is sent, every run of spaces and line breaks is collapsed to a
single space. A -- comment would therefore comment out the rest of the
statement. Write comments as /* like this */, which survives.
Page and export any result
Wrap a UNION or a VALUES list in a select, for example
SELECT * FROM (SELECT .. Results of a plain
SELECT (including WITH ... SELECT) can be paged beyond 100,000 rows and
exported; other row-returning forms show at most the first 100,000 rows.
SELECT, filters and ordering#
SELECT order_id, customer_id, order_total
FROM sales.orders
WHERE status = 'COMPLETE'
AND order_ts >= TIMESTAMP '2026-09-01 00:00:00'
AND channel IN ('online', 'mobile_app')
ORDER BY order_total DESC
LIMIT 20GROUP BY ALL groups by every non-aggregate column in the select list, and
SELECT DISTINCT, HAVING, LIMIT and OFFSET work as in standard SQL.
Joins#
SELECT o.order_id, c.name, c.segment, o.order_total
FROM sales.orders AS o
JOIN customers.profiles AS c
ON c.customer_id = o.customer_id
LEFT JOIN sales.returns AS r
ON r.order_id = o.order_id
WHERE r.order_id IS NULLINNER, LEFT, RIGHT, FULL, CROSS, LEFT SEMI and LEFT ANTI joins are
supported. A semi or anti join is a clear way to say "customers who have (or
have not) ordered":
SELECT c.customer_id, c.name
FROM customers.profiles AS c
LEFT ANTI JOIN sales.orders AS o
ON o.customer_id = c.customer_idCommon table expressions and subqueries#
WITH monthly AS (
SELECT date_trunc('month', order_ts) AS month,
SUM(order_total) AS revenue
FROM sales.orders
WHERE status = 'COMPLETE'
GROUP BY 1
)
SELECT month,
revenue,
revenue - LAG(revenue) OVER (ORDER BY month) AS change
FROM monthly
ORDER BY monthSubqueries work in FROM, WHERE (IN, EXISTS, scalar) and the select list.
Window functions#
SELECT customer_id,
order_id,
order_total,
ROW_NUMBER() OVER (PARTITION BY customer_id ORDER BY order_ts) AS nth_order,
SUM(order_total) OVER (
PARTITION BY customer_id ORDER BY order_ts
ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW
) AS lifetime_value
FROM sales.ordersThe ranking functions (ROW_NUMBER, RANK, DENSE_RANK, NTILE), the value
functions (LAG, LEAD, FIRST_VALUE, LAST_VALUE) and every aggregate can
be used with OVER.
Dates, strings and other everyday functions#
| Task | Functions |
|---|---|
| Current date and time | current_date(), current_timestamp() |
| Truncate and extract | date_, trunc(date, 'MM'), year(d), month(d), dayofweek(d), extract(HOUR FROM ts) |
| Date arithmetic | date_add(d, 7), date_sub(d, 7), add_months(d, 1), datediff(end, start), months_between(a, b), last_day(d) |
| Convert | to_, to_timestamp(s), date_, cast(x AS type), try_cast(x AS type) |
| Text | concat, concat_ws, substring, lower, upper, trim, replace, regexp_replace, regexp_extract, split, length, lpad |
| Numbers | round, floor, ceil, abs, greatest, least, try_divide(a, b) |
| Nulls and conditions | coalesce, nullif, ifnull, CASE WHEN ... END, if(cond, a, b) |
| Aggregates | count, sum, avg, min, max, count(DISTINCT x), approx_count_distinct, percentile_approx, collect_list, collect_set, max_by, min_by |
| Arrays and maps | array, size, explode, array_contains, transform, map_keys, map_values, element_at |
| JSON | from_json, to_json, get_json_object |
Data types#
| Type | Notes | Shown in results as |
|---|---|---|
TINYINT, SMALLINT, INT, BIGINT |
Whole numbers of 1, 2, 4 and 8 bytes | byte, short, integer, long |
FLOAT, DOUBLE |
Binary floating point | float, double |
DECIMAL(p, s) |
Exact numbers; use for money | decimal |
STRING |
Text of any length | string |
BOOLEAN |
true or false |
boolean |
DATE |
Calendar date | date |
TIMESTAMP |
Instant, with time zone | timestamp |
TIMESTAMP_NTZ |
Date and time without time zone | timestamp_ntz |
BINARY |
Bytes | binary |
ARRAY<T>, MAP<K,V>, STRUCT<a: T, ...> |
Nested values; shown as text in the grid | array, map, struct |
Format SQL#
Format SQL (the indent icon in the editor toolbar) lays the active tab out over several lines with upper-case keywords, using the Spark dialect. It shows "No SQL query to format" for an empty tab and "Unable to format this SQL query" if the text cannot be formatted.
Create and alter Iceberg tables#
Create a table#
CREATE TABLE sales.order_items (
order_id BIGINT,
line_no INT,
sku STRING,
quantity INT,
unit_price DECIMAL(10, 2)
) USING iceberg
COMMENT 'One row per order line'CREATE TABLE IF NOT EXISTS skips the statement when the table exists. To
create a table from a query, use CREATE TABLE .; REPLACE TABLE . swaps the contents and keeps the table's history.
CREATE TABLE sales.daily_revenue USING iceberg
PARTITIONED BY (day)
AS SELECT CAST(order_ts AS DATE) AS day,
channel,
SUM(order_total) AS revenue
FROM sales.orders
GROUP BY 1, 2Partitioning#
Partitioning groups rows into files so queries that filter on the partition column read less data. Iceberg partitions by a transform of a column, so you filter on the column itself and never on a derived partition column:
| Transform | Use for |
|---|---|
years(ts), months(ts), days(ts), hours(ts) |
Timestamp and date columns |
bucket(16, id) |
Spreading a high-cardinality key over a fixed number of buckets |
truncate(4, text) |
Grouping by the first characters or a numeric range |
| plain column | Low-cardinality columns such as region |
CREATE TABLE inventory.stock_moves (
sku STRING,
store_id INT,
moved_at TIMESTAMP,
delta INT
) USING iceberg
PARTITIONED BY (days(moved_at), bucket(8, store_id))A query such as WHERE moved_ prunes
partitions automatically. Choose coarse partitions: daily or monthly for most
tables, and avoid partitioning on a column with thousands of distinct values.
You can change how a table is partitioned later. New data is written with the new layout and old data keeps the old one; both stay queryable.
ALTER TABLE sales.orders ADD PARTITION FIELD bucket(4, store_id)
ALTER TABLE sales.orders DROP PARTITION FIELD bucket(4, store_id)
ALTER TABLE sales.orders REPLACE PARTITION FIELD days(order_ts) WITH months(order_ts)The table's Properties tab (see Table properties) shows the current Partitioned By value.
Schema evolution#
Iceberg tracks columns by an internal id, so these changes are metadata-only and safe: they never rewrite data and never change the meaning of existing columns.
ALTER TABLE sales.orders ADD COLUMN coupon_code STRING
ALTER TABLE sales.orders ADD COLUMN discount DECIMAL(10, 2) AFTER order_total
ALTER TABLE sales.orders RENAME COLUMN channel TO sales_channel
ALTER TABLE sales.orders ALTER COLUMN order_id TYPE BIGINT
ALTER TABLE sales.orders ALTER COLUMN status COMMENT 'COMPLETE, RETURNED or OPEN'
ALTER TABLE sales.orders DROP COLUMN coupon_codeA type change must widen the type (INT to BIGINT, FLOAT to DOUBLE, or a
larger DECIMAL precision). Other table changes:
ALTER TABLE sales.orders RENAME TO sales.orders_archive
ALTER TABLE sales.orders SET TBLPROPERTIES ('comment' = 'All customer orders')
COMMENT ON TABLE sales.orders IS 'All customer orders'
ALTER TABLE sales.orders WRITE ORDERED BY order_tsDropping a table removes it from the catalog:
DROP TABLE IF EXISTS sales.orders_archiveInsert, update, delete and merge#
All of these are transactional: a statement either commits as one new snapshot or leaves the table unchanged.
INSERT#
INSERT INTO sales.order_items VALUES (1001, 1, 'SKU-100', 2, 49.95)
INSERT INTO sales.order_items SELECT order_id, 1, 'SKU-100', 1, 19.00 FROM sales.orders
INSERT OVERWRITE sales.daily_revenue SELECT day, channel, revenue FROM sales.stageINSERT OVERWRITE replaces only the partitions the new rows touch, not the whole
table. To replace everything, use REPLACE TABLE . or delete first.
UPDATE and DELETE#
UPDATE sales.orders SET status = 'CANCELLED' WHERE order_id = 1004
DELETE FROM sales.orders WHERE status = 'CANCELLED' AND order_ts < TIMESTAMP '2025-10-01 00:00:00'
TRUNCATE TABLE sales.staging_ordersMERGE: upsert from a staging table#
MERGE INTO updates rows that match, inserts rows that do not, and can delete.
It is the way to load changes into a table without duplicating rows.
MERGE INTO customers.profiles AS t
USING customers.profile_updates AS s
ON t.customer_id = s.customer_id
WHEN MATCHED AND s.deleted THEN DELETE
WHEN MATCHED THEN UPDATE SET
t.name = s.name, t.email = s.email, t.segment = s.segment
WHEN NOT MATCHED THEN INSERT *Make the join key unique
A source row set that matches the same target row more than once makes the
MERGE fail. De-duplicate the staging data first, for example with
ROW_NUMBER() in a subquery.
Updates, deletes and merges need the Update permission on the table; inserts need Insert. See the permission table in the SQL reference.
Time travel and snapshots#
Every commit creates a snapshot. You can query a table as it was at an earlier snapshot or time.
SELECT COUNT(*) FROM sales.orders TIMESTAMP AS OF '2026-09-30 12:00:00'
SELECT COUNT(*) FROM sales.orders VERSION AS OF 4821763650912831907To find a snapshot id, open the table's Properties tab and click the Snapshot History value, which lists the ten most recent snapshots with their id, parent, time, operation and counts of added and deleted records, or query the snapshots metadata table (next section).

To undo a mistake, roll the table back to an earlier snapshot. This needs the AlterTable permission:
CALL system.rollback_to_snapshot('sales.orders', 4821763650912831907)Snapshots are not backups
Maintenance removes old snapshots (see Expire old snapshots), after which you can no longer travel back to them. Use database backups for long-term recovery.
Metadata tables#
Every Iceberg table has read-only metadata tables that describe its snapshots, files and partitions. Query them by adding a suffix to the table name; you need Select on the table.
| Metadata table | Shows |
|---|---|
sales.orders.snapshots |
Every snapshot: id, commit time, operation, summary |
sales.orders.history |
The table's history of current snapshots |
sales.orders.files |
Data files with row counts, sizes and column statistics |
sales. |
Row and file counts per partition |
sales.orders.manifests |
The manifest files that track the data files |
sales.orders.refs |
Branches and tags |
sales. |
Earlier versions of the table metadata |
sales.orders.entries, all_entries, all_files, all_data_files, all_delete_files, all_manifests, data_files, delete_files, position_deletes |
Lower-level file and manifest detail |
SELECT snapshot_id, committed_at, operation
FROM sales.orders.snapshots
ORDER BY committed_at DESC
LIMIT 10SELECT partition, record_count, file_count
FROM sales.orders.partitions
ORDER BY record_count DESCSELECT file_path, record_count, file_size_in_bytes
FROM sales.orders.files
ORDER BY file_size_in_bytes
LIMIT 20If the table has a data policy (a row filter, a column mask or protected
access), its metadata tables refuse to run with "Metadata tables of
<table> are …: the table has data policies, and its metadata tables expose
column statistics that would reveal masked or filtered values. Query the table
itself instead." Query the table instead.
Table properties#
Choose Properties in a table's menu to open a Properties tab. The top of the tab holds the maintenance panels; the bottom pane has three tabs.

- Table Properties lists Database, Table Name, Partitioned By, Last Updated, Row Count, Description, Last Storage Optimization, Last Compaction, Storage Optimization Enabled, Format Version, Snapshot Id, File Count, Total Size Bytes, Created At, Created By, Compression Codec, Object Storage Layout, Snapshot History and Sort Order.
- Schema lists each column with its type and governance tags.
- Sample Data shows the first rows of the table for administrators.
To read the table's Iceberg properties, run SHOW TBLPROPERTIES sales..
For a database, choose Properties in its menu to see the total tables, total
size and a per-table size and file count.
Maintenance#
Tables that receive many small writes accumulate many small files and old snapshots. Maintenance keeps them fast and small. It needs the AlterTable permission through SQL, and an administrator account in the Properties tab.
Compact small files#
In the Properties tab, the Compaction panel has these controls:
| Control | Meaning |
|---|---|
| Automatic compaction | Switch on to compact the table automatically |
| Strategy | Binpack merges small files; Sort also orders rows by a sort order |
| Rewrite job order | None (default), bytes-asc, bytes-desc, files-asc or files-desc |
| Commit group | Largest amount of data rewritten in one group (default 100 GB) |
| Partial progress | Maximum number of commits (default 10) |
| Concurrent groups | File groups rewritten in parallel (default 1) |

Saving shows "Compaction process initiated successfully!" and the work runs in the background. The same operation is available in SQL:
CALL system.rewrite_data_files(table => 'sales.orders')
CALL system.rewrite_data_files(table => 'sales.orders', strategy => 'sort',
sort_order => 'order_ts ASC NULLS LAST')Storage optimization#
The Storage panel's Storage optimization switch manages the table's file layout and cleanup in the background. When it is off, you choose the Compression codec (zstd, snappy or gzip) and the Object storage layout yourself. Saving shows a confirmation, and Last Storage Optimization in the properties records the time.
Expire old snapshots#
Expiring snapshots deletes snapshot history and the files only those snapshots used. Time travel to an expired snapshot stops working.
CALL system.expire_snapshots(table => 'sales.orders',
older_than => TIMESTAMP '2026-09-01 00:00:00',
retain_last => 5)Other table procedures you can call with the AlterTable permission are
rewrite_manifests (merge manifest files) and remove_orphan_files (delete
files no snapshot references):
CALL system.rewrite_manifests('sales.orders')Long-running queries and stopping a query#
A query that is still running after about 55 seconds keeps going in your session. The Messages tab reads "Still running. Results load here when the query finishes." and the page checks for you; when the query completes, the results open. You can leave the page open and keep working in another tab.

- Stop query (the red square in place of Run) cancels it: the Messages tab reads "Query stopped."
- A query that runs longer than 30 minutes is stopped by the session with "Query ran longer than 30 minutes and was stopped."
- A session runs up to four queries at a time. A fifth is refused with "This session is already running 4 queries. Wait for one to finish or stop it, then run this query again." Preparing a full result and exporting also count.
- If the page loses contact with the session while a query runs, it shows "Lost contact with the session. Retrying…" and picks the result up again when it can. A result kept for a detached query is held for 15 minutes; after that the Messages tab reads "The session no longer has this query. Run it again."
Re-running the same query within five minutes may return the earlier result from
a cache. Any statement that changes data, such as an INSERT, clears that cache,
so results after a change are always fresh.
Results, paging and exports#
The results grid#
The grid shows each column with its type. Drag a header to reorder columns, or
right-click it for Autosize this column, Autosize all columns,
Auto-align columns and Reset column order. There is no sorting or
filtering in the grid: use ORDER BY and WHERE. Click a cell that holds
nested data or long text to read the full value and copy it. Results with very
many columns load the first 300 columns, then further groups of 200 as you
scroll right.
The toolbar above the grid shows the response time, the row count and:
| Control | Behaviour |
|---|---|
| Rows per page | 50, 100, 500, 1000 or 10000 (default 10000). Changing it goes back to page 1. |
Page n / total, previous and next |
Move through the result |
| Download current page as CSV | A CSV of the rows on screen, named query_<date>.csv, with every value quoted |
| Export | Appears when the result has more than 100,000 rows. Writes every row to one file. |
For results of 100,000 rows or more the toolbar shows the exact total, for example "1,284,310 rows". If the exact total cannot be counted, the label reads "Showing top 100K rows".

Paging past the first 100,000 rows needs the full result prepared as files in
your warehouse bucket. The page shows "Preparing the full result for paging.
Pages load here when it is ready." and pages become readable as they are written.
Without an ORDER BY, row order can differ from the first run, so always sort a
result you page through.
Exports#
-
Click Export and choose CSV or Parquet in the Export format menu.

The Export menu offers CSV and Parquet. -
The toolbar shows "Preparing CSV file" with a timer and a Stop export button. If a status check fails it shows "Export: retrying…".
-
When the file is ready, the toolbar shows a download link with the file name and size, for example
lakehouse-. The link works for about one hour; hover over it to see when it ends.result- 20261001- 101507. csv 
A finished export is a download link.
Exports re-run your query, so row filters and column masks apply exactly as in
the grid. CSV exports have one header row, write nested values as JSON text and
write time-zone timestamps in UTC. Each export is recorded in the audit log with
the operation EXPORT. If an export fails, the red message beside Retry
export says why (see Troubleshooting).
If you only need the result inside the Lakehouse, keep it there with
CREATE TABLE . instead of exporting it.
Saved queries#
Save query (the disk icon) asks for a name in the Save As dialog and stores the SQL for you with the warehouse. The tab takes the saved name, and the notification reads "Query saved successfully". Saving a name that already exists is refused with "Key already exists."

Open Saved Queries in the left rail to list your queries with their warehouse, who changed them and when. Click a name to open the warehouse with the SQL in one tab (start a session to run it). Rename and Delete are in each row's Actions menu.

Unsaved text lives only in the page. Reloading the browser loses open tabs, so save a query you want to keep.
Governed tables, data policies and table access#
Two features decide what each person sees. Both apply to the editor, exports,
saved queries and any statement that reads the table, including CREATE TABLE
., which stores the masked or filtered values it was given.
Permissions you may be missing#
Groundzero checks every statement at three levels. A refusal reads "You do not
have All or <Action> permission", for example "You do not have All or Select
permission".
- Warehouse: create, delete and list warehouses, create and drop databases.
- Database: select, insert, update, create table, alter table and drop table on the tables of a database.
- Table: allow or deny rules for single tables, set in the Table Access Manager.
A table rule that denies an action always wins. Ask your administrator for the grant named in the message.
Data policies#
Choose Data policy in a table's menu to see or edit the policy for
database.table. You need Select on the database to open it and All to change
it. A policy has:
- Protected access: Policy only applies the policy to every read;
Block raw reads stops all reads of the table with "Table access blocked by
protected policy:
<database>.<table>". - Base row filter: a SQL condition added as a
WHEREto every read for everybody. Click a column chip under Available columns to insert a column name. The templates${user},${site},${groups}and${attr.<name>}expand to the signed-in user, site, groups and user attributes. - Base column masks: a mask per column.
- Principal rules: extra filters and masks for one User, one Group or the Default. A rule's filter is added to the base filter.

| Mask | What a reader sees |
|---|---|
full |
**** (or your replacement) for text; NULL for other types |
partial |
The first characters (3 by default) followed by *** (or your replacement) |
hash |
The SHA-256 hash of the value |
null |
NULL |
deny |
The query fails with "Column access denied by masking policy" |
unmask |
Removes a base mask for the user, group or default of a principal rule |
When several masks apply to a column, the strictest wins: deny, then full, null,
hash and partial. hash and partial apply only when the column is selected
directly; an expression such as upper(email) gets the full mask.
Masked columns cannot be used in WHERE, GROUP BY, HAVING, ORDER BY,
JOIN ... ON or window clauses: the query fails with "Masked columns cannot be
used in <clause> clauses". Select the masked column and filter on another one.
SELECT * is expanded with the masks applied, but a * cannot be masked when
the query has common table expressions, subqueries, joins or several tables;
list the columns instead. A masked column that exists in several tables must be
qualified ("Ambiguous unqualified masked column 'email'; qualify it").
JSON to save shows the whole policy as you edit it; Upload loads a policy and Copy copies it. Version history lists every saved version, newest first, with Restore. Save, Disable policy and Restore each create a new version, and a change applies from the next query.
Table Access Manager#
Choose Table Access Manager in a table's menu to grant or deny actions on one table to users or groups. You need All on the database. Pick an Action (Select, Insert, Update, Alter, Drop or All), Allow or Deny, and move users or groups from Available to Selected. Rules inherited from the database are listed, and a deny always wins. Every add or remove is saved immediately.

Read lakehouse tables from jobs and datasets#
The tables you create here are ordinary Iceberg tables, so every other runtime reads them through a Groundzero lakehouse connection (Connections, then the Groundzero Lakehouse type). The connection's Lakehouse URL is the value copied by Copy Lakehouse URL on the Warehouses page. The same permissions, masks and row filters apply to the caller of every run.
| From | How | See |
|---|---|---|
| Spark job or notebook | spark. reads with SQL; spark. appends or overwrites |
Spark guide, Query and write Lakehouse (Iceberg) tables |
| DuckDB job or notebook | session.; read only |
DuckDB guide, Query the Groundzero Lakehouse |
| Standard dataset | A SQL query on the connection, for example SELECT . |
Standard guide, Query lakehouse tables |
In every case, write tables as database.table. To write lakehouse tables from
code, use the Spark runtime; DuckDB and Standard read only.
Backups, schedules and restore#
A backup copies a database's data files and table definitions inside the warehouse bucket. It is a safety net for mistakes that snapshots cannot undo, such as dropping a table.

Back up now. Choose Backup Database in a database's menu and enter a
Backup Name: letters, digits and underscores, 3 to 50 characters, starting
with a letter and not beginning or ending with _ or -. The message "Database
backup created successfully!" means the backup started; it runs in the
background and shows Running until it finishes with Completed or
Failed. A name that exists is refused ("Backup name <name> already exists").
Schedule backups. Expand Schedules, open a database's menu and choose Schedule Backup. Set the Backup Name, Retention (days) from 1 to 30, the start and Repeat (Hourly, Daily, Weekly, Monthly or Yearly). Each run appends a timestamp to the name. A database has one schedule; Pause Schedule, Resume Schedule and Delete Schedule are in the same menu, and deleting a schedule keeps the backups it already made.
Restore. Choose Restore Database, then the backup and a Target Database Name (letters, digits and underscores). "Database restoration started!" confirms the start; refresh the tree when it finishes.
Restoring into the original database
Restoring a backup into the database it came from replaces that database's tables with the backed-up version. Changes made after the backup are lost.
A backup whose retention has passed is removed, and restoring it fails with
"Backup <name> has expired in S3 and was removed from the catalog. Take a fresh
backup before restoring." Mark stale backups failed (in the Databases
menu) marks backups that have been running for more than 180 minutes as failed.
Audit logs#
Every statement that runs in a warehouse is written to the audit.logs table,
with the time, user, operation, status, database, table, duration and the SQL.
Only administrators can read it: expand audit, then Tables, logs and
choose Open audit logs, or query it.

SELECT timestamp, userId, operation, status, execution_time_ms, query
FROM audit.logs
WHERE status = 'FAILED'
ORDER BY timestamp DESC
LIMIT 100The audit viewer has a range (7 days by default, 30, 90 or all), a page size (20,
50 or 100), refresh, Download current audit logs page as CSV, Compact audit
logs (expires snapshots older than 30 days, keeping the last 20) and Rewrite
audit files. Click a cell to open the details drawer. New rows can appear up to
about 30 seconds after a statement finishes, and audit.logs can be read but
never changed: "Audit logs can only be queried. Modifications are not permitted."