Move $_internalValidateArrayness insertion to a Rule-Based Rewriter (RBR) rule

    • Type: Improvement
    • Resolution: Unresolved
    • Priority: Minor - P4
    • None
    • Affects Version/s: None
    • Component/s: None
    • Query Optimization
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      The insertArraynessValidationStages() and removeArraynessValidationStages() functions are currently implemented as bespoke logic in optimize.cpp. This should be refactored into a proper RBR rule in a dedicated graph_validation_rules.cpp file to keep optimize.cpp clean and use the standard optimization framework.

      Background

      Currently, optimizePipeline() in optimize.cpp has special-cased code that:

      • Removes previously inserted $_internalValidateArrayness stages (before rewrites run)
      • Re-inserts them after all other rewrites complete

      This is gated by the internalEnableDependencyGraphValidation test-only knob. The goal is to move this logic into the RBR framework so that optimize.cpp doesn't need direct knowledge of validation stage insertion.

      Proposed Approach

      The Tags::Testing phase currently runs first (before Reordering and InPlace), but validation stage insertion needs to run last (after all other rewrites have finalized the pipeline shape). Two options:

      Move Tags::Testing to run after Reordering and InPlace — The only two existing Testing rules (MATCH_ARRAY_TYPE_PREDICATE_ALWAYS_FALSE and DUMMY_MATCH_CHECK_ARRAYNESS) should be evaluated to confirm they don't depend on running first. If they're order-independent (or also benefit from running last), reorder optimizePipeline() to call Testing after the other phases, then add the new validation rule there.

      Introduce a new tag (e.g., Tags::PostValidation) — If the existing Testing rules need to run first, add a separate tag/phase that runs after all other rewrites. The new validation insertion rule would be registered under this tag.

            Assignee:
            Unassigned
            Reporter:
            Matt Olma
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: