List, search, validate, or query semantic sources.
Interact with your project's semantic layer. Semantic sources are YAML
definitions that describe tables, columns, measures, joins, segments, and grain:
the vocabulary agents use to generate correct SQL.
# List all semantic sourcesktx sl
# List sources for a specific connectionktx sl --connection-id my-warehouse# List sources as JSONktx sl --json# Search sources as JSONktx sl "revenue"--json# Print the YAML for a source name that is unique across connectionsktx sl read orders
# Print the YAML for a source name that exists in multiple connectionsktx sl --connection-id my-warehouse read orders
# Validate a source name that is unique across connectionsktx sl validate orders
# Validate a source name that exists in multiple connectionsktx sl validate orders --connection-id my-warehouse# Compile a query and view the generated SQLktx sl query \
--connection-id my-warehouse \
--measure orders.total_revenue \
--dimension orders.created_date \
--format sql
# Execute a query with filtersktx sl query \
--connection-id my-warehouse \
--measure orders.total_revenue \
--dimension orders.status \
--filter"orders.created_date >= '2024-01-01'" \
--execute \
--max-rows100# Query with ordering and limitktx sl query \
--connection-id my-warehouse \
--measure orders.total_revenue \
--dimension customers.country \
--order-by total_revenue:desc \
--limit10 \
--execute# Execute and cap the result setktx sl query \
--connection-id my-warehouse \
--measure orders.count \
--dimension orders.created_date \
--execute \
--max-rows1000# Compile or execute without prompting for runtime installationktx sl query \
--connection-id my-warehouse \
--measure orders.count \
--execute \
--yes# Execute a query from a JSON filektx sl query \
--connection-id my-warehouse \
--query-file query.json \
--execute \
--max-rows100
Bare ktx sl (list) and ktx sl <query> (search) return human-readable
output by default. Use --json when an agent needs structured output. Use
--format sql on query to inspect generated SQL before execution, or leave
--format json for the compiled query and optional rows. Pretty search output
shows #1, #2, and later rank badges for the displayed results. Plain and
JSON output keep the raw score value, which is a ranking score rather than a
percentage.
ktx sl read <sourceName> prints the source YAML directly to stdout when the
source name is unique across connections. If the name exists in multiple
connections, rerun the command with --connection-id <id>. The command does
not wrap output in pretty, plain, or JSON formatting, so it can be piped to
other tools.
{"sql":"SELECT orders.status, SUM(orders.total_amount) AS total_revenue FROM public.orders GROUP BY orders.status","rows":[{"orders.status":"completed","total_revenue":125000}]}