Skip to content

Inspect schema

Task: Discover the tables and columns available in a data directory before writing queries.

Run a deliberately limited query to confirm schema loading and data accessibility:

Terminal window
cqlite \
--schema test-data/schemas/basic-types.cql \
--data-dir test-data/datasets/sstables \
--query "SELECT id, name FROM test_basic.simple_table LIMIT 1" \
--out json

Expected (confirms schema loaded and data is accessible):

[
{
"id": "0023ece7-7c4e-4705-9068-d1a59ec5fe19",
"name": "Debbie Soto"
}
]

If this returns an empty array or an error, see Failure modes below.

List every Data.db file in the dataset root to enumerate keyspaces and tables:

Terminal window
find test-data/datasets/sstables -name "*-Data.db" \
| sed 's|.*/\([^/]*\)/[^/]*-Data.db|\1|' \
| sort -u

Expected output (test datasets):

collection_clustering_table-6bf78680a25111f0a3fef1a551383fb9
collection_table-6b8c8fb0a25111f0a3fef1a551383fb9
sensor_data-...
simple_table-...
...

Each SSTable directory is named <table_name>-<uuid_hash>. The prefix before the first - is the table name. Keyspace directories contain one or more such table directories.

Terminal window
ls -1 test-data/datasets/sstables/

Expected output:

system
system_auth
system_distributed
system_schema
system_traces
test_basic
test_collections
test_timeseries
test_wide_rows

The system_* keyspaces contain Cassandra internal metadata. The test_* keyspaces contain application data.

Terminal window
grep -E "^(CREATE TABLE|USE )" test-data/schemas/basic-types.cql

Expected output (enumerates keyspace and table names):

USE test_basic;
CREATE TABLE IF NOT EXISTS simple_table (
CREATE TABLE IF NOT EXISTS multi_pk_table (
CREATE TABLE IF NOT EXISTS typed_table (
...
Terminal window
awk '/CREATE TABLE IF NOT EXISTS simple_table/,/^\)/' \
test-data/schemas/basic-types.cql

Expected output (column definitions for simple_table):

CREATE TABLE IF NOT EXISTS simple_table (
id UUID PRIMARY KEY,
name TEXT,
age INT,
salary BIGINT,
...
)
Schema fileKeyspaceTables
basic-types.cqltest_basicsimple_table, multi_pk_table, typed_table, and others
collections.cqltest_collectionscollection_table, nested_collections_table, and others
time-series.cqltest_timeseriessensor_data, events_table, and others
wide-rows.cqltest_wide_rowswide_partition_table, many_columns_table, and others
SymptomCauseFix
Zero rows returnedData.db file missing (only JSONL goldens present)Run bash test-data/scripts/fetch-datasets.sh
Schema not found errorWrong table name in query, or wrong --schema fileCheck schema file for exact table name
WARN about BTI format on stderrda- prefixed SSTables in the directoryBTI format not supported; only nb- SSTables are readable
Empty ls outputDataset not fetchedRun bash test-data/scripts/fetch-datasets.sh