introspect: -exclude config to skip transient tables/dictionaries#79
Merged
Conversation
Production dumps were carrying transient objects — ClickHouse atomic-replace temporaries (_tmp_replace_*), migration/DAG scratch tables (tmp_*), backups, staging, backfills — which pollute review and, because their DDL often can't be parsed, abort a node dump unless -allow-raw is set. Add a tool-level exclude config: an HCL file with glob patterns, matched against both the bare object name and <db>.<name>. introspect and dump-cluster gain -exclude <file>; matching objects are skipped before their DDL is parsed, so they neither land in the dump nor break introspection (and aren't captured as raw either). LoadExcludeConfig/ExcludeMatcher live in the hcl package; IntrospectWithExclude wraps Introspect (back-compatible). A starter config is in examples/exclude.hcl.
Skipped objects were logged at debug (invisible by default). Log each at info with the object name and the matching pattern, so a dump run shows exactly what was dropped. Add ExcludeMatcher.Match returning the matched pattern (Matches kept as a bool wrapper).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
The committed
clickhouse-schema/dumps were carrying transient objects — ClickHouse atomic-replace temporaries (_tmp_replace_*), migration/DAG scratch tables (tmp_dag_*,tmp_person_0007,infi_clickhouse_orm_migrations_tmp), backups (*_backup,*_backup_test), staging (*_staging), backfills (*_temp_backfill). They pollute review and, because their DDL often can't be parsed, a single one aborts a node dump unless-allow-rawis set.What
A tool-level exclude config: an HCL file of glob patterns; matching objects are skipped before their DDL is parsed.
internal/loader/hcl/exclude.go—ExcludeMatcher(globs viafilepath.Match, matched against both the barenameand<db>.<name>, nil-safe) +LoadExcludeConfigdecodingexclude { patterns = [...] }, validated at load.IntrospectWithExclude(...)wrapsIntrospect(which stays nil-exclude, back-compatible);processIntrospectRowsOptskips matching rows beforeintrospectOneObject, so an excluded object's unparseable DDL never aborts the dump and it isn't captured as raw either.introspectanddump-clustergain-exclude <file>, threaded throughintrospectSchema/dumpNode.examples/exclude.hcl— a starter config covering the transient patterns observed in production dumps.Testing
exclude_test.go— matcher (bare + qualified globs, nil-safe); config load (parse / empty / invalid glob); and the committedexamples/exclude.hclmatched against the real transient names from the dumps (_tmp_replace_5c4a29…,tmp_dag_team_*,person_distinct_id_backup,data_temp,…_temp_backfill,…_staging) while keeping genuine objects (events,sharded_query_log_archive,person).introspect_test.go— an excluded object with unparseable DDL is skipped in strict mode (no error, not captured as raw) — proves skip-before-parse.go vet, golangci-lint (0 issues), gofmt green. No live ClickHouse smoke (the row path is unit-covered with fake rows).Notes
*covers hex-suffixed temp names.*_old/*_neware left commented in the example since some are intentionally kept (e.g.query_log_archive_old).🤖 Generated with Claude Code