Subscription: support table-model column-filter for topics
Purpose
Add a column-filter topic attribute for table-model subscriptions so a topic can
restrict which columns consumers receive, based on column metadata, applied uniformly
across historical, real-time pipe, and IoTConsensus WAL paths.
What
- New optional topic attribute
column-filter(table-model only); unset ==true. Restricted boolean predicate over column-metadata fields aligned withinformation_schema.columns:database,table_name,column_name,datatype,category. Supports=/!=,IN,LIKE,REGEXP,IS [NOT] NULL,AND/OR/NOT. - Independent
ColumnFilter.g4grammar (decoupled from the query grammar) producing the reused relational AST nodes; a whitelist validator rejects unsupported syntax/fields. - Resolved to a per-(database, table) column set at CREATE/ALTER (and on re-bind) against the current schema, cached per topic on the DataNode and used for O(1) runtime pruning. TAG columns are retained; ATTRIBUTE columns are not transmittable.
- Applied in all paths: IoTConsensus WAL converter, pipe tablet batch, and TsFile reseal (prune at tablet granularity; raw TsFile passthrough kept only when the filter is trivial).
timeSelectedpropagated as an optional, backward-compatible per-table flag on the poll response (defaults to exposing time for old consumers).- ALTER TOPIC hot-refreshes the cached matcher (no converter rebuild; in-flight not reprocessed).
- Removed the legacy consensus-only
columnregex attribute.
Tests
- Unit: parser/validator/evaluator, binder, tablet pruner, topic config, poll response, record handler.
- Integration (table model): live/snapshot, record & TsFile, multi-consumer-group, historical+ realtime consistency, ALTER rebind, empty-result progress, snapshot semantics, custom time column, altered data type, tree-view source-column binding, attribute drop, 1C3D cluster ALTER-after-owner-transfer, DataNode restart re-snapshot, invalid-expression rejection, permission.
Notes
- The column-filter bound set is a non-persisted snapshot: stable between binds, re-derived from the current schema on CREATE/ALTER/restart/owner-transfer; not frozen for the topic lifetime.
- Tree-model topics are unaffected.
Codecov Report
:x: Patch coverage is 69.09227% with 412 lines in your changes missing coverage. Please review.
:white_check_mark: Project coverage is 42.19%. Comparing base (71cb6e6) to head (b7188f2).
:warning: Report is 8 commits behind head on master.
Additional details and impacted files
@@ Coverage Diff @@
## master #17936 +/- ##
============================================
+ Coverage 41.81% 42.19% +0.38%
Complexity 318 318
============================================
Files 5296 5306 +10
Lines 373384 375004 +1620
Branches 48210 48507 +297
============================================
+ Hits 156134 158238 +2104
+ Misses 217250 216766 -484
:umbrella: View full report in Codecov by Harness.
:loudspeaker: Have feedback on the report? Share it here.
:rocket: New features to boost your workflow:
- :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
Findings
-
Valid REGEXP/string literals are rejected before parsing
ColumnFilterParser.java#L139-L153
validateUnsupportedSyntax scans the raw expression and rejects <, >, and + before tokenization, but it does not
skip quoted string literals. As a result, valid filters such as column_name REGEXP "s[0-9]+", column_name = "a+b", or column_name LIKE "a>%" fail at topic creation time. This should either ignore characters inside quoted strings
or let the grammar/parser reject unsupported operators. -
A time-only filter drops all rows for tagless tables
ColumnFilterBinder.java#L67-L75, TabletColumnPruner.java#L78-L94
A filter like column_name = "time" only sets timeSelected; it does not add any selected physical tablet column. For a table without TAG columns, TabletColumnPruner then sees an empty selected column set and returns null, so
consumers receive no rows. IoTDB table model allows tagless tables such as CREATE TABLE t (s1 INT64 FIELD), so this is a valid case. The implementation should either support time-only tablets or reject this unsupported shape during bind/validation.
Quality Gate failed
Failed conditions
B Reliability Rating on New Code (required ≥ A)
See analysis details on SonarQube Cloud
💡 Need a hand with PR review? Try Gitar by Sonar!