Skip to content

[C++] Share expressions across table and tree queries - #1184

Open
ColinLeeo wants to merge 10 commits into
developfrom
refactor/cpp-shared-table-predicate
Open

ColinLeeo wants to merge 10 commits into
developfrom
refactor/cpp-shared-table-predicate

Conversation

@ColinLeeo

Copy link
Copy Markdown
Contributor

Motivation

The C++ reader can bind a named condition when it prepares a query. Callers can build the condition before opening a file and reuse it across queries. This PR brings the C++ work from #1178 onto an Apache-hosted branch for CI and simplifies how a table scan receives its TAG filter. The native reader work originally came from #1169.

Query behavior

  • Table and tree queries share storage::Expression for comparisons, ranges, null tests and logical operators. Each query binds its own copy of the named operands and typed literals. Callers can release the input expression after query preparation.
  • Table queries accept separate, optional const Expression* arguments for tag_filter and field_filter. TAG operands bind to device ID segments. FIELD operands bind to typed columns for row evaluation and page pruning. Offset and limit count rows that pass the filters.
  • The table executor passes one device filter to DeviceTaskIterator. A query prepared from an expression owns its bound filter. The existing indexed TAG overload continues to borrow the caller's Filter* for the lifetime of the scan.
  • Tree queries resolve full paths and unambiguous short names. They read any additional series needed by the predicate and return only the requested columns. NOT(a = x) continues to match a missing TAG and exclude a null FIELD or tree value.
  • The CLI and C wrapper build named expressions directly. The C++ expression factories replace TagFilterBuilder and the factories on AlignedFieldFilter. The C signatures are unchanged. A successful C TAG logical composition takes ownership of its operands. A null operand or aliased binary operands leave ownership with the caller. Allocation failure during composition terminates the process.

Verification

  • macOS arm64, LZMA2 enabled. All 1,988 enabled C++ Release tests and 1,989 enabled RelWithDebInfo ASan/UBSan tests passed.
  • The C++ tests cover schema rebinding, sparse tree series, predicate-only columns, pagination and the lifetime of both caller-owned indexed TAG filters and named expressions.
  • Linux arm64. Verified sanitizer instrumentation in libtsfile and all five Cython extensions. All 15 Python ownership tests passed under ASan/LSan.
  • Go tests, go vet and the Go race suite passed against the C++ library from this revision. C++ Spotless and git diff --check passed.
  • The macOS Python suite passed with 706 tests passing and 16 skipped.

@codecov-commenter

codecov-commenter commented Dec 3, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 83.88158% with 98 lines in your changes missing coverage. Please review.
✅ Project coverage is 69.55%. Comparing base (f7a60f1) to head (13de553).
⚠️ Report is 3 commits behind head on develop.

Files with missing lines Patch % Lines
cpp/src/reader/filter/aligned_field_filter.cc 82.27% 14 Missing and 14 partials ⚠️
cpp/src/reader/filter/tag_filter.cc 78.12% 18 Missing and 3 partials ⚠️
cpp/src/reader/qds_without_timegenerator.cc 78.26% 5 Missing and 10 partials ⚠️
cpp/src/cwrapper/tsfile_cwrapper.cc 67.50% 10 Missing and 3 partials ⚠️
cpp/src/reader/filter/bind_expression.cc 90.80% 2 Missing and 6 partials ⚠️
cpp/src/reader/expression.cc 94.91% 0 Missing and 3 partials ⚠️
cpp/src/reader/table_query_executor.cc 89.65% 1 Missing and 2 partials ⚠️
cpp/src/reader/tsfile_executor.cc 86.36% 2 Missing and 1 partial ⚠️
cpp/src/reader/tsfile_reader.cc 84.21% 0 Missing and 3 partials ⚠️
cpp/src/reader/aligned_chunk_reader.cc 0.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #1184      +/-   ##
===========================================
+ Coverage    69.45%   69.55%   +0.09%     
===========================================
  Files          798      799       +1     
  Lines        59106    59021      -85     
  Branches      9630     9619      -11     
===========================================
- Hits         41055    41052       -3     
+ Misses       16266    16180      -86     
- Partials      1785     1789       +4     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants