kJQ filters
Overview
JQ is a popular, practical language described as 'like sed for JSON data'.
Data inspect supports JQ-like filters on the rows of Iceberg tables. We call this kJQ, and it is the same language that Kpow uses to filter Kafka topics.
A kJQ filter is evaluated against every row, and only the rows where the filter is true are returned.
.status == "overdue" and (.amount | to-double > 1000)
Filtering table rows
Filters are evaluated against one row at a time, using the table's columns.
- Reference a column by name with a leading dot:
.amount. Quote names that contain spaces or special characters:."unit price". - Reach a field inside a
structcolumn with further dots:.address.city. - Index a
listcolumn with square brackets:.items[0],.items[-1]or.items[1:3]. - You can filter on columns that are not part of your projection.
Differences from Kpow
- Filters can only reference the table's own columns. The Kafka record fields
.key,.value,.headers,.partition,.offsetand.timestampdo not exist, and there are no SerDes. decimal,uuidand temporal columns are strings when filtered, as they are in the results. Convert them before comparing, for example.amount | to-double > 1000,.id | to-uuid == #uuid "..."or.created_at | from-date > #dt "2026-01-01".- A filter that references a column that does not exist matches no rows and does not report an error. If you get no results, check the column names.
- If a filter cannot be evaluated for a row, for example comparing a
nullvalue with a number, that row does not match. - A filter that cannot be parsed fails the search with a
kJQ error.
Examples
Rows where age is greater than 30:
.age > 30
Rows where name is ann, or age is 25:
.name == "ann" or .age == 25
Rows where the city field of the address struct is Melbourne:
.address.city == "Melbourne"
Rows where the decimal amount is at least 50:
.amount | to-double >= 50.00
Rows where customer starts with Acme:
.customer | startswith("Acme")
Rows where the tags list contains priority:
.tags | join(",") | contains("priority")
Rows with at least two line items and a large total:
(.items | length >= 2) and (.amount | to-double > 1000)
Rows where description is not empty. Negate a condition with | not:
.description | is-empty | not
Documentation
Follow this link to view the kJQ documentation for the full list of operators, transforms and functions.
The manual is written for Kafka records, so the parts that refer to record keys, values, headers, partitions or offsets do not apply to Iceberg tables.