Skip to content

feat(sql-parser): Support half-open time >= A AND time < B in SQL WHERE clause for benchmark parity #409

Merged
milindsrivastava1997 merged 2 commits into
mainfrom
408-feat-sql-parser-support-left-close-and-right-open
Jun 22, 2026
Merged

feat(sql-parser): Support half-open time >= A AND time < B in SQL WHERE clause for benchmark parity #409
milindsrivastava1997 merged 2 commits into
mainfrom
408-feat-sql-parser-support-left-close-and-right-open

Conversation

@akanksha-akkihal

Copy link
Copy Markdown
Contributor

Code Changes

1. sqlpattern_parser.rs (core logic)

  • Added a new parsing path for time >= … AND time < … in addition to the existing BETWEEN support.
  • Maps to the existing TimeInfo { start, duration } model — no changes to TimeInfo, engine timestamp math, store logic, or pattern matching.
  • Enforces strict operator semantics:
    • Accepted: >= (lower bound) + < (upper bound)
    • Rejected: > / <= combinations (treated as unmatched queries)
  • Supports flexible syntax:
    • Comparisons in either order
    • Time column on either side of the comparison (e.g., A <= time AND B > time)
  • Hardened get_timestamp_from_between_highlow to return None on unrecognized time expressions instead of panicking, preventing engine/planner crashes on malformed input.

2. Tests

File What was added
sqlparser_test.rs 10 parser tests covering equivalence with BETWEEN, reversed order, column-on-right forms, NOW()-relative expressions, matcher classification, template matching, and rejection cases
query_equivalence_tests.rs 2 engine tests validating half-open ≡ BETWEEN execution context and rejection of > / <= combinations
sql_integration.rs 2 planner tests verifying half-open quantile plans match BETWEEN plans and that > / <= combinations return SqlParse errors

What Did Not Change

  • Engine window selection / store containment logic
  • Planner config generation logic (continues to use the shared parser)
  • Existing BETWEEN behavior

Behavior Matrix

WHERE clause ASAP ClickHouse baseline
time BETWEEN A AND B ✅ Unchanged Inclusive-inclusive (>= A AND <= B) — may differ from ASAP
time >= A AND time < B ✅ New Half-open [A, B) — aligned with ASAP
time > A AND time <= B ❌ Unmatched

@milindsrivastava1997
milindsrivastava1997 merged commit c77cf60 into main Jun 22, 2026
11 checks passed
@milindsrivastava1997
milindsrivastava1997 deleted the 408-feat-sql-parser-support-left-close-and-right-open branch June 22, 2026 15:06
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.

feat(sql-parser): Support half-open time >= A AND time < B in SQL WHERE clause for benchmark parity

2 participants