Skip to content

fix(query/planner): apply :pushdown-preds in temporal standalone pattern-scan#827

Merged
whilo merged 1 commit into
mainfrom
fix/temporal-pattern-scan-pushdown
May 13, 2026
Merged

fix(query/planner): apply :pushdown-preds in temporal standalone pattern-scan#827
whilo merged 1 commit into
mainfrom
fix/temporal-pattern-scan-pushdown

Conversation

@whilo
Copy link
Copy Markdown
Member

@whilo whilo commented May 13, 2026

Summary

  • Mirror the entity-group temporal branch's :pushdown-preds post-filter onto the standalone :pattern-scan branch in execute-plan. Without it, the planner consumes the clause-level predicate (:consumed-preds) and lookup-batch-search silently drops it on temporal DBs.
  • Surface symptom: any HistoricalDB / AsOfDB / SinceDB query of the shape [?tx :db/txInstant ?inst] [(<= ?from ?inst)] that gets forced through the Relation path (non-empty :rels in the context — e.g. a [?m ...] collection IN binding) returned all rows instead of the bounded range.
  • Added a TDD-style regression test test-temporal-standalone-pattern-scan-pushdown-pred in query_planner_temporal_test.clj that fails on main and passes with this fix. The shape forces execute-plan (not execute-plan-direct) so the bug actually manifests.

Test plan

  • DATAHIKE_QUERY_PLANNER=true clj -M:test against the new namespace alone (4 tests, 11 assertions, 0 failures).
  • Same suite plus query-test / query-rules-test / query-planner-test / query-fns-test — 61 tests / 355 assertions, 0 failures.
  • Same suite under legacy mode — 61 tests / 355 assertions, 0 failures.
  • Pre-fix red: temporarily stashing the execute.cljc change makes the new test fail with not (= #{e2 e3} #{e1 e2 e3 + non-event txs}).

Follow-up to #826 / #825.

…ern-scan

The entity-group temporal branch in execute-plan re-applies :pushdown-preds
as a post-filter after lookup-batch-search (since the planner consumes the
clause-level predicate). The sibling standalone :pattern-scan branch had
no such re-application and silently dropped the predicate on
HistoricalDB / AsOfDB / SinceDB queries with a single data pattern.

Surface symptom: temporal range queries shaped like
  [?tx :db/txInstant ?inst] [(<= ?from ?inst)]
over-returned when forced through the Relation path (any context with
prior :rels — e.g. a `[?m ...]` collection binding).

Mirror the entity-group branch's filter-by-pred reduction on
(:pushdown-preds op) directly after lookup-batch-search.
@whilo whilo merged commit 015fb2a into main May 13, 2026
12 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.

1 participant