Skip to content

test(cpp): cover time operator filters - #1119

Merged
ColinLeeo merged 2 commits into
apache:developfrom
ColinLeeo:colin/cpp-time-operator-tests
Nov 17, 2026
Merged

ColinLeeo merged 2 commits into
apache:developfrom
ColinLeeo:colin/cpp-time-operator-tests

Conversation

@ColinLeeo

Copy link
Copy Markdown
Contributor

Summary

Add unit coverage for the time filter operators in cpp/src/reader/filter/time_operator.cc, which sat at 48% line coverage with 33 functions never executed.

cpp/test/reader/filter/time_operator_test.cc covers, for TimeBetween, TimeIn, TimeEq, TimeNotEq, TimeGt, TimeGtEq, TimeLt and TimeLtEq:

  • statistic-level pruning (satisfy(Statistic*))
  • row-level predicates over both int64_t and String values
  • satisfy_start_end_time / contain_start_end_time
  • get_time_ranges() including INT64_MIN/INT64_MAX edges and inverted ranges
  • satisfy_batch_time via 6/5/0 element inputs, exercising both the vector width (NEON pairs / SSE-AVX2 quads) and the scalar tail
  • is_unbounded_time_filter / is_contiguous_time_filter contracts

The tests exposed a precedence bug in TimeBetween::satisfy(int64_t, int64_t/String): ^ binds tighter than &&, so NOT BETWEEN rejected timestamps below the lower bound instead of accepting everything outside the interval (contradicting satisfy(Statistic*), satisfy_start_end_time() and the documented inverted-range behavior). The range test is now parenthesized.

Coverage of time_operator.cc: 48.2% -> 96.0% lines (315/328), 71/71 functions.

Test plan

  • ./mvnw -B clean verify -P with-java,with-python -Denable.lzma2=ON (Java, C++, Python; 1652 C++ tests passed)
  • ./mvnw -B clean verify -P with-cpp -Denable.asan=ON -Dbuild.type=RelWithDebInfo -Denable.lzma2=ON (1653 tests, 0 failed; macOS run used the Xcode 26.6 toolchain with ASAN_OPTIONS=detect_container_overflow=0 for the uninstrumented ANTLR runtime)
  • ./mvnw spotless:check -P with-java,with-python

Add unit tests for TimeBetween, TimeIn, TimeEq, TimeNotEq, TimeGt,
TimeGtEq, TimeLt and TimeLtEq: statistic pruning, row-level predicates,
range introspection and the SIMD/scalar batch paths.

The tests exposed a precedence bug in TimeBetween::satisfy(): `^` binds
tighter than `&&`, so NOT BETWEEN rejected timestamps below the lower
bound instead of accepting everything outside the interval. Parenthesize
the range test to match satisfy(Statistic*) and
satisfy_start_end_time().

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The tests preserve incorrect TimeNotEq boundary pruning that causes chunk readers to drop valid rows; only the singleton range [3, 3] should be rejected for time != 3.

1 open issue
What changed in this PR

This PR expands coverage of C++ time-filter operators and fixes a NOT BETWEEN precedence error found by the new tests.

Changes:

  • Add tests for eight operators covering pruning, row predicates, time ranges, boundary cases, and batch filtering.
  • Parenthesize the range condition in both TimeBetween::satisfy overloads so negation applies to the whole interval.
File Description
cpp/​test/​reader/​filter/​time_operator_test.cc Adds time-filter semantics and boundary tests.
cpp/​src/​reader/​filter/​time_operator.cc Fixes NOT BETWEEN evaluation for numeric and string row predicates.

Review effort: Balanced

TimeNotEq::satisfy_start_end_time() returned false whenever the excluded
value matched either end of the block range. Chunk readers skip a block
when it returns false, so `time != 3` dropped every row of a block
starting or ending at 3.

Only a single-point range can be fully excluded. Expect true for ranges
that straddle the excluded value and add an end-to-end query regression
that reads 299 of 300 rows.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues are recorded for the time-filter predicate fixes and expanded test coverage.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

@ColinLeeo
ColinLeeo merged commit ee76c9a into apache:develop Nov 17, 2026
49 checks passed
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