Ray's Knowledge Base
Unlock

duql on a View must stay lazy: plan in duql(), run only at execute

PreferenceVerified 29 Sep 2026Holds project: dftracer-utils
Preference. A rule, why it holds, and how to apply it.

Rule#

View::duql and explain_duql only build plans; nothing reads a record until a terminal executes. Work that must precede the scan (lookup sides, key sets) is a plan step that runs at execution, like a hash join's build side, not inside duql().

Why#

The user rejected both an eager design (sides run in duql()) and a deferred source that rebuilt the plan at collect, because the second loses the scan plan (no trace builders, no pruning). They want planning done properly and lazily, and speed wherever possible.

How to apply#

Attach a shared build step to the ViewPlan that effective_query runs once per execution; keep side results out of plan building; prove laziness with a test that sets a cap to fail and checks duql()/explain succeed while collect() fails.

Also found by searching

  • View.duql() reads records before collect is called, lookup side runs eagerly
  • calling duql on a view should only build the plan but it already scans data
  • where should pre-scan work like lookup key sets run in a duql View plan
  • lazy query planning vs eager execution, build step in ViewPlan effective_query
  • View.duql() is slow because lookup side executes immediately at plan time
  • how should duql lookup sides and key sets be built so planning stays lazy?
  • how do I test that duql() and explain don't read any records until collect?
  • eager sides in duql(), deferred source loses pruning and trace builders, ViewPlan build step