Skip to content

Commit a6365cb

Browse files
authored
Probe system.tables instead of system.databases in devnet discovery (#62)
The public readonly ClickHouse user is granted system.tables but not system.databases, so every devnet was silently skipped and an empty experimental catalog was committed. Also fail loudly when the default database cannot be listed instead of generating an empty catalog. Claude-Session: https://claude.ai/code/session_013dYRgdZD22uUhTzhqMr5bz
1 parent 4a9aa2f commit a6365cb

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

generate-experimental.sh

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,13 @@ list_tables() {
6262
" | grep -E '^[a-zA-Z_][a-zA-Z0-9_]*$' || true
6363
}
6464

65+
# The public readonly user is granted system.tables but NOT system.databases
66+
# (system.* is revoked with a small re-grant allowlist), so probe for tables
67+
# rather than the database itself.
6568
database_exists() {
6669
local database=$1
67-
local count=$(ch_query "SELECT count() FROM system.databases WHERE name = '$database' FORMAT TabSeparated")
68-
[ "$count" = "1" ]
70+
local count=$(ch_query "SELECT count() FROM system.tables WHERE database = '$database' FORMAT TabSeparated")
71+
[ -n "$count" ] && [ "$count" -gt 0 ] 2>/dev/null
6972
}
7073

7174
# Resolve the xatu branch for a fork: config override, else release/<fork>.
@@ -100,6 +103,11 @@ log "Found $(wc -l < "$tmp_dir/devnets.jsonl" | tr -d ' ') active devnet(s)"
100103
log "Listing tables in the default database"
101104
list_tables "default" > "$tmp_dir/tables_default"
102105

106+
if [ ! -s "$tmp_dir/tables_default" ]; then
107+
log "ERROR: could not list tables in the default database — check ClickHouse credentials and grants"
108+
exit 1
109+
fi
110+
103111
# Introspect each devnet
104112
> "$tmp_dir/results.jsonl"
105113
while read -r devnet; do

0 commit comments

Comments
 (0)