You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@datafusion.apache.org by "zhuqi-lucas (via GitHub)" <gi...@apache.org> on 2026/09/24 07:05:09 UTC

[PR] feat: extract enforcement into a PhysicalAnalyzerRule phase (prereq for #25572) [datafusion]

zhuqi-lucas opened a new pull request, #25688:
URL: https://github.com/apache/datafusion/pull/25688

   ## Which issue does this PR close?
   
   - Prerequisite for #25572 (the phase split, without the convergence loop yet).
   - Related to #25355.
   
   ## Rationale for this change
   
   The physical optimizer runs a single hand-ordered rule list. Some of those passes are not optimizations, they are *enforcers* of invariants: `EnsureRequirements` inserts the repartitioning and sorting needed to satisfy the distribution and ordering requirements every operator declares. The logical layer already separates these two kinds of passes (`AnalyzerRule` makes a plan valid, `OptimizerRule` makes it faster); the physical layer does not.
   
   Giving enforcement its own phase is the prerequisite for #25572: once the optimizer rules no longer include enforcement, they can be re-run to a fixed point without re-running the expensive enforcement passes each time.
   
   ## What changes are included in this PR?
   
   - A new `PhysicalAnalyzerRule` trait (mirrors the logical `AnalyzerRule`) and a `PhysicalAnalyzer` rule list, plumbed through `Session` / `SessionState` / `SessionStateBuilder` symmetrically with the physical optimizer rules.
   - `EnsureRequirements` implements `PhysicalAnalyzerRule` and is the sole default analyzer. It is **also** kept as a `PhysicalOptimizerRule`, so any custom rule list that still registers it keeps working.
   - The planner runs the analyzer phase and then the optimizer phase.
   
   ### A note on ordering (why not a literal "all analyzers, then all optimizers")
   
   The sketch in #25585 ran all analyzers before all optimizers. Implemented literally that breaks the default pipeline: `EnsureRequirements` would run before `JoinSelection`, which decides broadcast (single-partition) vs partitioned joins and therefore changes the required input distribution. Enforcing first repartitions the inputs of a join that `JoinSelection` then turns into a single-partition broadcast join, and `SanityCheckPlan` rejects the result (`does not satisfy distribution requirements: SinglePartition`). This matches the existing per-rule comments in `optimizer.rs` ("JoinSelection ... should run before EnsureRequirements").
   
   So the analyzer phase runs at `EnsureRequirements`' historical position: after the optimizer passes that establish requirements and before those that assume them (right before `CombinePartialFinalAggregate` in the default list). The default pipeline order, and every resulting plan, is therefore unchanged. Rearranging the list into cleaner phases is left to the follow-up in #25572.
   
   ## Are these changes tested?
   
   Yes:
   - Unit tests that the default analyzer list is `[EnsureRequirements]` and that it is no longer in the default optimizer list.
   - A planner test that a custom `PhysicalAnalyzerRule` registered via the builder runs during planning, and that enforcement still produces a valid plan.
   - The full `sqllogictest` suite passes with no plan changes (zero golden churn), confirming the default order is preserved.
   
   ## Are there any user-facing changes?
   
   - New public API: `PhysicalAnalyzerRule`, `PhysicalAnalyzer`, `Session::physical_analyzers`, `SessionState::physical_analyzers` / `add_physical_analyzer_rule`, and `SessionStateBuilder::with_physical_analyzer_rule(s)`.
   - `DefaultPhysicalPlanner::optimize_physical_plan`'s observer callback now receives the rule name (`&str`) instead of `&dyn PhysicalOptimizerRule`, so analyzer passes can be surfaced too (for example in `EXPLAIN VERBOSE`).
   - Migration note: a custom `Session` that overrides `physical_optimizers()` should also override `physical_analyzers()` (for example by delegating to `SessionState`), otherwise enforcement no longer runs for that session.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] feat: run physical requirement enforcement first, as a PhysicalAnalyzer phase [datafusion]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #25688:
URL: https://github.com/apache/datafusion/pull/25688#issuecomment-5934247561

   <!-- semver-check-comment -->
   Thank you for opening this pull request!
   
   Reviewer note: [cargo-semver-checks](https://github.com/obi1kenobi/cargo-semver-checks) reported the current version number is not SemVer-compatible with the changes in this pull request (compared against the base branch).
   
   <details>
   <summary>Details</summary>
   
   ```
        Cloning apache/main
       Building datafusion v55.1.0 (current)
          Built [  65.443s] (current)
        Parsing datafusion v55.1.0 (current)
         Parsed [   0.036s] (current)
       Building datafusion v55.1.0 (baseline)
          Built [  65.071s] (baseline)
        Parsing datafusion v55.1.0 (baseline)
         Parsed [   0.039s] (baseline)
       Checking datafusion v55.1.0 -> v55.1.0 (no change; assume patch)
        Checked [   0.624s] 223 checks: 223 pass, 31 skip
        Summary no semver update required
       Finished [ 133.186s] datafusion
       Building datafusion-ffi v55.1.0 (current)
          Built [  60.305s] (current)
        Parsing datafusion-ffi v55.1.0 (current)
         Parsed [   0.066s] (current)
       Building datafusion-ffi v55.1.0 (baseline)
          Built [  60.045s] (baseline)
        Parsing datafusion-ffi v55.1.0 (baseline)
         Parsed [   0.065s] (baseline)
       Checking datafusion-ffi v55.1.0 -> v55.1.0 (no change; assume patch)
        Checked [   0.276s] 223 checks: 223 pass, 31 skip
        Summary no semver update required
       Finished [ 122.307s] datafusion-ffi
       Building datafusion-physical-optimizer v55.1.0 (current)
          Built [  45.766s] (current)
        Parsing datafusion-physical-optimizer v55.1.0 (current)
         Parsed [   0.024s] (current)
       Building datafusion-physical-optimizer v55.1.0 (baseline)
          Built [  45.217s] (baseline)
        Parsing datafusion-physical-optimizer v55.1.0 (baseline)
         Parsed [   0.023s] (baseline)
       Checking datafusion-physical-optimizer v55.1.0 -> v55.1.0 (no change; assume patch)
        Checked [   0.116s] 223 checks: 222 pass, 1 fail, 0 warn, 31 skip
   
   --- failure constructible_struct_adds_private_field: struct no longer constructible due to new private field ---
   
   Description:
   A struct has a new non-public field that causes downstream code to be unable to construct it with a struct expression, including functional-update syntax.
           ref: https://doc.rust-lang.org/reference/expressions/struct-expr.html
          impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.50.0/src/lints/constructible_struct_adds_private_field.ron
   
   Failed in:
     field JoinSelection.phase in /home/runner/work/datafusion/datafusion/datafusion/physical-optimizer/src/join_selection.rs:87
   
        Summary semver requires new major version: 1 major and 0 minor checks failed
       Finished [  92.335s] datafusion-physical-optimizer
       Building datafusion-physical-plan v55.1.0 (current)
          Built [  42.078s] (current)
        Parsing datafusion-physical-plan v55.1.0 (current)
         Parsed [   0.178s] (current)
       Building datafusion-physical-plan v55.1.0 (baseline)
          Built [  42.694s] (baseline)
        Parsing datafusion-physical-plan v55.1.0 (baseline)
         Parsed [   0.178s] (baseline)
       Checking datafusion-physical-plan v55.1.0 -> v55.1.0 (no change; assume patch)
        Checked [   0.675s] 223 checks: 223 pass, 31 skip
        Summary no semver update required
       Finished [  86.980s] datafusion-physical-plan
       Building datafusion-proto v55.1.0 (current)
          Built [  61.328s] (current)
        Parsing datafusion-proto v55.1.0 (current)
         Parsed [   0.018s] (current)
       Building datafusion-proto v55.1.0 (baseline)
          Built [  60.123s] (baseline)
        Parsing datafusion-proto v55.1.0 (baseline)
         Parsed [   0.019s] (baseline)
       Checking datafusion-proto v55.1.0 -> v55.1.0 (no change; assume patch)
        Checked [   0.118s] 223 checks: 223 pass, 31 skip
        Summary no semver update required
       Finished [ 122.943s] datafusion-proto
       Building datafusion-session v55.1.0 (current)
          Built [  42.567s] (current)
        Parsing datafusion-session v55.1.0 (current)
         Parsed [   0.011s] (current)
       Building datafusion-session v55.1.0 (baseline)
          Built [  43.892s] (baseline)
        Parsing datafusion-session v55.1.0 (baseline)
         Parsed [   0.012s] (baseline)
       Checking datafusion-session v55.1.0 -> v55.1.0 (no change; assume patch)
        Checked [   0.190s] 223 checks: 223 pass, 31 skip
        Summary no semver update required
       Finished [  87.790s] datafusion-session
       Building datafusion-sqllogictest v55.1.0 (current)
          Built [ 110.044s] (current)
        Parsing datafusion-sqllogictest v55.1.0 (current)
         Parsed [   0.025s] (current)
       Building datafusion-sqllogictest v55.1.0 (baseline)
          Built [ 109.131s] (baseline)
        Parsing datafusion-sqllogictest v55.1.0 (baseline)
         Parsed [   0.023s] (baseline)
       Checking datafusion-sqllogictest v55.1.0 -> v55.1.0 (no change; assume patch)
        Checked [   0.096s] 223 checks: 223 pass, 31 skip
        Summary no semver update required
       Finished [ 222.038s] datafusion-sqllogictest
   ```
   
   </details>


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] feat: extract enforcement into a PhysicalAnalyzerRule phase (prereq for #25572) [datafusion]

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on PR #25688:
URL: https://github.com/apache/datafusion/pull/25688#issuecomment-5821444047

   Thanks @zhuqi-lucas  -- this is going to be great


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] feat: run physical requirement enforcement first, as a PhysicalAnalyzer phase [datafusion]

Posted by "zhuqi-lucas (via GitHub)" <gi...@apache.org>.
zhuqi-lucas commented on PR #25688:
URL: https://github.com/apache/datafusion/pull/25688#issuecomment-5882229805

   > Please just ping me when this is ready for another look.
   
   Thank you @alamb , it's ready for review again now and the sql bench has some regression now, because we do enforce first and some optimizer will broken the enforce and we need to reenforce some part of it.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] feat: run physical requirement enforcement first, as a PhysicalAnalyzer phase [datafusion]

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on PR #25688:
URL: https://github.com/apache/datafusion/pull/25688#issuecomment-6006654220

   > Projection pushdown is one concrete example of where another boundary could be useful. The important part is not this specific invariant, but that the same mechanism could express it naturally:
   
   I don't fully understand the use of this boundary -- when writing an OptimizerRule or trying to understand one, ideally I would not care if the projection was an explicit ProjectionExec or embedded in another ExecutionPlan unless it was relevant for my optimization


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] feat: run physical requirement enforcement first, as a PhysicalAnalyzer phase [datafusion]

Posted by "zhuqi-lucas (via GitHub)" <gi...@apache.org>.
zhuqi-lucas commented on PR #25688:
URL: https://github.com/apache/datafusion/pull/25688#issuecomment-6017106094

   Thank you @alamb and @2010YOUY01.
   
   One observation from reading #26069 against the code: its "only shape 1 is possible" precondition holds exactly because `LimitedDistinctAggregation` runs before `EnsureRequirements` and `CombinePartialFinalAggregate`, the only producers of the other two shapes. This PR makes that precondition explicit, since the rule now sits in the analyzer list ahead of enforcement. So I think the two PRs agree with each other.
   
   On the general mechanism, I agree with @alamb's framing: the invariants a plan can check about itself (schema, declared input properties satisfied) are what this boundary encodes, and `SanityCheckPlan` already verifies them. Shape facts like #26069's are a different kind: they describe what earlier rules produced, and nothing in the plan can verify them. For those I think the cheapest honest tool is what #26069 already does, a precondition stated in the rule's docs plus a debug assertion inside the rule, rather than a pipeline-level boundary that every rule has to declare against.
   
   I would land this PR as the base, and if a second concrete boundary that the plan itself can check shows up, build the general mechanism on top of it. Happy to review the PoC if @2010YOUY01 wants to explore it in parallel.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] feat: run physical requirement enforcement first, as a PhysicalAnalyzer phase [datafusion]

Posted by "2010YOUY01 (via GitHub)" <gi...@apache.org>.
2010YOUY01 commented on PR #25688:
URL: https://github.com/apache/datafusion/pull/25688#issuecomment-5928406180

   I'm wondering what concrete issue or bug this PR is trying to solve, is it to prevent similar bugs like
   
   - https://github.com/apache/datafusion/issues/21826
   
   Below are just some partial thoughts for reference. I'd like to probe into the target issue first to validate the reasoning, it's not suggesting a different implementation at this point.
   
   ----
   
   Placing `EnsureRequirements` in the middle may be a design that simplifies the overall implementation. The issue is that it introduces constraints on rewrites before and after it, and those constraints are not currently enforced explicitly, making the optimizer vulnerable to bugs. So I'm wondering whether there is a more flexible way to enforce the sanity check instead.
   
   One possible direction is to make these phase boundaries explicit. Each phase would have a well-defined plan shape that its rules can assume, rather than relying on the implicit ordering between individual optimizer rules. Roughly, the optimizer rule list can be split into stages like:
   
   # Optimizer rule list
   
   ```text
   // Stage 1: canonicalization
   // Normalize away enforced distribution so later rewrites operate on a
   // simpler canonical form without nodes such as `RepartitionExec`.
   
   initial_physical_planning
   
   
   // Stage 2: optimization
   // Easy-to-transform zone: rules can assume there is no `RepartitionExec`,
   // the rewrites are easier to implement.
   
   rule1
   rule2
   
   
   // Stage 3: lowering
   // Insert `RepartitionExec` where required. Rules after this point must
   // account for its presence.
   
   EnsureRequirements
   ```
   
   This is a common technique in compilers to organize very complex rewrites: split the pipeline into distinct phases and enforce the invariants. To keep overall transformation implementations simple, the general idea is to delay Stage 3 as late as possible, and try to put more rules in Stage 2, which seems to be in a different direction from this PR.
   
   The gap now, I think, is that the invariants are not enforced explicitly in datafusion (for example, after `EnsureRequirements`, traversing the tree after each rewrite to verify that the distribution requirements still hold), so it seem to have many hidden knowledge to know if you want to add one new optimizer rule correctly.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] feat: run physical requirement enforcement first, as a PhysicalAnalyzer phase [datafusion]

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on PR #25688:
URL: https://github.com/apache/datafusion/pull/25688#issuecomment-6250381924

   
   > > I think given the discussion and complexity here this work deserves writing up as an EPIC -- if you agree I will write up something that tries to explain the current situation, so we can be sure we are aligned
   > 
   > Thank you, this would be great!
   
   I tried to write up / summarize the high level discusison here
   - https://github.com/apache/datafusion/issues/26481


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] feat: run physical requirement enforcement first, as a PhysicalAnalyzer phase [datafusion]

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on PR #25688:
URL: https://github.com/apache/datafusion/pull/25688#issuecomment-6014895358

   > The TL;DR is that the existing optimizer rewrite implementation tries to recognize 3 possible aggregate plan shapes, and does so using a nested DFS algorithm.
   > However, there is a hidden constraint at the point where this rule runs, which means only one of those shapes is actually possible. With that constraint made explicit, the rewrite can be simplified to a straightforward pattern match without nested DFS.
   
   Thank you -- this is a very helpful example. I suspect the reason the rule look for three possible shapes is that they used to be created in earlier versions of DataFusion, so I wonder what type of boundary we could use to encode this in the future.
   
   > Now @zhuqi-lucas and @alamb seem more in favor of implementing the analyzer/optimizer split first, and treating a more general boundary mechanism as a follow-up.
   
   Yes, this accurately describes my preference, though I am happy to explore other alternatives and don't see any reason to rush this in.
   
   While the idea of a general boundary mechanism seems good in theory, I am somewhat skeptical of how useful it would be in practice. Specifically, I struggle to imagine what specific boundaries / invariants we could encode in an enumeration an enforce during planing other than the existing ones:
   1. Schema matches
   2. Declared required properties match actual input properties
   
   For example it is not clear to me the property described after `LimitedDistinctAggregation` in  https://github.com/apache/datafusion/pull/26069/changes#r4194462241 is actually invariant won't ever change  by all possible future optimizer passes, or even if we should try to enforce that as an invariant after subsequent passes
   
   I think my main concerns are:
   1.  Introducing a level of abstraction / API that isn't really used for anything other than the analyzer/optimizer split
   2. Adding unnecessarily strict requirements on other optimizer passes
   
   > My current preference is to implement the more general optimizer boundary directly, to avoid introducing multiple mechanisms for the same underlying problem.
   > 
   > I'd like to hear your thoughts before deciding on the next step. If you also think a general boundary mechanism is a plausible direction, I can put together a PoC this week.
   
   If we can come up with some other specific, useful boundaries / invariants this sounds like a good plan to me. 
   
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] feat: run physical requirement enforcement first, as a PhysicalAnalyzer phase [datafusion]

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on PR #25688:
URL: https://github.com/apache/datafusion/pull/25688#issuecomment-6233019348

   
   > For now, this invariant is only documented as a guideline, with automatic validation potentially added in the future.
   
   I think it is partially enforced by https://docs.rs/datafusion/latest/datafusion/physical_plan/trait.ExecutionPlan.html#method.check_invariants
   
   > 
   > If we want to enforce it, I think we need a machinery with similar complexity to #26360? If so, perhaps we could try to make it extensible to other invariant regions in the future.
   
   I do think adding additional invariants to the ExecutionPlans would be good
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] feat: run physical requirement enforcement first, as a PhysicalAnalyzer phase [datafusion]

Posted by "adriangbot (via GitHub)" <gi...@apache.org>.
adriangbot commented on PR #25688:
URL: https://github.com/apache/datafusion/pull/25688#issuecomment-5864837491

   🤖 Benchmark running (GKE) | [trigger](https://github.com/apache/datafusion/pull/25688#issuecomment-5864790300)
   **Instance:** `c4a-highmem-16` (12 vCPU / 65 GiB) | `Linux bench-c5864790300-2866-fjrcs 6.12.94+ #1 SMP Wed Aug 19 07:47:20 UTC 2026 aarch64 GNU/Linux`
   <details><summary>CPU Details (lscpu)</summary>
   
   ```
   Architecture:                            aarch64
   CPU op-mode(s):                          64-bit
   Byte Order:                              Little Endian
   CPU(s):                                  16
   On-line CPU(s) list:                     0-15
   Vendor ID:                               ARM
   Model name:                              Neoverse-V2
   Model:                                   1
   Thread(s) per core:                      1
   Core(s) per cluster:                     16
   Socket(s):                               -
   Cluster(s):                              1
   Stepping:                                r0p1
   BogoMIPS:                                2000.00
   Flags:                                   fp asimd evtstrm aes pmull sha1 sha2 crc32 atomics fphp asimdhp cpuid asimdrdm jscvt fcma lrcpc dcpop sha3 sm3 sm4 asimddp sha512 sve asimdfhm dit uscat ilrcpc flagm sb paca pacg dcpodp sve2 sveaes svepmull svebitperm svesha3 svesm4 flagm2 frint svei8mm svebf16 i8mm bf16 dgh rng bti
   L1d cache:                               1 MiB (16 instances)
   L1i cache:                               1 MiB (16 instances)
   L2 cache:                                32 MiB (16 instances)
   L3 cache:                                80 MiB (1 instance)
   NUMA node(s):                            1
   NUMA node0 CPU(s):                       0-15
   Vulnerability Gather data sampling:      Not affected
   Vulnerability Indirect target selection: Not affected
   Vulnerability Itlb multihit:             Not affected
   Vulnerability L1tf:                      Not affected
   Vulnerability Mds:                       Not affected
   Vulnerability Meltdown:                  Not affected
   Vulnerability Mmio stale data:           Not affected
   Vulnerability Reg file data sampling:    Not affected
   Vulnerability Retbleed:                  Not affected
   Vulnerability Spec rstack overflow:      Not affected
   Vulnerability Spec store bypass:         Mitigation; Speculative Store Bypass disabled via prctl
   Vulnerability Spectre v1:                Mitigation; __user pointer sanitization
   Vulnerability Spectre v2:                Mitigation; CSV2, BHB
   Vulnerability Srbds:                     Not affected
   Vulnerability Tsa:                       Not affected
   Vulnerability Tsx async abort:           Not affected
   Vulnerability Vmscape:                   Not affected
   ```
   
   </details>
   
   Comparing physical-analyzer-rule (9d47f7797e2c0f42d002e9895522e4b05a71d6eb) to e1aa7d9 (merge-base) [diff](https://github.com/apache/datafusion/compare/e1aa7d956a5aa67452c9e8bd2a033599767055d8..9d47f7797e2c0f42d002e9895522e4b05a71d6eb)
   
   <details><summary>Run configuration</summary>
   
   ```yaml
   run benchmark sql_planner
   ```
   
   </details>
   
   Results will be posted here when complete
   
   ---
   [File an issue](https://github.com/adriangb/datafusion-benchmarking/issues) against this benchmark runner


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] feat: run physical requirement enforcement first, as a PhysicalAnalyzer phase [datafusion]

Posted by "zhuqi-lucas (via GitHub)" <gi...@apache.org>.
zhuqi-lucas commented on PR #25688:
URL: https://github.com/apache/datafusion/pull/25688#issuecomment-6394102230

   Thanks @jayzhan211 for the careful review! Yes, please feel free to take it over — rebasing, fixing the issues above and adding the insert-only core on top sounds great to me. Happy to review it.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] feat: run physical requirement enforcement first, as a PhysicalAnalyzer phase [datafusion]

Posted by "adriangbot (via GitHub)" <gi...@apache.org>.
adriangbot commented on PR #25688:
URL: https://github.com/apache/datafusion/pull/25688#issuecomment-5865768324

   🤖 Benchmark completed (GKE) | [trigger](https://github.com/apache/datafusion/pull/25688#issuecomment-5864790300)
   
   **Instance:** `c4a-highmem-16` (12 vCPU / 65 GiB)
   
   Comparing physical-analyzer-rule (9d47f7797e2c0f42d002e9895522e4b05a71d6eb) to e1aa7d9 (merge-base) [diff](https://github.com/apache/datafusion/compare/e1aa7d956a5aa67452c9e8bd2a033599767055d8..9d47f7797e2c0f42d002e9895522e4b05a71d6eb)
   
   <details><summary>Run configuration</summary>
   
   ```yaml
   run benchmark sql_planner
   ```
   
   </details>
   
   <details><summary>CPU Details (lscpu)</summary>
   
   ```
   Architecture:                            aarch64
   CPU op-mode(s):                          64-bit
   Byte Order:                              Little Endian
   CPU(s):                                  16
   On-line CPU(s) list:                     0-15
   Vendor ID:                               ARM
   Model name:                              Neoverse-V2
   Model:                                   1
   Thread(s) per core:                      1
   Core(s) per cluster:                     16
   Socket(s):                               -
   Cluster(s):                              1
   Stepping:                                r0p1
   BogoMIPS:                                2000.00
   Flags:                                   fp asimd evtstrm aes pmull sha1 sha2 crc32 atomics fphp asimdhp cpuid asimdrdm jscvt fcma lrcpc dcpop sha3 sm3 sm4 asimddp sha512 sve asimdfhm dit uscat ilrcpc flagm sb paca pacg dcpodp sve2 sveaes svepmull svebitperm svesha3 svesm4 flagm2 frint svei8mm svebf16 i8mm bf16 dgh rng bti
   L1d cache:                               1 MiB (16 instances)
   L1i cache:                               1 MiB (16 instances)
   L2 cache:                                32 MiB (16 instances)
   L3 cache:                                80 MiB (1 instance)
   NUMA node(s):                            1
   NUMA node0 CPU(s):                       0-15
   Vulnerability Gather data sampling:      Not affected
   Vulnerability Indirect target selection: Not affected
   Vulnerability Itlb multihit:             Not affected
   Vulnerability L1tf:                      Not affected
   Vulnerability Mds:                       Not affected
   Vulnerability Meltdown:                  Not affected
   Vulnerability Mmio stale data:           Not affected
   Vulnerability Reg file data sampling:    Not affected
   Vulnerability Retbleed:                  Not affected
   Vulnerability Spec rstack overflow:      Not affected
   Vulnerability Spec store bypass:         Mitigation; Speculative Store Bypass disabled via prctl
   Vulnerability Spectre v1:                Mitigation; __user pointer sanitization
   Vulnerability Spectre v2:                Mitigation; CSV2, BHB
   Vulnerability Srbds:                     Not affected
   Vulnerability Tsa:                       Not affected
   Vulnerability Tsx async abort:           Not affected
   Vulnerability Vmscape:                   Not affected
   ```
   
   </details>
   
   <details><summary>Details</summary>
   <p>
   
   ```
   group                                                 HEAD                                    physical-analyzer-rule
   -----                                                 ----                                    ----------------------
   logical_aggregate_with_join                           1.00    406.0±1.72µs        ? ?/sec     1.01    410.4±1.75µs        ? ?/sec
   logical_correlated_subquery_exists                    1.00    244.8±1.74µs        ? ?/sec     1.01    246.8±1.68µs        ? ?/sec
   logical_correlated_subquery_in                        1.00    247.7±1.10µs        ? ?/sec     1.00    247.7±0.69µs        ? ?/sec
   logical_distinct_many_columns                         1.00    331.6±1.55µs        ? ?/sec     1.01    334.0±1.13µs        ? ?/sec
   logical_join_4_with_agg_and_filter                    1.00    200.1±0.52µs        ? ?/sec     1.00    200.3±0.97µs        ? ?/sec
   logical_join_8_with_agg_sort_limit                    1.00    368.6±1.83µs        ? ?/sec     1.02    375.5±1.74µs        ? ?/sec
   logical_join_chain_16                                 1.00    630.8±2.37µs        ? ?/sec     1.01    638.3±2.34µs        ? ?/sec
   logical_join_chain_4                                  1.00     78.7±0.30µs        ? ?/sec     1.00     78.7±0.41µs        ? ?/sec
   logical_join_chain_8                                  1.00    206.0±0.77µs        ? ?/sec     1.02    209.5±0.98µs        ? ?/sec
   logical_multiple_subqueries                           1.00    482.2±2.67µs        ? ?/sec     1.00    483.0±3.04µs        ? ?/sec
   logical_nested_cte_4_levels                           1.02    224.7±7.21µs        ? ?/sec     1.00    220.6±1.55µs        ? ?/sec
   logical_plan_struct_join_agg_sort                     1.00    124.9±0.17µs        ? ?/sec     1.03    129.0±1.66µs        ? ?/sec
   logical_plan_tpcds_all                                1.00     83.8±0.20ms        ? ?/sec     1.00     83.8±0.52ms        ? ?/sec
   logical_plan_tpch_all                                 1.00      5.6±0.03ms        ? ?/sec     1.00      5.6±0.02ms        ? ?/sec
   logical_scalar_subquery                               1.00    266.9±1.94µs        ? ?/sec     1.01    268.4±1.88µs        ? ?/sec
   logical_select_all_from_1000                          1.00      8.8±0.03ms        ? ?/sec     1.04      9.1±0.07ms        ? ?/sec
   logical_select_one_from_700                           1.00    293.8±1.77µs        ? ?/sec     1.01    295.7±1.89µs        ? ?/sec
   logical_trivial_join_high_numbered_columns            1.00    249.1±1.69µs        ? ?/sec     1.01    250.7±1.04µs        ? ?/sec
   logical_trivial_join_low_numbered_columns             1.00    236.5±1.35µs        ? ?/sec     1.02    241.4±2.16µs        ? ?/sec
   logical_union_4_branches                              1.00    388.2±1.75µs        ? ?/sec     1.01    390.3±2.06µs        ? ?/sec
   logical_union_8_branches                              1.00    780.5±2.36µs        ? ?/sec     1.02    797.1±3.45µs        ? ?/sec
   logical_wide_aggregate_100_exprs                      1.00      3.9±0.04ms        ? ?/sec     1.01      4.0±0.06ms        ? ?/sec
   logical_wide_case_50_exprs                            1.00  1804.7±11.81µs        ? ?/sec     1.01  1817.5±11.08µs        ? ?/sec
   logical_wide_filter_200_predicates                    1.00  1333.8±11.10µs        ? ?/sec     1.00   1331.5±6.10µs        ? ?/sec
   logical_wide_filter_50_predicates                     1.00    359.2±1.51µs        ? ?/sec     1.01    364.5±1.72µs        ? ?/sec
   optimizer_correlated_exists                           1.00    223.9±0.43µs        ? ?/sec     1.02    229.3±0.64µs        ? ?/sec
   optimizer_join_4_with_agg_filter                      1.00    409.1±0.99µs        ? ?/sec     1.03    422.0±1.79µs        ? ?/sec
   optimizer_join_chain_4                                1.00    157.4±0.40µs        ? ?/sec     1.02    161.1±0.25µs        ? ?/sec
   optimizer_join_chain_8                                1.00    548.9±2.22µs        ? ?/sec     1.00    550.6±1.39µs        ? ?/sec
   optimizer_select_all_from_1000                        1.03      7.0±0.01ms        ? ?/sec     1.00      6.8±0.05ms        ? ?/sec
   optimizer_select_one_from_700                         1.00    238.0±0.60µs        ? ?/sec     1.00    236.9±0.41µs        ? ?/sec
   optimizer_tpcds_all                                   1.00    286.0±2.93ms        ? ?/sec     1.01    288.9±2.88ms        ? ?/sec
   optimizer_tpch_all                                    1.00     15.6±0.24ms        ? ?/sec     1.03     16.1±0.03ms        ? ?/sec
   optimizer_wide_aggregate_100                          1.00   1783.0±4.48µs        ? ?/sec     1.01   1801.5±3.06µs        ? ?/sec
   optimizer_wide_filter_200                             1.00      3.9±0.02ms        ? ?/sec     1.01      3.9±0.01ms        ? ?/sec
   physical_intersection                                 1.00    579.1±7.10µs        ? ?/sec     1.00    581.3±2.47µs        ? ?/sec
   physical_join_consider_sort                           1.00   1039.7±2.17µs        ? ?/sec     1.02  1061.2±10.17µs        ? ?/sec
   physical_join_distinct                                1.00    227.8±1.41µs        ? ?/sec     1.01    231.0±1.22µs        ? ?/sec
   physical_many_self_joins                              1.00      7.7±0.07ms        ? ?/sec     1.03      7.9±0.11ms        ? ?/sec
   physical_plan_clickbench_all                          1.00   145.8±14.09ms        ? ?/sec     1.14   166.5±16.16ms        ? ?/sec
   physical_plan_clickbench_q1                           1.00  1416.5±103.41µs        ? ?/sec    1.09  1540.5±124.70µs        ? ?/sec
   physical_plan_clickbench_q10                          1.01      2.0±0.17ms        ? ?/sec     1.00      2.0±0.15ms        ? ?/sec
   physical_plan_clickbench_q11                          1.00      2.1±0.01ms        ? ?/sec     1.22      2.6±0.27ms        ? ?/sec
   physical_plan_clickbench_q12                          1.00      2.2±0.01ms        ? ?/sec     1.31      2.9±0.33ms        ? ?/sec
   physical_plan_clickbench_q13                          1.00      2.2±0.26ms        ? ?/sec     1.06      2.4±0.23ms        ? ?/sec
   physical_plan_clickbench_q14                          1.00      2.2±0.06ms        ? ?/sec     1.14      2.5±0.13ms        ? ?/sec
   physical_plan_clickbench_q15                          1.00      2.1±0.06ms        ? ?/sec     1.10      2.3±0.01ms        ? ?/sec
   physical_plan_clickbench_q16                          1.02  1809.8±110.06µs        ? ?/sec    1.00  1768.0±52.73µs        ? ?/sec
   physical_plan_clickbench_q17                          1.00  1831.1±130.12µs        ? ?/sec    1.08  1982.0±220.93µs        ? ?/sec
   physical_plan_clickbench_q18                          1.00   1659.7±5.57µs        ? ?/sec     1.03  1710.7±126.47µs        ? ?/sec
   physical_plan_clickbench_q19                          1.16      2.4±0.27ms        ? ?/sec     1.00      2.0±0.09ms        ? ?/sec
   physical_plan_clickbench_q2                           1.00  1795.1±131.68µs        ? ?/sec    1.05   1889.6±5.57µs        ? ?/sec
   physical_plan_clickbench_q20                          1.00  1607.9±133.80µs        ? ?/sec    1.03   1663.8±3.82µs        ? ?/sec
   physical_plan_clickbench_q21                          1.00  1787.8±128.55µs        ? ?/sec    1.06   1903.3±5.26µs        ? ?/sec
   physical_plan_clickbench_q22                          1.00      2.2±0.21ms        ? ?/sec     1.15      2.5±0.28ms        ? ?/sec
   physical_plan_clickbench_q23                          1.00      2.3±0.01ms        ? ?/sec     1.24      2.8±0.33ms        ? ?/sec
   physical_plan_clickbench_q24                          1.00      5.8±0.17ms        ? ?/sec     1.08      6.3±0.35ms        ? ?/sec
   physical_plan_clickbench_q25                          1.00   1841.4±5.19µs        ? ?/sec     1.10      2.0±0.06ms        ? ?/sec
   physical_plan_clickbench_q26                          1.00  1730.3±53.20µs        ? ?/sec     1.16      2.0±0.15ms        ? ?/sec
   physical_plan_clickbench_q27                          1.00  1996.2±195.13µs        ? ?/sec    1.11      2.2±0.21ms        ? ?/sec
   physical_plan_clickbench_q28                          1.00      2.2±0.01ms        ? ?/sec     1.13      2.5±0.01ms        ? ?/sec
   physical_plan_clickbench_q29                          1.00      2.6±0.31ms        ? ?/sec     1.19      3.1±0.35ms        ? ?/sec
   physical_plan_clickbench_q3                           1.00  1655.4±86.99µs        ? ?/sec     1.02  1688.9±138.24µs        ? ?/sec
   physical_plan_clickbench_q30                          1.00     15.3±0.34ms        ? ?/sec     1.02     15.6±0.41ms        ? ?/sec
   physical_plan_clickbench_q31                          1.00      2.3±0.01ms        ? ?/sec     1.13      2.6±0.14ms        ? ?/sec
   physical_plan_clickbench_q32                          1.00      2.5±0.24ms        ? ?/sec     1.05      2.6±0.01ms        ? ?/sec
   physical_plan_clickbench_q33                          1.02   1964.4±4.98µs        ? ?/sec     1.00   1933.7±5.34µs        ? ?/sec
   physical_plan_clickbench_q34                          1.00   1749.8±4.38µs        ? ?/sec     1.10  1933.2±218.96µs        ? ?/sec
   physical_plan_clickbench_q35                          1.13      2.1±0.23ms        ? ?/sec     1.00   1837.0±4.85µs        ? ?/sec
   physical_plan_clickbench_q36                          1.10      2.3±0.24ms        ? ?/sec     1.00      2.0±0.01ms        ? ?/sec
   physical_plan_clickbench_q37                          1.00      2.5±0.13ms        ? ?/sec     1.15      2.9±0.27ms        ? ?/sec
   physical_plan_clickbench_q38                          1.00      2.5±0.01ms        ? ?/sec     1.19      2.9±0.28ms        ? ?/sec
   physical_plan_clickbench_q39                          1.00      2.5±0.01ms        ? ?/sec     1.13      2.8±0.01ms        ? ?/sec
   physical_plan_clickbench_q4                           1.09  1624.0±152.34µs        ? ?/sec    1.00  1496.4±85.46µs        ? ?/sec
   physical_plan_clickbench_q40                          1.00      3.3±0.25ms        ? ?/sec     1.36      4.5±0.03ms        ? ?/sec
   physical_plan_clickbench_q41                          1.00      3.2±0.34ms        ? ?/sec     1.02      3.3±0.34ms        ? ?/sec
   physical_plan_clickbench_q42                          1.00      3.1±0.28ms        ? ?/sec     1.09      3.3±0.01ms        ? ?/sec
   physical_plan_clickbench_q43                          1.00      3.1±0.17ms        ? ?/sec     1.21      3.7±0.31ms        ? ?/sec
   physical_plan_clickbench_q44                          1.00  1552.5±30.14µs        ? ?/sec     1.02  1581.6±89.94µs        ? ?/sec
   physical_plan_clickbench_q45                          1.05  1637.4±126.57µs        ? ?/sec    1.00   1558.9±6.13µs        ? ?/sec
   physical_plan_clickbench_q46                          1.00  1918.9±186.74µs        ? ?/sec    1.08      2.1±0.20ms        ? ?/sec
   physical_plan_clickbench_q47                          1.07      2.6±0.28ms        ? ?/sec     1.00      2.4±0.08ms        ? ?/sec
   physical_plan_clickbench_q48                          1.00      2.5±0.05ms        ? ?/sec     1.20      3.0±0.26ms        ? ?/sec
   physical_plan_clickbench_q49                          1.00      2.6±0.08ms        ? ?/sec     1.13      2.9±0.01ms        ? ?/sec
   physical_plan_clickbench_q5                           1.00  1639.8±94.18µs        ? ?/sec     1.01  1654.8±105.28µs        ? ?/sec
   physical_plan_clickbench_q50                          1.00      2.6±0.19ms        ? ?/sec     1.07      2.8±0.01ms        ? ?/sec
   physical_plan_clickbench_q51                          1.00  1961.0±141.13µs        ? ?/sec    1.06      2.1±0.24ms        ? ?/sec
   physical_plan_clickbench_q52                          1.02      2.7±0.30ms        ? ?/sec     1.00      2.7±0.27ms        ? ?/sec
   physical_plan_clickbench_q53                          1.07  1892.4±164.72µs        ? ?/sec    1.00  1772.8±37.64µs        ? ?/sec
   physical_plan_clickbench_q54                          1.03  1810.6±125.87µs        ? ?/sec    1.00   1756.9±4.69µs        ? ?/sec
   physical_plan_clickbench_q55                          1.01  1718.5±116.85µs        ? ?/sec    1.00   1696.6±4.24µs        ? ?/sec
   physical_plan_clickbench_q56                          1.00  1705.6±90.71µs        ? ?/sec     1.18      2.0±0.17ms        ? ?/sec
   physical_plan_clickbench_q57                          1.00  1929.2±220.79µs        ? ?/sec    1.11      2.2±0.23ms        ? ?/sec
   physical_plan_clickbench_q58                          1.00      2.4±0.25ms        ? ?/sec     1.09      2.6±0.15ms        ? ?/sec
   physical_plan_clickbench_q59                          1.01  1725.5±100.01µs        ? ?/sec    1.00  1707.0±31.71µs        ? ?/sec
   physical_plan_clickbench_q6                           1.00  1631.0±94.11µs        ? ?/sec     1.01  1654.9±53.49µs        ? ?/sec
   physical_plan_clickbench_q60                          1.01  1712.4±102.60µs        ? ?/sec    1.00   1703.4±3.99µs        ? ?/sec
   physical_plan_clickbench_q7                           1.00   1431.5±4.59µs        ? ?/sec     1.23  1764.3±181.98µs        ? ?/sec
   physical_plan_clickbench_q8                           1.08      2.3±0.25ms        ? ?/sec     1.00      2.2±0.04ms        ? ?/sec
   physical_plan_clickbench_q9                           1.03      2.0±0.19ms        ? ?/sec     1.00  1957.6±128.49µs        ? ?/sec
   physical_plan_struct_join_agg_sort                    1.00  1322.1±13.12µs        ? ?/sec     1.08   1430.3±2.99µs        ? ?/sec
   physical_plan_tpcds_all                               1.00   672.9±21.24ms        ? ?/sec     1.13   762.1±22.57ms        ? ?/sec
   physical_plan_tpch_all                                1.00     43.3±1.54ms        ? ?/sec     1.11     48.2±0.95ms        ? ?/sec
   physical_plan_tpch_q1                                 1.00   1427.4±7.05µs        ? ?/sec     1.00  1432.5±26.05µs        ? ?/sec
   physical_plan_tpch_q10                                1.00      2.5±0.14ms        ? ?/sec     1.13      2.8±0.04ms        ? ?/sec
   physical_plan_tpch_q11                                1.00      2.2±0.00ms        ? ?/sec     1.13      2.4±0.00ms        ? ?/sec
   physical_plan_tpch_q12                                1.00   1228.2±2.09µs        ? ?/sec     1.09  1341.4±38.78µs        ? ?/sec
   physical_plan_tpch_q13                                1.00  1014.8±14.79µs        ? ?/sec     1.12  1140.7±18.22µs        ? ?/sec
   physical_plan_tpch_q14                                1.00  1334.4±29.64µs        ? ?/sec     1.10  1467.0±24.83µs        ? ?/sec
   physical_plan_tpch_q16                                1.00   1601.9±1.97µs        ? ?/sec     1.20  1924.3±111.67µs        ? ?/sec
   physical_plan_tpch_q17                                1.00  1704.5±62.23µs        ? ?/sec     1.07  1826.4±97.11µs        ? ?/sec
   physical_plan_tpch_q18                                1.00  1949.0±94.59µs        ? ?/sec     1.14      2.2±0.10ms        ? ?/sec
   physical_plan_tpch_q19                                1.00  1816.4±53.19µs        ? ?/sec     1.05  1902.3±47.93µs        ? ?/sec
   physical_plan_tpch_q2                                 1.00      3.5±0.00ms        ? ?/sec     1.16      4.0±0.00ms        ? ?/sec
   physical_plan_tpch_q20                                1.00      2.1±0.14ms        ? ?/sec     1.07      2.3±0.00ms        ? ?/sec
   physical_plan_tpch_q21                                1.00      2.7±0.00ms        ? ?/sec     1.33      3.5±0.02ms        ? ?/sec
   physical_plan_tpch_q22                                1.01  1640.2±65.73µs        ? ?/sec     1.00  1619.3±72.18µs        ? ?/sec
   physical_plan_tpch_q3                                 1.00  1787.1±61.77µs        ? ?/sec     1.27      2.3±0.02ms        ? ?/sec
   physical_plan_tpch_q4                                 1.00  1125.7±16.73µs        ? ?/sec     1.16  1303.4±34.99µs        ? ?/sec
   physical_plan_tpch_q5                                 1.00      2.5±0.04ms        ? ?/sec     1.18      3.0±0.00ms        ? ?/sec
   physical_plan_tpch_q6                                 1.00    592.2±2.93µs        ? ?/sec     1.03    612.4±4.68µs        ? ?/sec
   physical_plan_tpch_q7                                 1.00      2.7±0.14ms        ? ?/sec     1.24      3.4±0.17ms        ? ?/sec
   physical_plan_tpch_q8                                 1.00      3.6±0.00ms        ? ?/sec     1.20      4.3±0.01ms        ? ?/sec
   physical_plan_tpch_q9                                 1.00      2.6±0.00ms        ? ?/sec     1.29      3.4±0.14ms        ? ?/sec
   physical_select_aggregates_from_200                   1.00     12.4±0.16ms        ? ?/sec     1.02     12.7±0.03ms        ? ?/sec
   physical_select_all_from_1000                         1.00     20.3±0.12ms        ? ?/sec     1.00     20.3±0.16ms        ? ?/sec
   physical_select_one_from_700                          1.00    739.0±2.70µs        ? ?/sec     1.00    741.9±3.48µs        ? ?/sec
   physical_sorted_union_order_by_10_int64               1.01      3.9±0.13ms        ? ?/sec     1.00      3.9±0.11ms        ? ?/sec
   physical_sorted_union_order_by_10_uint64              1.00      7.4±0.01ms        ? ?/sec     1.01      7.5±0.01ms        ? ?/sec
   physical_sorted_union_order_by_50_int64               1.01     85.4±1.54ms        ? ?/sec     1.00     84.9±1.68ms        ? ?/sec
   physical_sorted_union_order_by_50_uint64              1.00   305.9±10.52ms        ? ?/sec     1.00    306.3±9.98ms        ? ?/sec
   physical_theta_join_consider_sort                     1.01   1071.7±8.23µs        ? ?/sec     1.00   1064.7±3.58µs        ? ?/sec
   physical_unnest_to_join                               1.00    620.1±1.78µs        ? ?/sec     1.00    618.2±1.72µs        ? ?/sec
   physical_window_function_partition_by_12_on_values    1.00    646.9±2.55µs        ? ?/sec     1.03    665.3±3.49µs        ? ?/sec
   physical_window_function_partition_by_30_on_values    1.00   1299.2±9.80µs        ? ?/sec     1.01  1315.2±10.21µs        ? ?/sec
   physical_window_function_partition_by_4_on_values     1.00    395.1±1.77µs        ? ?/sec     1.05    413.7±1.32µs        ? ?/sec
   physical_window_function_partition_by_7_on_values     1.00    483.1±1.81µs        ? ?/sec     1.05    506.4±1.52µs        ? ?/sec
   physical_window_function_partition_by_8_on_values     1.00    519.0±1.90µs        ? ?/sec     1.05    543.2±2.49µs        ? ?/sec
   with_param_values_many_columns                        1.00    430.6±2.38µs        ? ?/sec     1.02    439.5±1.99µs        ? ?/sec
   ```
   
   </p>
   </details>
   
   <details><summary>Resource Usage</summary>
   
   **sql_planner — base (merge-base)**
   | Metric | Value |
   |--------|-------|
   | Wall time | 2065.5s |
   | Peak memory | 138.7 MiB |
   | Avg memory | 87.9 MiB |
   | CPU user | 1976.0s |
   | CPU sys | 1.6s |
   | Peak spill | 0 B |
   
   **sql_planner — branch**
   | Metric | Value |
   |--------|-------|
   | Wall time | 2050.5s |
   | Peak memory | 139.0 MiB |
   | Avg memory | 89.3 MiB |
   | CPU user | 1967.1s |
   | CPU sys | 1.6s |
   | Peak spill | 0 B |
   
   </details>
   
   
   ---
   [File an issue](https://github.com/adriangb/datafusion-benchmarking/issues) against this benchmark runner


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] feat: run physical requirement enforcement first, as a PhysicalAnalyzer phase [datafusion]

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on PR #25688:
URL: https://github.com/apache/datafusion/pull/25688#issuecomment-5930726354

   Thank you for working on this @zhuqi-lucas 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] feat: run physical requirement enforcement first, as a PhysicalAnalyzer phase [datafusion]

Posted by "zhuqi-lucas (via GitHub)" <gi...@apache.org>.
zhuqi-lucas commented on PR #25688:
URL: https://github.com/apache/datafusion/pull/25688#issuecomment-5946484125

   Thanks @alamb, and sorry for the long comments, I will keep them short from now on.
   
   > For example, if we had to initially treat JoinSelection as a PhysicalAnalyzerRule because it produces invalid plans we could do that initially (and keep the same effective ordering of passes as today, but split between Analyzer/Optimizer)
   >
   > Then in follow on PRs we could explore how to move JoinSelection into the OptimizerRules (e.g. by ensuring that it doesn't make plans invalid)
   
   That is what the current push does: `JoinSelection` runs as an analyzer rule, before enforcement, so nothing re-enforces any more; `EnsureRequirements` is one rule again; and the benchmark shows no regression. The one plan change left is the `window_topn.slt` case, which gains parallelism.
   
   It goes a bit beyond the smallest change in two places: `AggregateStatistics`, `LimitedDistinctAggregation` and `WindowTopN` already run after enforcement (with the small fixes that needed), and the debug-only `check_invariants` boundary check you pointed at is in. Happy to split either out if you prefer. The follow-ups I plan are exactly the ones you describe: moving `FilterPushdown` and then `JoinSelection` into the optimizer phase, once they can keep plans valid on their own.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] feat: run physical requirement enforcement first, as a PhysicalAnalyzer phase [datafusion]

Posted by "zhuqi-lucas (via GitHub)" <gi...@apache.org>.
zhuqi-lucas commented on PR #25688:
URL: https://github.com/apache/datafusion/pull/25688#issuecomment-5946668057

   run benchmark sql_planner
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] feat: extract enforcement into a PhysicalAnalyzerRule phase (prereq for #25572) [datafusion]

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on code in PR #25688:
URL: https://github.com/apache/datafusion/pull/25688#discussion_r4092066476


##########
datafusion/core/src/execution/session_state.rs:
##########
@@ -259,6 +265,7 @@ impl Debug for SessionState {
         ret.field("query_planners", &self.inner.query_planner)
             .field("analyzer", &self.inner.analyzer)
             .field("optimizer", &self.inner.optimizer)
+            .field("physical_analyzers", &self.inner.physical_analyzers)

Review Comment:
   I know I am biased, but I really like the symmetry here with the `analyzer`



##########
datafusion/core/src/execution/session_state.rs:
##########
@@ -166,6 +169,9 @@ struct SessionStateInner {
     type_planner: Option<Arc<dyn TypePlanner>>,
     /// Responsible for optimizing a logical plan
     optimizer: Optimizer,
+    /// Responsible for enforcing invariants on a physical execution plan
+    /// (distribution, ordering) before optimization

Review Comment:
   ❤️ 



##########
datafusion/core/src/physical_planner.rs:
##########
@@ -3122,7 +2969,72 @@ impl DefaultPhysicalPlanner {
         let optimizer_context = SessionOptimizerContext {
             session: session_state,
         };
-        for optimizer in optimizers {
+
+        // Where the analyzer phase (enforcement) runs relative to the optimizer
+        // rules. Enforcement makes the plan *valid* by satisfying the
+        // distribution and ordering requirements every operator declares.
+        //
+        // Ideally analyzers would run strictly first, but the built-in pipeline
+        // cannot: `JoinSelection` is an optimizer that decides broadcast

Review Comment:
   I think we should strive to get rid of this code (perhaps by refactoring the JoinSelection pass to update the distribution itself (by calling a helper of Enforce, for example) and actually put enforcement first. 
   
   I think longer term being able to easily adjust join orders and update the plan as necessary is important for having better join optimizer support
   
   So maybe we need to start with a PR to run JoinSelection after Enforcement, and then this PR to pull enforcment to an analyzer rule that runs first
   
   The other thing we could do temporarily is maybe put `JoinSelection` as an analyzer rule (as strange as that is) and file a ticket to make it a real analyzer rule



##########
datafusion/physical-optimizer/src/analyzer.rs:
##########
@@ -0,0 +1,113 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+//! Physical analyzer
+
+use std::sync::Arc;
+
+use crate::ensure_requirements::EnsureRequirements;
+
+// Re-export from this module for convenience.
+pub use datafusion_session::PhysicalAnalyzerRule;
+
+/// A rule-based physical analyzer.
+///
+/// Analyzer rules make the plan *valid*: they enforce the invariants every
+/// operator declares (distribution, ordering) rather than making the plan
+/// faster, mirroring the logical layer's `Analyzer`/`Optimizer` split. They run
+/// as a distinct phase relative to the [`PhysicalOptimizer`](crate::optimizer::PhysicalOptimizer)
+/// rules; see [`PhysicalAnalyzerRule`] for how the default planner places that
+/// phase (it is not run strictly before every optimizer rule).
+#[derive(Clone, Debug)]
+pub struct PhysicalAnalyzer {
+    /// All rules to apply
+    pub rules: Vec<Arc<dyn PhysicalAnalyzerRule + Send + Sync>>,
+}
+
+impl Default for PhysicalAnalyzer {
+    fn default() -> Self {
+        Self::new()
+    }
+}
+
+impl PhysicalAnalyzer {
+    /// Create a new analyzer using the recommended list of rules
+    pub fn new() -> Self {
+        let rules: Vec<Arc<dyn PhysicalAnalyzerRule + Send + Sync>> = vec![
+            // Ensures each input plan satisfies the distribution and ordering

Review Comment:
   I think this comment should maybe be on PhysicalAnalyzer or the `PhysicalAnalyzerRule`



##########
datafusion/physical-optimizer/src/analyzer.rs:
##########
@@ -0,0 +1,113 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+//! Physical analyzer
+
+use std::sync::Arc;
+
+use crate::ensure_requirements::EnsureRequirements;
+
+// Re-export from this module for convenience.
+pub use datafusion_session::PhysicalAnalyzerRule;
+
+/// A rule-based physical analyzer.
+///
+/// Analyzer rules make the plan *valid*: they enforce the invariants every
+/// operator declares (distribution, ordering) rather than making the plan
+/// faster, mirroring the logical layer's `Analyzer`/`Optimizer` split. They run
+/// as a distinct phase relative to the [`PhysicalOptimizer`](crate::optimizer::PhysicalOptimizer)
+/// rules; see [`PhysicalAnalyzerRule`] for how the default planner places that
+/// phase (it is not run strictly before every optimizer rule).
+#[derive(Clone, Debug)]
+pub struct PhysicalAnalyzer {
+    /// All rules to apply
+    pub rules: Vec<Arc<dyn PhysicalAnalyzerRule + Send + Sync>>,
+}
+
+impl Default for PhysicalAnalyzer {
+    fn default() -> Self {
+        Self::new()
+    }
+}
+
+impl PhysicalAnalyzer {
+    /// Create a new analyzer using the recommended list of rules
+    pub fn new() -> Self {
+        let rules: Vec<Arc<dyn PhysicalAnalyzerRule + Send + Sync>> = vec![
+            // Ensures each input plan satisfies the distribution and ordering
+            // requirements declared by `ExecutionPlan::required_input_distribution`
+            // and `ExecutionPlan::required_input_ordering`.
+            //
+            // If the requirements are already satisfied, this rule leaves the plan
+            // unchanged. For example, it does not add sorting when the input is a
+            // file scan whose existing order already satisfies the required ordering.
+            // Otherwise, this rule inserts the necessary repartitioning and sorting
+            // operators.
+            //
+            // This used to be implemented as two separate rules: `EnforceDistribution`

Review Comment:
   it isn't clear to me why the history of having 2 separate rules is important for future readers to know (I think we could pare this one down)



##########
datafusion/session/src/physical_analyzer.rs:
##########
@@ -0,0 +1,104 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+//! Physical analyzer interfaces.
+
+use std::fmt::Debug;
+use std::sync::Arc;
+
+use datafusion_common::Result;
+use datafusion_common::config::ConfigOptions;
+use datafusion_physical_plan::ExecutionPlan;
+
+use crate::physical_optimizer::PhysicalOptimizerContext;
+
+/// A `PhysicalAnalyzerRule` transforms an [`ExecutionPlan`] to make the plan
+/// *valid* prior to the rest of the DataFusion physical optimization process.
+///
+/// `PhysicalAnalyzerRule`s are different from [`PhysicalOptimizerRule`]s: an
+/// optimizer rule must preserve the semantics of an already-valid plan while
+/// computing the same results in a more efficient way, whereas an analyzer
+/// rule is what *establishes* those semantics by satisfying the invariants
+/// every operator declares.
+///
+/// For example, an analyzer rule may repartition an [`ExecutionPlan`]'s input
+/// to match [`ExecutionPlan::required_input_distribution`] or insert a
+/// `SortExec` to match [`ExecutionPlan::required_input_ordering`].
+///
+/// This mirrors the logical layer's split between `AnalyzerRule` (make the
+/// plan valid) and `OptimizerRule` (make the plan faster).
+///
+/// # Ordering
+///
+/// Analyzer rules run as their own phase, conceptually before the optimizer
+/// rules that assume a valid plan. Note that the built-in planner does not
+/// literally run every analyzer before every optimizer: to preserve the
+/// hand-tuned order of the default pipeline it runs the analyzer phase at the
+/// position `EnsureRequirements` historically occupied (see
+/// [`DefaultPhysicalPlanner::optimize_physical_plan`]), because some default
+/// optimizer rules (notably join selection) must run before enforcement. A
+/// custom rule should therefore not assume it sees the raw initial plan, only
+/// that requirement enforcement has not yet run when it does.
+///
+/// [`DefaultPhysicalPlanner::optimize_physical_plan`]: https://docs.rs/datafusion/latest/datafusion/physical_planner/struct.DefaultPhysicalPlanner.html#method.optimize_physical_plan
+///
+/// [`PhysicalOptimizerRule`]: crate::physical_optimizer::PhysicalOptimizerRule
+/// [`ExecutionPlan::required_input_distribution`]: datafusion_physical_plan::ExecutionPlan::required_input_distribution
+/// [`ExecutionPlan::required_input_ordering`]: datafusion_physical_plan::ExecutionPlan::required_input_ordering
+pub trait PhysicalAnalyzerRule: Debug + std::any::Any {
+    /// Rewrite `plan` so that it satisfies the invariants this rule enforces.
+    ///
+    /// This is the primary method. Rules that need access to the statistics
+    /// registry should override [`analyze_with_context`](Self::analyze_with_context)
+    /// instead.
+    fn analyze(
+        &self,
+        plan: Arc<dyn ExecutionPlan>,
+        config: &ConfigOptions,
+    ) -> Result<Arc<dyn ExecutionPlan>>;
+
+    /// Rewrite `plan` with access to extended context (statistics registry, etc.).
+    ///
+    /// The default implementation calls [`analyze`](Self::analyze) with the
+    /// config options from the context. This mirrors
+    /// [`PhysicalOptimizerRule::optimize_with_context`], so enforcement passes
+    /// keep the same statistics-registry access they had while they were
+    /// optimizer rules.
+    ///
+    /// [`PhysicalOptimizerRule::optimize_with_context`]: crate::physical_optimizer::PhysicalOptimizerRule::optimize_with_context
+    fn analyze_with_context(
+        &self,
+        plan: Arc<dyn ExecutionPlan>,
+        context: &dyn PhysicalOptimizerContext,
+    ) -> Result<Arc<dyn ExecutionPlan>> {
+        self.analyze(plan, context.config_options())
+    }
+
+    /// A human readable name for this analyzer rule.
+    fn name(&self) -> &str;
+
+    /// A flag to indicate whether the physical planner should validate that
+    /// the rule will not change the schema of the plan after the rewrite.
+    ///
+    /// This mirrors [`PhysicalOptimizerRule::schema_check`]; enforcement passes

Review Comment:
   FWIW I think schema_check should be true for all optimizer rules and only analyzer rules should be alloed to change the schema, given the definition of analyzer / optimizer we are adding. We could try and tighten this up as a follow on issue / work -- no need to do it here



##########
datafusion/session/src/physical_analyzer.rs:
##########
@@ -0,0 +1,104 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+//! Physical analyzer interfaces.
+
+use std::fmt::Debug;
+use std::sync::Arc;
+
+use datafusion_common::Result;
+use datafusion_common::config::ConfigOptions;
+use datafusion_physical_plan::ExecutionPlan;
+
+use crate::physical_optimizer::PhysicalOptimizerContext;
+
+/// A `PhysicalAnalyzerRule` transforms an [`ExecutionPlan`] to make the plan
+/// *valid* prior to the rest of the DataFusion physical optimization process.
+///
+/// `PhysicalAnalyzerRule`s are different from [`PhysicalOptimizerRule`]s: an
+/// optimizer rule must preserve the semantics of an already-valid plan while
+/// computing the same results in a more efficient way, whereas an analyzer
+/// rule is what *establishes* those semantics by satisfying the invariants
+/// every operator declares.
+///
+/// For example, an analyzer rule may repartition an [`ExecutionPlan`]'s input
+/// to match [`ExecutionPlan::required_input_distribution`] or insert a
+/// `SortExec` to match [`ExecutionPlan::required_input_ordering`].
+///
+/// This mirrors the logical layer's split between `AnalyzerRule` (make the
+/// plan valid) and `OptimizerRule` (make the plan faster).
+///
+/// # Ordering
+///
+/// Analyzer rules run as their own phase, conceptually before the optimizer
+/// rules that assume a valid plan. Note that the built-in planner does not
+/// literally run every analyzer before every optimizer: to preserve the

Review Comment:
   As mentioned elsewhere I think we should change this



##########
datafusion/session/src/physical_analyzer.rs:
##########
@@ -0,0 +1,104 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+//! Physical analyzer interfaces.
+
+use std::fmt::Debug;
+use std::sync::Arc;
+
+use datafusion_common::Result;
+use datafusion_common::config::ConfigOptions;
+use datafusion_physical_plan::ExecutionPlan;
+
+use crate::physical_optimizer::PhysicalOptimizerContext;
+
+/// A `PhysicalAnalyzerRule` transforms an [`ExecutionPlan`] to make the plan
+/// *valid* prior to the rest of the DataFusion physical optimization process.
+///
+/// `PhysicalAnalyzerRule`s are different from [`PhysicalOptimizerRule`]s: an
+/// optimizer rule must preserve the semantics of an already-valid plan while
+/// computing the same results in a more efficient way, whereas an analyzer
+/// rule is what *establishes* those semantics by satisfying the invariants
+/// every operator declares.
+///
+/// For example, an analyzer rule may repartition an [`ExecutionPlan`]'s input
+/// to match [`ExecutionPlan::required_input_distribution`] or insert a
+/// `SortExec` to match [`ExecutionPlan::required_input_ordering`].
+///
+/// This mirrors the logical layer's split between `AnalyzerRule` (make the

Review Comment:
   I recommend making these doc links to ANalyzerRule and OptimizerRule (they probably need to be links to the docs.rs page due to crate dependencies)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] feat: run physical requirement enforcement first, as a PhysicalAnalyzer phase [datafusion]

Posted by "adriangbot (via GitHub)" <gi...@apache.org>.
adriangbot commented on PR #25688:
URL: https://github.com/apache/datafusion/pull/25688#issuecomment-5946920841

   🤖 Benchmark running (GKE) | [trigger](https://github.com/apache/datafusion/pull/25688#issuecomment-5946668057)
   **Instance:** `c4a-highcpu-48` (12 vCPU / 65 GiB) | `Linux bench-c5946668057-3020-b7dnt 6.12.94+ #1 SMP Wed Aug 19 07:47:20 UTC 2026 aarch64 GNU/Linux`
   <details><summary>CPU Details (lscpu)</summary>
   
   ```
   Architecture:                            aarch64
   CPU op-mode(s):                          64-bit
   Byte Order:                              Little Endian
   CPU(s):                                  48
   On-line CPU(s) list:                     0-47
   Vendor ID:                               ARM
   Model name:                              Neoverse-V2
   Model:                                   1
   Thread(s) per core:                      1
   Core(s) per cluster:                     48
   Socket(s):                               -
   Cluster(s):                              1
   Stepping:                                r0p1
   BogoMIPS:                                2000.00
   Flags:                                   fp asimd evtstrm aes pmull sha1 sha2 crc32 atomics fphp asimdhp cpuid asimdrdm jscvt fcma lrcpc dcpop sha3 sm3 sm4 asimddp sha512 sve asimdfhm dit uscat ilrcpc flagm sb paca pacg dcpodp sve2 sveaes svepmull svebitperm svesha3 svesm4 flagm2 frint svei8mm svebf16 i8mm bf16 dgh rng bti
   L1d cache:                               3 MiB (48 instances)
   L1i cache:                               3 MiB (48 instances)
   L2 cache:                                96 MiB (48 instances)
   L3 cache:                                80 MiB (1 instance)
   NUMA node(s):                            1
   NUMA node0 CPU(s):                       0-47
   Vulnerability Gather data sampling:      Not affected
   Vulnerability Indirect target selection: Not affected
   Vulnerability Itlb multihit:             Not affected
   Vulnerability L1tf:                      Not affected
   Vulnerability Mds:                       Not affected
   Vulnerability Meltdown:                  Not affected
   Vulnerability Mmio stale data:           Not affected
   Vulnerability Reg file data sampling:    Not affected
   Vulnerability Retbleed:                  Not affected
   Vulnerability Spec rstack overflow:      Not affected
   Vulnerability Spec store bypass:         Mitigation; Speculative Store Bypass disabled via prctl
   Vulnerability Spectre v1:                Mitigation; __user pointer sanitization
   Vulnerability Spectre v2:                Mitigation; CSV2, BHB
   Vulnerability Srbds:                     Not affected
   Vulnerability Tsa:                       Not affected
   Vulnerability Tsx async abort:           Not affected
   Vulnerability Vmscape:                   Not affected
   ```
   
   </details>
   
   Comparing physical-analyzer-rule (79c63dab6706c4eb16304173a226d5b31d24ce92) to 4d167a1 (merge-base) [diff](https://github.com/apache/datafusion/compare/4d167a167228a424ef8cc29fd6bea5f17fc23c2a..79c63dab6706c4eb16304173a226d5b31d24ce92)
   
   <details><summary>Run configuration</summary>
   
   ```yaml
   run benchmark sql_planner
   ```
   
   </details>
   
   Results will be posted here when complete
   
   ---
   [File an issue](https://github.com/adriangb/datafusion-benchmarking/issues) against this benchmark runner


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] feat: run physical requirement enforcement first, as a PhysicalAnalyzer phase [datafusion]

Posted by "2010YOUY01 (via GitHub)" <gi...@apache.org>.
2010YOUY01 commented on PR #25688:
URL: https://github.com/apache/datafusion/pull/25688#issuecomment-6008750474

   > If I understand the assumptions behind the optimizer implementation correctly, adding more explicit constraints should make both understanding and implementation easier.
   
   There happens to be an example of how an extra constraint can simplify the implementation; see the rationale for details.
   
   The TL;DR is that the existing optimizer rewrite implementation tries to recognize 3 possible aggregate plan shapes, and does so using a nested DFS algorithm.
   
   However, there is a hidden constraint at the point where this rule runs, which means only one of those shapes is actually possible. With that constraint made explicit, the rewrite can be simplified to a straightforward pattern match without nested DFS.
   
   - https://github.com/apache/datafusion/pull/26069


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] feat: run physical requirement enforcement first, as a PhysicalAnalyzer phase [datafusion]

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on PR #25688:
URL: https://github.com/apache/datafusion/pull/25688#issuecomment-6006612748

   > # What I mean by extensible boundaries
   
   Thank you @2010YOUY01  and @zhuqi-lucas  
   
   Extensible boundaries are an interesting idea, do you have any particular use case in mind for this?
   
   The one usecase I know of is a OptimizerRule that may disturb sorting or distribution requirements (and thus needs to run the EnforceRequirements pass again). I think this usecase can be satisfied by having the OptimizerRule just call EnforceRequirements again explicitly so the requirements are satisfied after the rule runs.
   
   As neat an idea of having multiple classes of constraints that can be satisfied at different points, I think it makes it harder to reason about the optimizer as a whole and any OptimizerRule individually -- we would need some way for each rule to communicate what its expected input and output boundary was
   
   I also don't see the split of "invalid plan" --> "valid plan" as embodied in AnalayzeRule / OptimizerRule as preventing us from adding some sort of extensible boundaries in the future (though they would likely not have an invalid/valid boundary) 🤔 
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] feat: run physical requirement enforcement first, as a PhysicalAnalyzer phase [datafusion]

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on PR #25688:
URL: https://github.com/apache/datafusion/pull/25688#issuecomment-6018276865

   > Those concerns make a lot of sense to me. My next step is to prototype the idea and try to identify/enforce ~3 more useful boundaries or invariants, to see whether this approach can consistently reduce complexity:
   
   Thank you for the measured and thoughtful reply. I think the idea of prototyping out what it might look like is a very reasonable next step


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] feat: run physical requirement enforcement first, as a PhysicalAnalyzer phase [datafusion]

Posted by "zhuqi-lucas (via GitHub)" <gi...@apache.org>.
zhuqi-lucas commented on PR #25688:
URL: https://github.com/apache/datafusion/pull/25688#issuecomment-5965273828

   Thanks @2010YOUY01, your summary is accurate.
   
   I like the extensible boundaries idea. The analyzer/optimizer split is the first such boundary, and a generic "boundary + validator" entry in the rule list can build on it rather than replace it. I would treat this PR as the starting point and do the general mechanism as a follow-up, there is a lot we can build on top of it.
   
   The validation part is cheap: behind `cfg(debug_assertions)`, run the sanity check (distribution and ordering satisfied) after every optimizer rule, so a violation points at the rule that caused it. Zero cost in release, same as the existing per-rule `check_invariants`. Happy to add that here if you both prefer, otherwise as a follow-up.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] feat: run physical requirement enforcement first, as a PhysicalAnalyzer phase [datafusion]

Posted by "zhuqi-lucas (via GitHub)" <gi...@apache.org>.
zhuqi-lucas commented on PR #25688:
URL: https://github.com/apache/datafusion/pull/25688#issuecomment-5864790300

   run benchmark sql_planner


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] feat: extract enforcement into a PhysicalAnalyzerRule phase (prereq for #25572) [datafusion]

Posted by "zhuqi-lucas (via GitHub)" <gi...@apache.org>.
zhuqi-lucas commented on PR #25688:
URL: https://github.com/apache/datafusion/pull/25688#issuecomment-5812372370

   Thanks @alamb, this is really helpful. Agreed on enforcement-first — I'll follow your sequencing: first a PR refactoring `JoinSelection` to update distribution itself via a reusable `Enforce` helper (so it runs after enforcement), then this PR pulls enforcement into an analyzer that runs first, and I'll pare down the comments here meanwhile.
   
   One thing I'd like to fold into that helper: make it invariant-gated so any rule that changes requirements can call it to self-repair cheaply when the plan is already valid, which keeps repeated enforcement from re-deriving the whole tree.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] feat: run physical requirement enforcement first, as a PhysicalAnalyzer phase [datafusion]

Posted by "2010YOUY01 (via GitHub)" <gi...@apache.org>.
2010YOUY01 commented on PR #25688:
URL: https://github.com/apache/datafusion/pull/25688#issuecomment-5965009472

   Here is what I understand from the latest discussion and code diff. I used AI to help summarize it, so please point out anything I misunderstood.
   
   The latest change keeps the existing physical optimizer rule order, but introduces one hard boundary through the `PhysicalAnalyzer` / `PhysicalOptimizer` split.
   
   Conceptually:
   
   - **Before the boundary:** there are no enforced repartition/sort operators yet, so rules are relatively free to transform the plan.
   - **After the boundary:** repartition/sort operators may already exist, so every later rule must recognize and preserve the distribution and ordering requirements that have already been satisfied.
   
   My major suggestion is to make this boundary mechanism **extensible**, instead of encoding one specific boundary through the Analyzer/Optimizer split.
   
   ```text
   # Current design
   
   PhysicalAnalyzer:
       OutputRequirements(add)
       aggregate_statistics
       join_selection
       LimitedDistinctAggregation
       FilterPushdown
       WindowTopN
       EnsureRequirements
   
       # Boundary:
       # distribution and ordering requirements are satisfied
   
   PhysicalOptimizer:
       ...remaining existing rules...
   
   
   # What I mean by extensible boundaries
   
   rule1
   rule2
   rule3
   
       # Boundary A:
       # distribution and ordering requirements are now enforced
   
   rule4
   rule5
   
       # Boundary B:
       # another optimizer invariant is now established
   
   rule6
   rule7
   ```
   
   If these boundaries can be represented explicitly, I think optimizer maintenance becomes much easier. Rules can clearly see which assumptions they are allowed to rely on, instead of those assumptions being hidden in rule ordering and implementation details.
   
   Projection pushdown is one concrete example of where another boundary could be useful. The important part is not this specific invariant, but that the same mechanism could express it naturally:
   
   ```text
   rule1
   
       # Before this point, projection has one canonical representation:
       #
       # ProjectionExec
       # -- child
   
   ProjectionPushDown
   
       # After this point, projection may either stay explicit:
       #
       # ProjectionExec(c1 + c2)
       # -- Join(output = [c1, c2])
       #
       # or be fused into an operator that supports it:
       #
       # Join(
       #     output = [c1, c2],
       #     projection = [c1],
       # )
   
   rule2
   rule3
   ```
   
   I suspect there are more hidden invariants like this in the optimizer today, so I think it is important that the mechanism can naturally support multiple boundaries rather than only this one distribution/ordering boundary.
   
   One additional nice-to-have is validation. I don't think this needs to be a major design decision, since it seems relatively easy to extend once boundaries are represented explicitly.
   
   For example, after a boundary establishes an invariant, we could validate it after every subsequent rule, at least in tests or debug builds:
   
   ```text
   EnsureRequirements
   
   Rule3
   ValidateEnsureRequirements
   
   Rule4
   ValidateEnsureRequirements
   ```
   
   That would make it much easier to identify exactly which rule first breaks the invariant, rather than discovering the violation only after the entire optimizer finishes.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] feat: run physical requirement enforcement first, as a PhysicalAnalyzer phase [datafusion]

Posted by "2010YOUY01 (via GitHub)" <gi...@apache.org>.
2010YOUY01 commented on PR #25688:
URL: https://github.com/apache/datafusion/pull/25688#issuecomment-6008341569

   > As neat an idea of having multiple classes of constraints that can be satisfied at different points, I think it makes it harder to reason about the optimizer as a whole and any OptimizerRule individually -- we would need some way for each rule to communicate what its expected input and output boundary was
   
   If I understand the assumptions behind the optimizer implementation correctly, adding more explicit constraints should make both understanding and implementation easier.
   
   Let me first restate the assumptions. I may be missing something here since I have less experience working on optimizers.
   
   ```txt
   # Assumptions for the physical optimizer
   
   DataFusion provides a default ordered list of optimizer rules.
   
   // Default rules
   rules = [
     rule1,
     rule2,
     rule3,
     rule4,
     ...
   ]
   
   - The default rules are only guaranteed to be safe when run in the prescribed order.
   
   - To disable specific behavior, use configuration options that define known-safe variations. For example,
     `set datafusion.optimizer.enable_distinct_aggregation_soft_limit = false`
     disables one specific aggregation optimization without arbitrarily modifying the rule pipeline.
   
   - (This sounds intimidating, but seems close to the current state):
     To implement an extension rule outside core, you need to understand the implicit constraints established by the surrounding default optimizer rules. Otherwise, changes in the default rules might break the plan.
     Currently, many of these constraints are only documented locally inside individual rules.
   
   # Future improvement direction
   
   Make these constraints easier to understand, express, and test.
   
   # Not intended usage
   
   Arbitrarily reorder/remove default rules downstream and expect the resulting optimizer pipeline to remain valid.
   
   // Reordered default rules mixed with extension rules
   rules = [
     rule3,
     extension_rule1,
     rule1,
     ...
   ]
   ```
   
   ## More constraints can simplify optimizer extensions
   
   If we explicitly exclude arbitrary reordering of the default optimizer rule list from the supported use case, then stronger constraints can simplify the optimizer:
   
   - **Simpler implementation:** each optimizer rule needs to handle fewer possible input states if its preconditions are known.
   - **Safer composition:** a rule knows which invariants it must preserve so that later rules continue to work correctly.
   
   ### Walkthrough
   
   In @zhuqi-lucas's use case:
   
   ```txt
   rules = [
     rule1,
     rule2,
     EnsureRequirements,
     rule3,
     extension_rule,
     ...
   ]
   ```
   
   If we treat the analyzer/optimizer split as a general boundary, the preconditions and postconditions of `extension_rule` become much clearer:
   
   - **Assumption:** input plans already satisfy their distribution/ordering requirements (`RepartitionExec`s have been inserted and the plan is runnable).
   - **Promise:** the rule must not invalidate those requirements. It either preserves the existing enforcement operators or re-runs `EnsureRequirements` internally when necessary.
   
   The simplification provided by this boundary is that a semantically equivalent plan has a canonical physical shape at this point in the optimizer.
   
   ```txt
   // plan1 and plan2 are semantically equivalent, but the analyzer boundary
   // guarantees that this rule only needs to handle plan1.
   //
   // This reduces the number of physical shapes the rule needs to reason about.
   
   // plan1
   AggregateExec(mode=final)
   --RepartitionExec
   ----AggregateExec(mode=partial)
   
   // plan2
   AggregateExec(mode=final)
   --AggregateExec(mode=partial)
   ```
   
   More constraints can reduce the problem space further. For example, if this extension rule needs to inspect projections, its implementation becomes simpler if projected plans also have one canonical shape at this boundary, rather than allowing several equivalent representations.
   
   ## Proceeding with this PR
   
   Now @zhuqi-lucas and @alamb seem more in favor of implementing the analyzer/optimizer split first, and treating a more general boundary mechanism as a follow-up.
   
   My current preference is to implement the more general optimizer boundary directly, to avoid introducing multiple mechanisms for the same underlying problem. That said, if I have misunderstood the assumptions above, this proposal would definitely need to be reworked.
   
   I'd like to hear your thoughts before deciding on the next step. If you also think a general boundary mechanism is a plausible direction, I can put together a PoC this week.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] feat: run physical requirement enforcement first, as a PhysicalAnalyzer phase [datafusion]

Posted by "zhuqi-lucas (via GitHub)" <gi...@apache.org>.
zhuqi-lucas commented on code in PR #25688:
URL: https://github.com/apache/datafusion/pull/25688#discussion_r4155684195


##########
datafusion/physical-optimizer/src/analyzer.rs:
##########
@@ -0,0 +1,153 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+//! Physical analyzer
+
+use std::sync::Arc;
+
+use crate::ensure_requirements::{EnforceDistribution, EnforceSorting};
+use crate::output_requirements::OutputRequirements;
+
+// Re-export from this module for convenience.
+pub use datafusion_session::PhysicalAnalyzerRule;
+
+/// A rule-based physical analyzer.
+///
+/// Analyzer rules make the plan *valid*: they enforce the invariants every
+/// operator declares (distribution, ordering) rather than making the plan
+/// faster, mirroring the logical layer's `Analyzer`/`Optimizer` split. The
+/// default planner runs the whole analyzer phase before the
+/// [`PhysicalOptimizer`](crate::optimizer::PhysicalOptimizer) phase, so every
+/// optimizer rule can assume it receives a valid plan; see
+/// [`PhysicalAnalyzerRule`] for details.
+#[derive(Clone, Debug)]
+pub struct PhysicalAnalyzer {
+    /// All rules to apply
+    pub rules: Vec<Arc<dyn PhysicalAnalyzerRule + Send + Sync>>,
+}
+
+impl Default for PhysicalAnalyzer {
+    fn default() -> Self {
+        Self::new()
+    }
+}
+
+impl PhysicalAnalyzer {
+    /// Create a new analyzer using the recommended list of rules
+    pub fn new() -> Self {
+        // All enforcement runs here, first, as the analyzer phase: it makes the
+        // plan *valid* (distribution first, then ordering) before any optimizer
+        // rule sees it, mirroring the logical Analyzer/Optimizer split. The
+        // optimizer rules that change these requirements (`JoinSelection`,
+        // `WindowTopN`, `FilterPushdown`) re-establish validity themselves, so
+        // enforcement is not repeated as an optimizer pass. The sort
+        // *optimizations* (`OptimizeSorts`) are not enforcement and stay in the
+        // optimizer phase.
+        let rules: Vec<Arc<dyn PhysicalAnalyzerRule + Send + Sync>> = vec![
+            // Establish the output-requirement boundary first, so enforcement can
+            // see it (parallelize top-level scans below it, preserve the query's
+            // final ordering). The matching remove pass runs late in the optimizer.
+            Arc::new(OutputRequirements::new_add_mode()),
+            Arc::new(EnforceDistribution::new()),

Review Comment:
   Thanks @alamb. So that a rule which disturbs only one of them can call the smallest repair it needs rather than a full pass: `JoinSelection` and `FilterPushdown` re-establish distribution only, since neither changes any operator ordering.
   
   On your related worry about the regression, I profiled it and the split is not where it goes. Across the two `enforce_distribution_requirements` calls per plan on tpch q21: phase 0 interleave normalisation 2.3 us, phase 1 join-key reordering 6.6 us, phase 2a distribution 292 us. Combining the two rules again would not recover that, since distribution and sorting are separate tree walks inside `EnsureRequirements` today as well. I will post the full attribution on the PR.



##########
datafusion/sqllogictest/test_files/window_topn.slt:
##########
@@ -1575,11 +1575,9 @@ logical_plan
 physical_plan
 01)ProjectionExec: expr=[c1@0 as c1, c2@1 as c2, row_number() PARTITION BY [t.c1] ORDER BY [t.c2 DESC NULLS FIRST] RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW@2 as rn]
 02)--BoundedWindowAggExec: wdw=[row_number() PARTITION BY [t.c1] ORDER BY [t.c2 DESC NULLS FIRST] RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW: Field { "row_number() PARTITION BY [t.c1] ORDER BY [t.c2 DESC NULLS FIRST] RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW": UInt64 }, frame: RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW], mode=[Sorted]
-03)----SortPreservingMergeExec: [c1@0 ASC NULLS LAST, c2@1 DESC]
-04)------SortExec: expr=[c1@0 ASC NULLS LAST, c2@1 DESC], preserve_partitioning=[true]
-05)--------PartitionedTopKExec: fn=row_number, fetch=1, partition=[c1@0], order=[c2@1 DESC]
-06)----------RepartitionExec: partitioning=Hash([c1@0], 5), input_partitions=1
-07)------------DataSourceExec: partitions=1, partition_sizes=[1]
+03)----PartitionedTopKExec: fn=row_number, fetch=1, partition=[c1@0], order=[c2@1 DESC]

Review Comment:
   Thanks @alamb. It goes the other way, parallelism increases here.
   
   `SortPreservingMergeExec` outputs a single partition, so before this change `BoundedWindowAggExec` ran on one partition. Now it sits directly on the 5-way hash repartition and runs across all five. The `SortExec` and the merge became redundant rather than being dropped: `PartitionedTopKExec` carries `partition=[c1] order=[c2 DESC]`, so it already emits rows grouped by `c1` and ordered by `c2` descending, and hashing on `c1` keeps each group inside one partition, which is what `mode=[Sorted]` needs.
   
   It passes `SanityCheckPlan` and the query results are unchanged.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] feat: run physical requirement enforcement first, as a PhysicalAnalyzer phase [datafusion]

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on PR #25688:
URL: https://github.com/apache/datafusion/pull/25688#issuecomment-6233028328

   I think given the discussion and complexity here this work deserves writing up as an EPIC -- if you agree I will write up something that tries to explain the current situation, so we can be sure we are aligned


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] feat: run physical requirement enforcement first, as a PhysicalAnalyzer phase [datafusion]

Posted by "zhuqi-lucas (via GitHub)" <gi...@apache.org>.
zhuqi-lucas commented on PR #25688:
URL: https://github.com/apache/datafusion/pull/25688#issuecomment-5934038705

   run benchmark sql_planner
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] feat: run physical requirement enforcement first, as a PhysicalAnalyzer phase [datafusion]

Posted by "zhuqi-lucas (via GitHub)" <gi...@apache.org>.
zhuqi-lucas commented on PR #25688:
URL: https://github.com/apache/datafusion/pull/25688#issuecomment-5932417602

   > I think the structure of this PR looks good in general. I worry about:
   >
   > 1. Plan changes -- they don't all look good to me
   > 2. Performance regression (can we perhaps combine EnforceDistribution and EnforceSort again and find some other ways to make OptimizeSort faster?)
   
   Thanks @alamb. On 2, I profiled it, and I do not think combining them back is the lever. Local A/B on tpch q21, merge-base `e1aa7d9` against this branch, same machine:
   
   | | merge-base | this branch |
   |---|---|---|
   | end to end per plan | 1173.2 us | 1383.2 us |
   | `join_selection` | 80.7 us | **252.9 us** |
   | `EnsureRequirements` | 133.4 us | moved to the analyzer |
   | `OptimizeSorts` | - | 29.8 us |
   
   The optimizer-phase delta is `join_selection` +172.2, `EnsureRequirements` -133.4, `OptimizeSorts` +29.8. So the extra time is inside `JoinSelection`, and it is the `enforce_distribution_requirements` call it makes after rewriting. That function runs **twice per plan** here and is 22% of planning. Splitting the two rules is not where it went: on merge-base `EnsureRequirements` already does distribution and sorting as two separate bottom-up walks, so merging them removes no traversal, and `OptimizeSorts` at 29.8 us cannot account for a 210 us regression even at zero.
   
   Looking at the three rules that self-repair in this PR, they are not the same case:
   
   | rule | repairs | why it touches enforcement | where it belongs |
   |---|---|---|---|
   | `JoinSelection` | distribution | declares nothing until it runs | **before** enforcement |
   | `FilterPushdown` | distribution | see below, two reasons | **before** enforcement |
   | `WindowTopN` | distribution and ordering | needs the lowered plan to do its job | **after**, repair is legitimate |
   
   `JoinSelection`: before it runs, a hash join's mode is `PartitionMode::Auto`, which declares `UnspecifiedDistribution` for its children and `UnknownPartitioning` for its output. Enforcement running first therefore does nothing for joins. The plan only acquires unsatisfied requirements once a mode is picked, and the repair then re-derives them over the whole tree, on a tree the first pass already expanded.
   
   `FilterPushdown` is coupled to enforcement in two separate ways, and I think only one of them is real. First, pushing a predicate into a source rebuilds `DataSourceExec`, and the rebuilt node loses the file grouping enforcement had established: in `repartition_scan.slt` 4 file groups become 2 when I remove the repair. That looks like a defect in the rebuild rather than an ordering constraint, and fixing it would decouple the two. Second, pushing a predicate changes the statistics the distribution decisions read, a source's row count flips Exact to Inexact, which changes whether its scan is parallelized. That one is a genuine dependency and is why master runs `FilterPushdown` before `EnsureRequirements`.
   
   `WindowTopN` is the one that earns the contract: it rebuilds the window over a hash-partitioned `PartitionedTopKExec`, so it needs enforcement to have run, and it genuinely disturbs both distribution and ordering. It is also rare enough that it does not show up in the q21 numbers at all.
   
   I tried moving `JoinSelection` ahead of enforcement rather than repairing after it. q21 goes from **1.3973 ms to 1.1856 ms** against the merge-base 1.2312 ms, so faster than before this PR rather than merely recovered. The `issue_21826` regression test still passes with only the `InterleaveExec` normalisation kept inside `JoinSelection`, which is the part that actually fixes that panic and holds in any order.
   
   To be explicit, that makes `JoinSelection` an analyzer rule rather than an optimizer one. It is what you floated earlier in this review, "put `JoinSelection` as an analyzer rule (as strange as that is)", and I think it is less strange than it sounds: `PartitionMode::Auto` is not executable at all, `HashJoinExec::execute` returns a plan error on it, so resolving the mode is a correctness step under the definition you gave.
   
   Where I am less sure, and where @2010YOUY01's staging seems relevant: if both `JoinSelection` and `FilterPushdown` have to precede enforcement while `WindowTopN`, `OptimizeSorts` and `TopKRepartition` have to follow it, then a plain analyzer-then-optimizer split does not express the chain, since `FilterPushdown` is an optimization by any reading. Either the analyzer phase ends up holding rules that are not about correctness, or the split wants a different criterion than correctness, something closer to "determines requirements" versus "consumes them". I would rather measure the first part and let the naming follow than argue it up front, but I would like to know how you both read that boundary before I rework this.
   
   On 1, I replied inline about the `window_topn` plan, where parallelism goes up rather than down. Happy to walk through the rest of the plan changes one at a time.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] feat: run physical requirement enforcement first, as a PhysicalAnalyzer phase [datafusion]

Posted by "zhuqi-lucas (via GitHub)" <gi...@apache.org>.
zhuqi-lucas commented on PR #25688:
URL: https://github.com/apache/datafusion/pull/25688#issuecomment-5930852416

   Thanks @alamb and @2010YOUY01 for the careful reads.
   
   **Our use case is planning performance.**
   
   We maintain a downstream engine on DataFusion with a number of custom physical rewrites interleaved into the optimizer chain, among them materialized view matching and a distributed execution rule that wraps subtrees for remote execution. Because each of them can invalidate requirements the plan had already satisfied, several physical rules repeat in our chain, `EnsureRequirements` six times in a single planning pass.
   
   Most of those repeats return the plan unchanged and still pay the full cost. Measured on a snapshot endpoint over a 34-node plan: physical optimization is **118.3 ms across 36 rule calls**, of which `EnsureRequirements` alone is **93.9 ms, 79.4%**. **Four of those six passes are byte-identical no-ops**, and 28 of 35 rule passes in total leave the plan untouched.
   
   So what we want is a fingerprint of the physical plan, so that a rule handed an input it has already been observed to leave unchanged is skipped instead of re-run. That is #25356. On the same chain it takes `EnsureRequirements` from 6 executions to 3 and physical optimization from **87.0 ms to 48.5 ms**, with the rendered plans byte-identical.
   
   For context on how this PR came about: @alamb proposed the phase split as an alternate strategy while reviewing #25356, with the goal of being able to rerun the optimizer rules to convergence. I think the two are complementary rather than exclusive. The fingerprint does not require any reordering of rules, it does not depend on rules being idempotent, and it covers repetition that a downstream chain authors, which the upstream rule list cannot see. For our use case specifically that last part is what matters, since our repeats come from our own rewrites rather than from the upstream ordering.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] feat: extract enforcement into a PhysicalAnalyzerRule phase (prereq for #25572) [datafusion]

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on PR #25688:
URL: https://github.com/apache/datafusion/pull/25688#issuecomment-5811572752

   > an enforce -> optimize -> enforce alternation (enforcement still runs on both sides, since rules depend on it in each direction), with each enforcement pass gated on check_invariants so one whose requirements already hold is skipped by a cheap semantic check instead of a full re-derivation — repeated enforcement stays correct but cheap. Happy to capture all of this (topology, the invariant gate, and the deprecated shim) in an epic so this PR stays a small prerequisite — I can open it if you agree.
   
   I think we should consider aiming eventually for the invariant that each PhysicalOptimzierRule leaves the plan in a valid shape (so we don't have run multiple enforcement passes). That would be the simplest to reason about -- and would let each PhysicalOptimizerRule assume it got a valid plan as input which would also likely simplify the logic
   
   I am not sure how far away from this invariant the existing rules are
   
   > repeated enforcement stays correct but cheap
   
   I think it would be even cheaper if we didn't have to re-run Enforcement


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] feat: extract enforcement into a PhysicalAnalyzerRule phase (prereq for #25572) [datafusion]

Posted by "zhuqi-lucas (via GitHub)" <gi...@apache.org>.
zhuqi-lucas commented on PR #25688:
URL: https://github.com/apache/datafusion/pull/25688#issuecomment-5810550610

   @alamb this is the first step from #25355 — `EnsureRequirements` is pulled out into a new `PhysicalAnalyzerRule` trait, and the planner runs analyzers then optimizers.
   
   To keep it a pure refactor I run the analyzer phase at `EnsureRequirements`' current position (right before `CombinePartialFinalAggregate`) rather than strictly first: running it before `JoinSelection` yields an invalid single-partition broadcast join, so this way every plan and the full sqllogictest suite stay unchanged.
   
   Would appreciate an early look at the trait / API shape before I build the convergence loop on top of it.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] feat: run physical requirement enforcement first, as a PhysicalAnalyzer phase [datafusion]

Posted by "zhuqi-lucas (via GitHub)" <gi...@apache.org>.
zhuqi-lucas commented on PR #25688:
URL: https://github.com/apache/datafusion/pull/25688#issuecomment-6210771932

   Thanks for prototyping this! The `InputRequirementsSatisfied` region starts exactly where #25688 draws the analyzer/optimizer boundary, so the two look complementary to me.
   
   One concern from a downstream pipeline: Atlas rebuilds the list from `physical_optimizers()`, inserts rules by anchor, and calls `with_physical_optimizer_rules`, which silently drops all regions. An API to insert rules next to a named rule while keeping the markers would help extensions actually get these checks.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] feat: run physical requirement enforcement first, as a PhysicalAnalyzer phase [datafusion]

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on PR #25688:
URL: https://github.com/apache/datafusion/pull/25688#issuecomment-6233004719

   > In https://github.com/apache/datafusion/pull/26360, I think our disagreement is whether more explicit invariants make maintenance easier. I think they do, while @alamb believes the opposite.
   
   In my mind, my position is more like "removing as many hidden assumptions makes maintenance easier" (as in I feel we should remove the hidden invariants rather than make them visible)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] feat: run physical requirement enforcement first, as a PhysicalAnalyzer phase [datafusion]

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on PR #25688:
URL: https://github.com/apache/datafusion/pull/25688#issuecomment-6225378698

   > Thanks @2010YOUY01 for prototyping this! The `InputRequirementsSatisfied` region starts exactly where #25688 draws the analyzer/optimizer boundary, so the two look complementary to me.
   > 
   > One concern from a downstream pipeline: our internal engine(Atlas) rebuilds the list from `physical_optimizers()`, inserts rules by anchor, and calls `with_physical_optimizer_rules`, which silently drops all regions. An API to insert rules next to a named rule while keeping the markers would help extensions actually get these checks.
   
   I agree -- thank you @2010YOUY01 
   
   I also have some concerns that I wrote about in https://github.com/apache/datafusion/pull/26360#pullrequestreview-5554104569


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] feat: run physical requirement enforcement first, as a PhysicalAnalyzer phase [datafusion]

Posted by "2010YOUY01 (via GitHub)" <gi...@apache.org>.
2010YOUY01 commented on PR #25688:
URL: https://github.com/apache/datafusion/pull/25688#issuecomment-6228184562

   In https://github.com/apache/datafusion/pull/26360, I think our disagreement is whether more explicit invariants make maintenance easier. I think they do, while @alamb believes the opposite. Since I've dealt with fewer optimizer-related problems, I'll trust your judgment for now, though I'm not fully convinced yet. I'll perhaps look for more problem-specific, compelling invariant regions in the future.
   
   Regarding the next steps for the analyzer/optimizer split, I'd appreciate some clarification. As I understand it, this PR only separates the rules into phases, without actually enforcing the following invariant:
   
   ```
   After `EnforceDistribution` (or after the analyzer phase), all subsequent rules must preserve distribution/ordering requirements, either by:
   - Recognizing `RepartitionExec` nodes and preserving them.
   - Reapplying `EnforceDistribution` internally if they break those requirements.
   ```
   
   For now, this invariant is only documented as a guideline, with automatic validation potentially added in the future.
   
   If we want to enforce it, I think we need a machinery with similar complexity to https://github.com/apache/datafusion/pull/26360? If so, perhaps we could try to make it extensible to other invariant regions in the future.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] feat: run physical requirement enforcement first, as a PhysicalAnalyzer phase [datafusion]

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on PR #25688:
URL: https://github.com/apache/datafusion/pull/25688#issuecomment-6014930191

   >   To implement an extension rule outside core, you need to understand the implicit constraints established by the surrounding default optimizer rules. Otherwise, changes in the default rules might break the plan.
   >   Currently, many of these constraints are only documented locally inside individual rules.
   
   In my mind, the constraints are not imposed by the rules themselves, but are a property of the ExecutionPlan nodes -- there should be clear semantics of what each ExecutionPlan does and what is required of its input/output
   
   As long as these constraints are satisfied, then an OptimizerRule should be able to rearrange the plan however it sees fit as long as the resulting plan still produces the same output
   
   What is not clear to me is that there is any way to encode some sort of optimization property (e.g that limits have been pushed down) that gets tighter after each pass
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] feat: run physical requirement enforcement first, as a PhysicalAnalyzer phase [datafusion]

Posted by "2010YOUY01 (via GitHub)" <gi...@apache.org>.
2010YOUY01 commented on PR #25688:
URL: https://github.com/apache/datafusion/pull/25688#issuecomment-6187164494

   I opened 
   - https://github.com/apache/datafusion/pull/26360
   
   I think this mechanism can achieve the end goal of [https://github.com/apache/datafusion/issues/25572](https://github.com/apache/datafusion/issues/25572), while being more expressive than the analyzer/optimizer split approach (e.g., allowing us to temporarily relax plan-validity invariants during optimization).
   
   With this PoC, an analyzer/optimizer split with iterative re-optimization until convergence could look like this:
   
   ```rust
   pub fn new() -> Self {
       use PhysicalOptimizerStep as Step;
   
       let steps = vec![
           // ----------------
           // Analyzer Phase
           // ----------------
           Step::Begin(Arc::new(NoEmbeddedProjections)),
           Step::Rule(Arc::new(OutputRequirements::new_add_mode())),
           // ...
           Step::Rule(Arc::new(JoinSelection::new())),
           Step::Begin(Arc::new(HashJoinModesResolved)),
           // ...
           Step::Rule(Arc::new(EnsureRequirements::new())),
   
           // --------------------------------------
           // Optimizer Phase, with iterative re-optimization
           // --------------------------------------
           Step::Loop {
               max_passes: 3,
               steps: vec![
                   Step::Rule(Arc::new(ProjectionPushdown::new())),
                   // ...
                   Step::Rule(Arc::new(SanityCheckPlan::new())),
               ],
           },
   
           Step::End(InputRequirementsSatisfied.name()),
           Step::End(HashJoinModesResolved.name()),
       ];
   
       Self::with_steps(steps)
   }
   ```
   
   The tradeoff, as I see it, is:
   
   - **Analyzer/optimizer split:** More intuitive, but hidden constraints remain implicit.
   - **Invariant regions:** More expressive, but with a steeper learning curve.
   
   I have to admit that the PoC approach looks confusing at first glance, but I believe it could make long-term maintenance easier once we get used to it. Overall, I'm positive about this direction after prototyping it.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] feat: run physical requirement enforcement first, as a PhysicalAnalyzer phase [datafusion]

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on PR #25688:
URL: https://github.com/apache/datafusion/pull/25688#issuecomment-5930143672

   checking it out


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] feat: run physical requirement enforcement first, as a PhysicalAnalyzer phase [datafusion]

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on PR #25688:
URL: https://github.com/apache/datafusion/pull/25688#issuecomment-5936142091

   > The optimizer-phase delta is join_selection +172.2, EnsureRequirements -133.4, OptimizeSorts +29.8. So the extra time is inside JoinSelection, and it is the enforce_distribution_requirements call it makes after rewriting. That function runs twice per plan here and is 22% of planning. Splitting the two rules is not where it went: on merge-base EnsureRequirements already does distribution and sorting as two separate bottom-up walks, so merging them removes no traversal, and OptimizeSorts at 29.8 us cannot account for a 210 us regression even at zero.
   
   So  one way to bring back performance then is to update JoinSelection so it doesn't have to call `enforce_distribution_requirements` (it can fix the distribution internally if it changes the plan tree). 
   
   Sorry I find it really hard to read large / wall of comments, so you may have already said this farther down
   
   
   > To be explicit, that makes JoinSelection an analyzer rule rather than an optimizer one. It is what you floated earlier in this review, "put JoinSelection as an analyzer rule (as strange as that is)", and I think it is less strange than it sounds: PartitionMode::Auto is not executable at all, HashJoinExec::execute returns a plan error on it, so resolving the mode is a correctness step under the definition you gave.
   
   I guess what I am advocating is trying to introduce PhysicalAnalyzerRule with the smallest number of other changes as possible.
   
   For example, if we had to initially treat `JoinSelection` as a `PhysicalAnalyzerRule` because it produces invalid plans we could do that initially (and keep the same effective ordering of passes as today, but split between Analyzer/Optimizer)
   
   Then in follow on PRs we could explore how to move JoinSelection into the OptimizerRules (e.g. by ensuring that it doesn't make plans invalid)
   
   Those steps I think are more self contained and easier to review


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] feat: run physical requirement enforcement first, as a PhysicalAnalyzer phase [datafusion]

Posted by "zhuqi-lucas (via GitHub)" <gi...@apache.org>.
zhuqi-lucas commented on code in PR #25688:
URL: https://github.com/apache/datafusion/pull/25688#discussion_r4155680202


##########
datafusion/core/tests/physical_optimizer/ensure_requirements.rs:
##########
@@ -1560,3 +1564,222 @@ fn test_sort_pushed_below_limit_with_skip_keeps_skip_rows() -> Result<()> {
     ");
     Ok(())
 }
+
+// ========================================================================
+// Decomposition tests: `EnsureRequirements` was split into three rules

Review Comment:
   Thanks @alamb. No, it is not. Removing the PR history from that comment.



##########
datafusion/core/tests/physical_optimizer/filter_pushdown.rs:
##########
@@ -134,7 +134,8 @@ fn test_pushdown_volatile_functions_not_allowed() {
       output:
         Ok:
           - FilterExec: a@0 = random()
-          -   DataSourceExec: file_groups={1 group: [[test.parquet]]}, projection=[a, b, c], file_type=test, pushdown_supported=true
+          -   RepartitionExec: partitioning=RoundRobinBatch(4), input_partitions=1

Review Comment:
   Thanks @alamb. The snapshots embed `target_partitions`, which defaults to the number of CPUs, so they rendered differently on a 12-core dev machine and 4-core CI. I pinned it to 4 in the test helper and re-accepted the snapshots. Nothing about the pushdown behaviour changed.



##########
datafusion/physical-optimizer/src/ensure_requirements/mod.rs:
##########
@@ -176,6 +177,302 @@ impl EnsureRequirements {
     }
 }
 
+/// Phases 0-2a: make the plan valid with respect to **distribution**
+/// requirements only (normalize interleave, join-key reordering, distribution
+/// enforcement). Split from ordering enforcement so it can be used on its own:
+/// the [`EnforceDistribution`] analyzer rule runs it as the first enforcement
+/// step, and rules that change only distribution (`JoinSelection`,
+/// `FilterPushdown`) call it directly to re-establish the partitioning their
+/// rewrite disturbed, without touching ordering.
+pub fn enforce_distribution_requirements(
+    plan: Arc<dyn ExecutionPlan>,
+    context: &dyn PhysicalOptimizerContext,
+) -> Result<Arc<dyn ExecutionPlan>> {
+    let config = context.config_options();
+    // Phase 0: Normalize `InterleaveExec` back to `UnionExec` (top-down).
+    // Interleaves are distribution artifacts of Phase 2, which re-derives
+    // them from the children's final partitioning. Keeping them would
+    // fail as soon as a child loses the partitioning they depend on.
+    use super::enforce_distribution::replace_interleave_with_union;
+    let plan = plan.transform_down(replace_interleave_with_union).data()?;
+
+    // Phase 1: Join key reordering (top-down, from EnforceDistribution)
+    use super::enforce_distribution::{
+        PlanWithKeyRequirements, adjust_input_keys_ordering,
+    };
+    let top_down_join_key_reordering = config.optimizer.top_down_join_key_reordering;
+    let plan = if top_down_join_key_reordering {
+        let ctx = PlanWithKeyRequirements::new_default(plan);
+        ctx.transform_down(adjust_input_keys_ordering).data()?.plan
+    } else {
+        use super::enforce_distribution::reorder_join_keys_to_inputs;
+        plan.transform_up(|p| Ok(Transformed::yes(reorder_join_keys_to_inputs(p)?)))
+            .data()?
+    };
+
+    // Phase 2a: Distribution enforcement (bottom-up)
+    use super::enforce_distribution::{
+        DistributionContext, ensure_distribution_with_stats,
+    };
+    let dist_ctx = DistributionContext::new_default(plan);
+    // Share one statistics context across the whole distribution pass so each
+    // subtree's statistics are computed once instead of once per ancestor.
+    // Build it from the session's statistics registry so registered providers
+    // are consulted (an empty registry, the default, is unchanged behavior).
+    // `StatsCache` is keyed by raw node pointer, so reset it after any node
+    // whose plan pointer actually changed: a rewrite can free a cached node
+    // and a later allocation could reuse its address. A node that makes no
+    // change cannot free anything, so the cache safely persists across the
+    // no-op nodes that dominate a deep plan.
+    let stats_ctx = match context.statistics_registry() {
+        Some(registry) => StatisticsContext::new_with_registry(registry.clone()),
+        None => StatisticsContext::new(),
+    };
+    let dist_ctx = dist_ctx
+        .transform_up(|ctx| {
+            let before = Arc::clone(&ctx.plan);
+            let result = ensure_distribution_with_stats(ctx, config, &stats_ctx)?;
+            if !Arc::ptr_eq(&before, &result.data.plan) {
+                stats_ctx.reset_cache();
+            }
+            Ok(result)
+        })
+        .data()?;
+    Ok(dist_ctx.plan)
+}
+
+/// Phase 2b: enforce **ordering** requirements by inserting `SortExec`s on a
+/// distribution-fixed plan (bottom-up). This is the enforcement half that is
+/// *not* idempotent, so in the default pipeline it runs exactly once via the
+/// [`EnforceSorting`] analyzer rule. Exposed as a free function so the combined
+/// [`enforce_requirements`] (used by rules that disturb ordering, and by the
+/// [`EnsureRequirements`] compatibility shim) can reuse it.
+pub fn enforce_sorting_requirements(
+    plan: Arc<dyn ExecutionPlan>,
+) -> Result<Arc<dyn ExecutionPlan>> {
+    use super::enforce_sorting::{PlanWithCorrespondingSort, ensure_sorting};
+    let sort_ctx = PlanWithCorrespondingSort::new_default(plan);
+    let sort_ctx = sort_ctx.transform_up(ensure_sorting)?.data;
+    Ok(sort_ctx.plan)
+}
+
+/// Phases 0-2: full requirement enforcement (distribution via
+/// [`enforce_distribution_requirements`], then sorting via
+/// [`enforce_sorting_requirements`]). The default pipeline uses the
+/// finer-grained [`EnforceDistribution`] / [`EnforceSorting`] rules instead;
+/// this stays for the [`EnsureRequirements`] compatibility shim.
+pub fn enforce_requirements(
+    plan: Arc<dyn ExecutionPlan>,
+    context: &dyn PhysicalOptimizerContext,
+) -> Result<Arc<dyn ExecutionPlan>> {
+    let plan = enforce_distribution_requirements(plan, context)?;
+    enforce_sorting_requirements(plan)
+}
+
+/// Phase 3: sort and distribution *optimizations* that make an already-valid
+/// plan faster (parallelize sorts, order-preserving variants, sort pushdown,
+/// partial sort). Split out of enforcement so it can run in the optimizer phase,
+/// after other optimizer rules (such as `WindowTopN`) have produced the
+/// operators it parallelizes. Exposed as the [`OptimizeSorts`] rule.
+pub fn optimize_sorts(
+    plan: Arc<dyn ExecutionPlan>,
+    config: &ConfigOptions,
+) -> Result<Arc<dyn ExecutionPlan>> {
+    // 3a: Parallelize sorts (Coalesce+Sort → SPM+Sort)
+    use super::enforce_sorting::{
+        PlanWithCorrespondingCoalescePartitions, parallelize_sorts,
+        replace_with_partial_sort,
+    };
+    let plan = if config.optimizer.repartition_sorts {
+        let ctx = PlanWithCorrespondingCoalescePartitions::new_default(plan);
+        ctx.transform_up(parallelize_sorts).data()?.plan
+    } else {
+        plan
+    };
+
+    // 3b: Order-preserving variants
+    use super::enforce_sorting::replace_with_order_preserving_variants::{
+        OrderPreservationContext, replace_with_order_preserving_variants,
+    };
+    let ctx = OrderPreservationContext::new_default(plan);
+    let plan = ctx
+        .transform_up(|c| replace_with_order_preserving_variants(c, false, true, config))
+        .data()?
+        .plan;
+
+    // 3c: Sort pushdown (distribution-aware)
+    use super::enforce_sorting::sort_pushdown::{
+        SortPushDown, assign_initial_requirements, pushdown_sorts,
+    };
+    let mut sort_pushdown = SortPushDown::new_default(plan);
+    assign_initial_requirements(&mut sort_pushdown);
+    let adjusted = pushdown_sorts(sort_pushdown)?;
+
+    // 3d: Partial sort
+    adjusted
+        .plan
+        .transform_up(|p| Ok(Transformed::yes(replace_with_partial_sort(p)?)))
+        .data()
+}
+
+/// Enforces **distribution** requirements (Phases 0-2a) via
+/// [`enforce_distribution_requirements`]. In the default pipeline it runs as the
+/// [`PhysicalAnalyzerRule`] that makes the plan distribution-valid before the
+/// optimizer rules see it. It is idempotent enough to run more than once, and
+/// still implements [`PhysicalOptimizerRule`] so downstream pipelines that splice
+/// it in by position keep working; the default optimizer rules that change
+/// distribution (`JoinSelection`, `FilterPushdown`) instead call
+/// [`enforce_distribution_requirements`] directly to re-establish it themselves.
+#[derive(Default, Debug)]
+pub struct EnforceDistribution {}
+
+impl EnforceDistribution {
+    #[expect(missing_docs)]
+    pub fn new() -> Self {
+        Self {}
+    }
+}
+
+impl PhysicalOptimizerRule for EnforceDistribution {
+    fn optimize(
+        &self,
+        plan: Arc<dyn ExecutionPlan>,
+        config: &ConfigOptions,
+    ) -> Result<Arc<dyn ExecutionPlan>> {
+        enforce_distribution_requirements(plan, &ConfigOnlyContext::new(config))
+    }
+
+    fn optimize_with_context(
+        &self,
+        plan: Arc<dyn ExecutionPlan>,
+        context: &dyn PhysicalOptimizerContext,
+    ) -> Result<Arc<dyn ExecutionPlan>> {
+        enforce_distribution_requirements(plan, context)
+    }
+
+    fn name(&self) -> &str {
+        "EnforceDistribution"
+    }
+
+    fn schema_check(&self) -> bool {
+        true
+    }
+}
+
+impl PhysicalAnalyzerRule for EnforceDistribution {
+    fn analyze(
+        &self,
+        plan: Arc<dyn ExecutionPlan>,
+        config: &ConfigOptions,
+    ) -> Result<Arc<dyn ExecutionPlan>> {
+        enforce_distribution_requirements(plan, &ConfigOnlyContext::new(config))
+    }
+
+    fn analyze_with_context(
+        &self,
+        plan: Arc<dyn ExecutionPlan>,
+        context: &dyn PhysicalOptimizerContext,
+    ) -> Result<Arc<dyn ExecutionPlan>> {
+        enforce_distribution_requirements(plan, context)
+    }
+
+    fn name(&self) -> &str {
+        "EnforceDistribution"
+    }
+
+    fn schema_check(&self) -> bool {
+        true
+    }
+}
+
+/// Enforces **ordering** requirements (Phase 2b) via
+/// [`enforce_sorting_requirements`]. Not idempotent, so it runs exactly once in
+/// the default pipeline, as the ordering-enforcement [`PhysicalAnalyzerRule`]
+/// (after [`EnforceDistribution`], on the distribution-fixed plan). The later
+/// optimizer rules that disturb ordering (`WindowTopN`) re-establish it
+/// themselves via [`enforce_requirements`].
+#[derive(Default, Debug)]
+pub struct EnforceSorting {}
+
+impl EnforceSorting {
+    #[expect(missing_docs)]
+    pub fn new() -> Self {
+        Self {}
+    }
+}
+
+impl PhysicalOptimizerRule for EnforceSorting {

Review Comment:
   Thanks @alamb. It already is: the default analyzer list is `[OutputRequirements, EnforceDistribution, EnforceSorting]`, so sorting is enforced in the analyzer phase, right after distribution. This `PhysicalOptimizerRule` impl is only kept so custom rule lists that register `EnforceSorting` by position keep working. I will make that clearer in the docs, since you had to ask.



##########
datafusion/physical-optimizer/src/optimizer.rs:
##########
@@ -115,25 +118,12 @@ impl PhysicalOptimizer {
             // window's declared ordering without pattern-matching a SortExec)
             // and before ProjectionPushdown (which embeds projections into FilterExec).
             Arc::new(WindowTopN::new()),
-            // Ensures each input plan satisfies the distribution and ordering
-            // requirements declared by `ExecutionPlan::required_input_distribution`
-            // and `ExecutionPlan::required_input_ordering`.
-            //
-            // If the requirements are already satisfied, this rule leaves the plan
-            // unchanged. For example, it does not add sorting when the input is a
-            // file scan whose existing order already satisfies the required ordering.
-            // Otherwise, this rule inserts the necessary repartitioning and sorting
-            // operators.
-            //
-            // This used to be implemented as two separate rules: `EnforceDistribution`
-            // and `EnforceSorting`. It is now a single idempotent rule that decides
-            // distribution and sorting together in one bottom-up pass, so the
-            // `pushdown_sorts` step no longer breaks distribution invariants set
-            // earlier in the pipeline. See the module-level doc on
-            // [`EnsureRequirements`](crate::ensure_requirements) for the per-phase
-            // breakdown, and <https://github.com/apache/datafusion/issues/21973>
-            // for the original failure mode.
-            Arc::new(EnsureRequirements::new()),
+            // All enforcement (distribution and ordering) runs first in the

Review Comment:
   Thanks @alamb, agreed. Removing.



##########
datafusion/physical-optimizer/src/optimizer.rs:
##########
@@ -89,9 +89,12 @@ impl PhysicalOptimizer {
         //   queries, and will likely increase the optimization time. Please extend
         //   existing rules when possible, rather than adding a new rule.
         let rules: Vec<Arc<dyn PhysicalOptimizerRule + Send + Sync>> = vec![
-            // If there is a output requirement of the query, make sure that
-            // this information is not lost across different rules during optimization.
-            Arc::new(OutputRequirements::new_add_mode()),
+            // The output-requirement boundary (`OutputRequirements` add mode) and

Review Comment:
   Thanks @alamb, agreed. Removing.



##########
datafusion/physical-optimizer/src/analyzer.rs:
##########
@@ -0,0 +1,153 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+//! Physical analyzer
+
+use std::sync::Arc;
+
+use crate::ensure_requirements::{EnforceDistribution, EnforceSorting};
+use crate::output_requirements::OutputRequirements;
+
+// Re-export from this module for convenience.
+pub use datafusion_session::PhysicalAnalyzerRule;
+
+/// A rule-based physical analyzer.
+///
+/// Analyzer rules make the plan *valid*: they enforce the invariants every
+/// operator declares (distribution, ordering) rather than making the plan
+/// faster, mirroring the logical layer's `Analyzer`/`Optimizer` split. The
+/// default planner runs the whole analyzer phase before the
+/// [`PhysicalOptimizer`](crate::optimizer::PhysicalOptimizer) phase, so every
+/// optimizer rule can assume it receives a valid plan; see
+/// [`PhysicalAnalyzerRule`] for details.
+#[derive(Clone, Debug)]
+pub struct PhysicalAnalyzer {
+    /// All rules to apply
+    pub rules: Vec<Arc<dyn PhysicalAnalyzerRule + Send + Sync>>,
+}
+
+impl Default for PhysicalAnalyzer {
+    fn default() -> Self {
+        Self::new()
+    }
+}
+
+impl PhysicalAnalyzer {
+    /// Create a new analyzer using the recommended list of rules
+    pub fn new() -> Self {
+        // All enforcement runs here, first, as the analyzer phase: it makes the

Review Comment:
   Thanks @alamb, agreed. Removing and leaving the explanation in one place.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] feat: run physical requirement enforcement first, as a PhysicalAnalyzer phase [datafusion]

Posted by "2010YOUY01 (via GitHub)" <gi...@apache.org>.
2010YOUY01 commented on PR #25688:
URL: https://github.com/apache/datafusion/pull/25688#issuecomment-6246223865

   > > In #26360, I think our disagreement is whether more explicit invariants make maintenance easier. I think they do, while @alamb believes the opposite.
   > 
   > In my mind, my position is more like "removing as many hidden assumptions makes maintenance easier" (as in I feel we should remove the hidden invariants rather than make them visible)
   
   I agree with this point — it's a great design principle.
   
   Moving in this direction requires careful design and review of optimizer changes. However, moving in the opposite direction can happen naturally through the development process, as we focus on solving today's problems as quickly as possible.
   
   My general feeling is that the latter force is stronger (and I'm tempted to blame AI again). As a result, the implementation seems to be accumulating more hidden invariants, with different rules undoing each other's work or defensively working around one another.
   
   > > For now, this invariant is only documented as a guideline, with automatic validation potentially added in the future.
   > 
   > I think it is partially enforced by https://docs.rs/datafusion/latest/datafusion/physical_plan/trait.ExecutionPlan.html#method.check_invariants
   > 
   > > If we want to enforce it, I think we need a machinery with similar complexity to #26360? If so, perhaps we could try to make it extensible to other invariant regions in the future.
   > 
   > I do think adding additional invariants to the ExecutionPlans would be good
   
   I also agree that we should make better use of `check_invariants`, but it currently doesn't cover cross-rule invariants like those targeted by #26360. I don't think cross-rule invariants can be eliminated entirely. (Though this makes me wonder whether we could extend `check_invariants` to achieve what #26360 is trying to do.)
   
   Going forward, I'll try to better document these hidden cross-rule assumptions whenever I get a chance to work on related code, and see whether we can eliminate some of them.
   
   
   
   > I think given the discussion and complexity here this work deserves writing up as an EPIC -- if you agree I will write up something that tries to explain the current situation, so we can be sure we are aligned
   
   Thank you, this would be great!


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] feat: extract enforcement into a PhysicalAnalyzerRule phase (prereq for #25572) [datafusion]

Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #25688:
URL: https://github.com/apache/datafusion/pull/25688#discussion_r4091503403


##########
datafusion/session/src/session.rs:
##########
@@ -135,6 +137,17 @@ pub trait Session: Send + Sync {
         &[]
     }
 
+    /// Return the physical analyzer rules for this session.
+    ///
+    /// Analyzer rules run before the physical optimizer rules and make the plan
+    /// *valid* (for example by enforcing the distribution and ordering
+    /// requirements every operator declares). The default implementation
+    /// returns **no rules**; any real session should override this method (for
+    /// example by returning `SessionState::physical_analyzers`).
+    fn physical_analyzers(&self) -> &[Arc<dyn PhysicalAnalyzerRule + Send + Sync>] {
+        &[]
+    }

Review Comment:
   This new default is empty, so existing `Session` adapters that only forward `physical_optimizers` silently lose `EnsureRequirements`. In particular, `ForeignSession` forwards the optimizer list across the FFI boundary but has no `physical_analyzers` implementation; a planner invoked with that session can therefore receive no enforcement and produce a plan missing required repartitioning or sorting. Add the analyzer callback/conversion and delegate it in the FFI adapter, or otherwise preserve the inner analyzer list.



##########
datafusion/physical-optimizer/src/analyzer.rs:
##########
@@ -0,0 +1,111 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+//! Physical analyzer
+
+use std::sync::Arc;
+
+use crate::ensure_requirements::EnsureRequirements;
+
+// Re-export from this module for convenience.
+pub use datafusion_session::PhysicalAnalyzerRule;
+
+/// A rule-based physical analyzer.
+///
+/// Analyzer rules run before the [`PhysicalOptimizer`](crate::optimizer::PhysicalOptimizer)
+/// rules and make the plan *valid*: they enforce the invariants every operator
+/// declares (distribution, ordering) rather than making the plan faster. This
+/// mirrors the logical layer's `Analyzer`/`Optimizer` split.

Review Comment:
   The implementation does not run analyzer rules before the optimizer pipeline: the planner delays this phase until the `CombinePartialFinalAggregate` boundary to preserve the historical `EnsureRequirements` position. This wording gives users of `PhysicalAnalyzer` the wrong ordering contract.



##########
datafusion/session/src/physical_analyzer.rs:
##########
@@ -0,0 +1,91 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+//! Physical analyzer interfaces.
+
+use std::fmt::Debug;
+use std::sync::Arc;
+
+use datafusion_common::Result;
+use datafusion_common::config::ConfigOptions;
+use datafusion_physical_plan::ExecutionPlan;
+
+use crate::physical_optimizer::PhysicalOptimizerContext;
+
+/// A `PhysicalAnalyzerRule` transforms an [`ExecutionPlan`] to make the plan
+/// *valid* prior to the rest of the DataFusion physical optimization process.
+///
+/// `PhysicalAnalyzerRule`s are different from [`PhysicalOptimizerRule`]s: an
+/// optimizer rule must preserve the semantics of an already-valid plan while
+/// computing the same results in a more efficient way, whereas an analyzer
+/// rule is what *establishes* those semantics by satisfying the invariants
+/// every operator declares.
+///
+/// For example, an analyzer rule may repartition an [`ExecutionPlan`]'s input
+/// to match [`ExecutionPlan::required_input_distribution`] or insert a
+/// `SortExec` to match [`ExecutionPlan::required_input_ordering`].
+///
+/// This mirrors the logical layer's split between `AnalyzerRule` (make the
+/// plan valid) and `OptimizerRule` (make the plan faster). The physical
+/// planner runs all analyzer rules first, then the optimizer rules.

Review Comment:
   This documents a phase ordering that the implementation does not provide: the default planner deliberately invokes analyzers at the historical `EnsureRequirements` boundary, after several optimizer rules, rather than before every optimizer rule. This can mislead custom analyzer authors about what plan state their rule will see; please document the boundary behavior here (and in the corresponding `PhysicalAnalyzer` docs).



##########
datafusion/core/src/physical_planner.rs:
##########
@@ -3122,7 +3125,62 @@ impl DefaultPhysicalPlanner {
         let optimizer_context = SessionOptimizerContext {
             session: session_state,
         };
-        for optimizer in optimizers {
+
+        // The analyzer phase (enforcement) makes the plan *valid* by satisfying
+        // the distribution and ordering requirements every operator declares.
+        // It runs at the point in the historical rule order where
+        // `EnsureRequirements` used to sit: after the optimizer passes that
+        // *establish* those requirements and before the passes that assume they
+        // already hold. `JoinSelection` is the load-bearing case: it decides
+        // broadcast (single-partition) vs partitioned joins, which changes the
+        // required input distribution, so enforcing before it repartitions the
+        // inputs of a join that is then turned into a single-partition broadcast
+        // join, producing an invalid plan. In the default pipeline that boundary
+        // is right before the rule named below. A custom optimizer list without
+        // that rule runs the analyzers first (the phase-pure order), which is
+        // correct for any list whose passes do not depend on running before
+        // enforcement.
+        const ANALYZER_BOUNDARY_RULE: &str = "CombinePartialFinalAggregate";
+        let analyzer_boundary = optimizers
+            .iter()
+            .position(|o| o.name() == ANALYZER_BOUNDARY_RULE)
+            .unwrap_or(0);

Review Comment:
   The analyzer placement is derived from a rule name that custom optimizer lists can omit or rename, with the fallback running analyzers at index 0. For example, a custom list containing `JoinSelection` and `SanityCheckPlan` but not `CombinePartialFinalAggregate` runs `EnsureRequirements` before join selection; the default pipeline explicitly requires join selection to run first because it can change a join to single-partition/broadcast and therefore change its requirements. That can leave the final plan invalid. The boundary needs to be explicit or preserved independently of the presence of this particular rule.
   
   This issue also appears on line 3498 of the same file.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] feat: run physical requirement enforcement first, as a PhysicalAnalyzer phase [datafusion]

Posted by "codecov-commenter (via GitHub)" <gi...@apache.org>.
codecov-commenter commented on PR #25688:
URL: https://github.com/apache/datafusion/pull/25688#issuecomment-5857282285

   ## [Codecov](https://app.codecov.io/gh/apache/datafusion/pull/25688?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
   :x: Patch coverage is `84.43936%` with `68 lines` in your changes missing coverage. Please review.
   :white_check_mark: Project coverage is 82.51%. Comparing base ([`424cfd8`](https://app.codecov.io/gh/apache/datafusion/commit/424cfd8eb7e5d73229227324f02b39179babeeb1?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`0bf1852`](https://app.codecov.io/gh/apache/datafusion/commit/0bf18528959f80a70d54dd77fc456430c02e776d?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
   :warning: Report is 45 commits behind head on main.
   
   | [Files with missing lines](https://app.codecov.io/gh/apache/datafusion/pull/25688?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Patch % | Lines |
   |---|---|---|
   | [.../physical-optimizer/src/ensure\_requirements/mod.rs](https://app.codecov.io/gh/apache/datafusion/pull/25688?src=pr&el=tree&filepath=datafusion%2Fphysical-optimizer%2Fsrc%2Fensure_requirements%2Fmod.rs&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-ZGF0YWZ1c2lvbi9waHlzaWNhbC1vcHRpbWl6ZXIvc3JjL2Vuc3VyZV9yZXF1aXJlbWVudHMvbW9kLnJz) | 78.94% | [21 Missing and 11 partials :warning: ](https://app.codecov.io/gh/apache/datafusion/pull/25688?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   | [datafusion/core/src/execution/session\_state.rs](https://app.codecov.io/gh/apache/datafusion/pull/25688?src=pr&el=tree&filepath=datafusion%2Fcore%2Fsrc%2Fexecution%2Fsession_state.rs&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-ZGF0YWZ1c2lvbi9jb3JlL3NyYy9leGVjdXRpb24vc2Vzc2lvbl9zdGF0ZS5ycw==) | 73.58% | [12 Missing and 2 partials :warning: ](https://app.codecov.io/gh/apache/datafusion/pull/25688?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   | [datafusion/core/src/physical\_planner.rs](https://app.codecov.io/gh/apache/datafusion/pull/25688?src=pr&el=tree&filepath=datafusion%2Fcore%2Fsrc%2Fphysical_planner.rs&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-ZGF0YWZ1c2lvbi9jb3JlL3NyYy9waHlzaWNhbF9wbGFubmVyLnJz) | 87.73% | [5 Missing and 8 partials :warning: ](https://app.codecov.io/gh/apache/datafusion/pull/25688?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   | [...sion/physical-optimizer/src/output\_requirements.rs](https://app.codecov.io/gh/apache/datafusion/pull/25688?src=pr&el=tree&filepath=datafusion%2Fphysical-optimizer%2Fsrc%2Foutput_requirements.rs&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-ZGF0YWZ1c2lvbi9waHlzaWNhbC1vcHRpbWl6ZXIvc3JjL291dHB1dF9yZXF1aXJlbWVudHMucnM=) | 77.77% | [4 Missing :warning: ](https://app.codecov.io/gh/apache/datafusion/pull/25688?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   | [...atafusion/physical-optimizer/src/join\_selection.rs](https://app.codecov.io/gh/apache/datafusion/pull/25688?src=pr&el=tree&filepath=datafusion%2Fphysical-optimizer%2Fsrc%2Fjoin_selection.rs&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-ZGF0YWZ1c2lvbi9waHlzaWNhbC1vcHRpbWl6ZXIvc3JjL2pvaW5fc2VsZWN0aW9uLnJz) | 75.00% | [0 Missing and 2 partials :warning: ](https://app.codecov.io/gh/apache/datafusion/pull/25688?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   | [datafusion/physical-optimizer/src/analyzer.rs](https://app.codecov.io/gh/apache/datafusion/pull/25688?src=pr&el=tree&filepath=datafusion%2Fphysical-optimizer%2Fsrc%2Fanalyzer.rs&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-ZGF0YWZ1c2lvbi9waHlzaWNhbC1vcHRpbWl6ZXIvc3JjL2FuYWx5emVyLnJz) | 98.18% | [0 Missing and 1 partial :warning: ](https://app.codecov.io/gh/apache/datafusion/pull/25688?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   | [...tafusion/physical-optimizer/src/filter\_pushdown.rs](https://app.codecov.io/gh/apache/datafusion/pull/25688?src=pr&el=tree&filepath=datafusion%2Fphysical-optimizer%2Fsrc%2Ffilter_pushdown.rs&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-ZGF0YWZ1c2lvbi9waHlzaWNhbC1vcHRpbWl6ZXIvc3JjL2ZpbHRlcl9wdXNoZG93bi5ycw==) | 85.71% | [0 Missing and 1 partial :warning: ](https://app.codecov.io/gh/apache/datafusion/pull/25688?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   | [datafusion/physical-optimizer/src/window\_topn.rs](https://app.codecov.io/gh/apache/datafusion/pull/25688?src=pr&el=tree&filepath=datafusion%2Fphysical-optimizer%2Fsrc%2Fwindow_topn.rs&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-ZGF0YWZ1c2lvbi9waHlzaWNhbC1vcHRpbWl6ZXIvc3JjL3dpbmRvd190b3BuLnJz) | 92.30% | [0 Missing and 1 partial :warning: ](https://app.codecov.io/gh/apache/datafusion/pull/25688?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   
   <details><summary>Additional details and impacted files</summary>
   
   
   
   ```diff
   @@            Coverage Diff             @@
   ##             main   #25688      +/-   ##
   ==========================================
   + Coverage   82.49%   82.51%   +0.02%     
   ==========================================
     Files        1140     1143       +3     
     Lines      437675   440154    +2479     
     Branches   437675   440154    +2479     
   ==========================================
   + Hits       361054   363199    +2145     
   - Misses      54830    55001     +171     
   - Partials    21791    21954     +163     
   ```
   </details>
   
   [:umbrella: View full report in Codecov by Harness](https://app.codecov.io/gh/apache/datafusion/pull/25688?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).   
   :loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
   <details><summary> :rocket: New features to boost your workflow: </summary>
   
   - :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
   - :package: [JS Bundle Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
   </details>


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] feat: run physical requirement enforcement first, as a PhysicalAnalyzer phase [datafusion]

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on PR #25688:
URL: https://github.com/apache/datafusion/pull/25688#issuecomment-5930525089

   > I'm wondering what concrete issue or bug this PR is trying to solve, is it to prevent similar bugs like
   > 
   > * [InterleaveExec::with_new_children panics when optimizer rewrites change children's partitioning #21826](https://github.com/apache/datafusion/issues/21826)
   > 
   > Below are just some partial thoughts for reference. I'd like to probe into the target issue first to validate the reasoning, it's not suggesting a different implementation at this point.
   
   My understanding is that the driving rationale was to speed up query planning to the point where the optimizer rules can be run multiple times and stop when they have reached a fixed point (the plan is not changing)
   
   I think this is what @zhuqi-lucas  describes in this ticket (though I agree the usecase is not clear)
   - https://github.com/apache/datafusion/issues/25355
   
   
   
   > Placing `EnsureRequirements` in the middle may be a design that simplifies the overall implementation. The issue is that it introduces constraints on rewrites before and after it, and those constraints are not currently enforced explicitly, making the optimizer vulnerable to bugs. So I'm wondering whether there is a more flexible way to enforce the sanity check instead.
   > The gap now, I think, is that the invariants are not enforced explicitly in datafusion (for example, after `EnsureRequirements`, traversing the tree after each rewrite to verify that the distribution requirements still hold), so it seem to have many hidden knowledge to know if you want to add one new optimizer rule correctly.
   
   I agree invariants are not explicitly checked / easy to understand. @wiedld  and I tried to add some invariant checking here: https://docs.rs/datafusion/latest/datafusion/physical_plan/trait.ExecutionPlan.html#method.check_invariants but it is not widely used nor expansive. 
   
   > This is a common technique in compilers to organize very complex rewrites: split the pipeline into distinct phases and enforce the invariants. To keep overall transformation implementations simple, the general idea is to delay Stage 3 as late as possible, and try to put more rules in Stage 2, which seems to be in a different direction from this PR.
   
   This is a great point, and  I think in Databases in general (and DataFusion in particular) it maps pretty well if you think about LogicalPlan --> PhysicalPlan as the "lowering" phase (e.g. the LogicalPlan is much simpler)
   
   
   > One possible direction is to make these phase boundaries explicit. Each phase would have a well-defined plan shape that its rules can assume, rather than relying on the implicit ordering between individual optimizer rules. Roughly, the optimizer rule list can be split into stages like:
   
   Yes, that is indeed similar to what I was thinking (and what I think the `PhysicalAnalayzerPass` is in my mind)
   
   I was hoping think the high level optimization flow is something like
   
   Phase 1: Logical Plan Optimization
   ** Stage 1: correctness: [AnalyzerRules](https://docs.rs/datafusion/latest/datafusion/optimizer/trait.AnalyzerRule.html) apply semantic changes to get the plan correct (type coercion, function rewrites, etc)
   ** Stage 2: optimization: [OptimizerRules](https://docs.rs/datafusion/latest/datafusion/optimizer/trait.OptimizerRule.html) -- tree rewrites that make the plan faster
   
   
   I was hoping to get a similar split in ExecutionPlan Optimization
   ** Stage 1: correctness (`PhysicalAnalyzerRule` -- this PR) -- that gets the plans executable (could be run)
   ** Stage 2: optimization [PhysicalOptimizerRule](https://docs.rs/datafusion/latest/datafusion/physical_optimizer/trait.PhysicalOptimizerRule.html) -- tree rewrites that make the plan faster
    
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] feat: run physical requirement enforcement first, as a PhysicalAnalyzer phase [datafusion]

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on code in PR #25688:
URL: https://github.com/apache/datafusion/pull/25688#discussion_r4154971062


##########
datafusion/core/tests/physical_optimizer/ensure_requirements.rs:
##########
@@ -1560,3 +1564,222 @@ fn test_sort_pushed_below_limit_with_skip_keeps_skip_rows() -> Result<()> {
     ");
     Ok(())
 }
+
+// ========================================================================
+// Decomposition tests: `EnsureRequirements` was split into three rules

Review Comment:
   Is the history of what happened important to document in comments (that will live after this PR)?



##########
datafusion/core/tests/physical_optimizer/filter_pushdown.rs:
##########
@@ -134,7 +134,8 @@ fn test_pushdown_volatile_functions_not_allowed() {
       output:
         Ok:
           - FilterExec: a@0 = random()
-          -   DataSourceExec: file_groups={1 group: [[test.parquet]]}, projection=[a, b, c], file_type=test, pushdown_supported=true
+          -   RepartitionExec: partitioning=RoundRobinBatch(4), input_partitions=1

Review Comment:
   why did these tests change?



##########
datafusion/physical-optimizer/src/optimizer.rs:
##########
@@ -115,25 +118,12 @@ impl PhysicalOptimizer {
             // window's declared ordering without pattern-matching a SortExec)
             // and before ProjectionPushdown (which embeds projections into FilterExec).
             Arc::new(WindowTopN::new()),
-            // Ensures each input plan satisfies the distribution and ordering
-            // requirements declared by `ExecutionPlan::required_input_distribution`
-            // and `ExecutionPlan::required_input_ordering`.
-            //
-            // If the requirements are already satisfied, this rule leaves the plan
-            // unchanged. For example, it does not add sorting when the input is a
-            // file scan whose existing order already satisfies the required ordering.
-            // Otherwise, this rule inserts the necessary repartitioning and sorting
-            // operators.
-            //
-            // This used to be implemented as two separate rules: `EnforceDistribution`
-            // and `EnforceSorting`. It is now a single idempotent rule that decides
-            // distribution and sorting together in one bottom-up pass, so the
-            // `pushdown_sorts` step no longer breaks distribution invariants set
-            // earlier in the pipeline. See the module-level doc on
-            // [`EnsureRequirements`](crate::ensure_requirements) for the per-phase
-            // breakdown, and <https://github.com/apache/datafusion/issues/21973>
-            // for the original failure mode.
-            Arc::new(EnsureRequirements::new()),
+            // All enforcement (distribution and ordering) runs first in the

Review Comment:
   the details about enforcement seem irrelevant at this poing



##########
datafusion/physical-optimizer/src/analyzer.rs:
##########
@@ -0,0 +1,153 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+//! Physical analyzer
+
+use std::sync::Arc;
+
+use crate::ensure_requirements::{EnforceDistribution, EnforceSorting};
+use crate::output_requirements::OutputRequirements;
+
+// Re-export from this module for convenience.
+pub use datafusion_session::PhysicalAnalyzerRule;
+
+/// A rule-based physical analyzer.
+///
+/// Analyzer rules make the plan *valid*: they enforce the invariants every
+/// operator declares (distribution, ordering) rather than making the plan
+/// faster, mirroring the logical layer's `Analyzer`/`Optimizer` split. The
+/// default planner runs the whole analyzer phase before the
+/// [`PhysicalOptimizer`](crate::optimizer::PhysicalOptimizer) phase, so every
+/// optimizer rule can assume it receives a valid plan; see
+/// [`PhysicalAnalyzerRule`] for details.
+#[derive(Clone, Debug)]
+pub struct PhysicalAnalyzer {
+    /// All rules to apply
+    pub rules: Vec<Arc<dyn PhysicalAnalyzerRule + Send + Sync>>,
+}
+
+impl Default for PhysicalAnalyzer {
+    fn default() -> Self {
+        Self::new()
+    }
+}
+
+impl PhysicalAnalyzer {
+    /// Create a new analyzer using the recommended list of rules
+    pub fn new() -> Self {
+        // All enforcement runs here, first, as the analyzer phase: it makes the

Review Comment:
   this seems redundant to the documentation on `PhysicalAnalyzer` and `PhysicalAnalyzerRule`



##########
datafusion/sqllogictest/test_files/window_topn.slt:
##########
@@ -1575,11 +1575,9 @@ logical_plan
 physical_plan
 01)ProjectionExec: expr=[c1@0 as c1, c2@1 as c2, row_number() PARTITION BY [t.c1] ORDER BY [t.c2 DESC NULLS FIRST] RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW@2 as rn]
 02)--BoundedWindowAggExec: wdw=[row_number() PARTITION BY [t.c1] ORDER BY [t.c2 DESC NULLS FIRST] RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW: Field { "row_number() PARTITION BY [t.c1] ORDER BY [t.c2 DESC NULLS FIRST] RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW": UInt64 }, frame: RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW], mode=[Sorted]
-03)----SortPreservingMergeExec: [c1@0 ASC NULLS LAST, c2@1 DESC]
-04)------SortExec: expr=[c1@0 ASC NULLS LAST, c2@1 DESC], preserve_partitioning=[true]
-05)--------PartitionedTopKExec: fn=row_number, fetch=1, partition=[c1@0], order=[c2@1 DESC]
-06)----------RepartitionExec: partitioning=Hash([c1@0], 5), input_partitions=1
-07)------------DataSourceExec: partitions=1, partition_sizes=[1]
+03)----PartitionedTopKExec: fn=row_number, fetch=1, partition=[c1@0], order=[c2@1 DESC]

Review Comment:
   is this plan change ok? it looks like maybe the partitioning doesn't run in parallel anymore?



##########
datafusion/physical-optimizer/src/analyzer.rs:
##########
@@ -0,0 +1,153 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+//! Physical analyzer
+
+use std::sync::Arc;
+
+use crate::ensure_requirements::{EnforceDistribution, EnforceSorting};
+use crate::output_requirements::OutputRequirements;
+
+// Re-export from this module for convenience.
+pub use datafusion_session::PhysicalAnalyzerRule;
+
+/// A rule-based physical analyzer.
+///
+/// Analyzer rules make the plan *valid*: they enforce the invariants every
+/// operator declares (distribution, ordering) rather than making the plan
+/// faster, mirroring the logical layer's `Analyzer`/`Optimizer` split. The
+/// default planner runs the whole analyzer phase before the
+/// [`PhysicalOptimizer`](crate::optimizer::PhysicalOptimizer) phase, so every
+/// optimizer rule can assume it receives a valid plan; see
+/// [`PhysicalAnalyzerRule`] for details.
+#[derive(Clone, Debug)]
+pub struct PhysicalAnalyzer {
+    /// All rules to apply
+    pub rules: Vec<Arc<dyn PhysicalAnalyzerRule + Send + Sync>>,
+}
+
+impl Default for PhysicalAnalyzer {
+    fn default() -> Self {
+        Self::new()
+    }
+}
+
+impl PhysicalAnalyzer {
+    /// Create a new analyzer using the recommended list of rules
+    pub fn new() -> Self {
+        // All enforcement runs here, first, as the analyzer phase: it makes the
+        // plan *valid* (distribution first, then ordering) before any optimizer
+        // rule sees it, mirroring the logical Analyzer/Optimizer split. The
+        // optimizer rules that change these requirements (`JoinSelection`,
+        // `WindowTopN`, `FilterPushdown`) re-establish validity themselves, so
+        // enforcement is not repeated as an optimizer pass. The sort
+        // *optimizations* (`OptimizeSorts`) are not enforcement and stay in the
+        // optimizer phase.
+        let rules: Vec<Arc<dyn PhysicalAnalyzerRule + Send + Sync>> = vec![
+            // Establish the output-requirement boundary first, so enforcement can
+            // see it (parallelize top-level scans below it, preserve the query's
+            // final ordering). The matching remove pass runs late in the optimizer.
+            Arc::new(OutputRequirements::new_add_mode()),
+            Arc::new(EnforceDistribution::new()),

Review Comment:
   why did you split EnforceDistribution and EnforceSorting when they were unified before?



##########
datafusion/physical-optimizer/src/ensure_requirements/mod.rs:
##########
@@ -176,6 +177,302 @@ impl EnsureRequirements {
     }
 }
 
+/// Phases 0-2a: make the plan valid with respect to **distribution**
+/// requirements only (normalize interleave, join-key reordering, distribution
+/// enforcement). Split from ordering enforcement so it can be used on its own:
+/// the [`EnforceDistribution`] analyzer rule runs it as the first enforcement
+/// step, and rules that change only distribution (`JoinSelection`,
+/// `FilterPushdown`) call it directly to re-establish the partitioning their
+/// rewrite disturbed, without touching ordering.
+pub fn enforce_distribution_requirements(
+    plan: Arc<dyn ExecutionPlan>,
+    context: &dyn PhysicalOptimizerContext,
+) -> Result<Arc<dyn ExecutionPlan>> {
+    let config = context.config_options();
+    // Phase 0: Normalize `InterleaveExec` back to `UnionExec` (top-down).
+    // Interleaves are distribution artifacts of Phase 2, which re-derives
+    // them from the children's final partitioning. Keeping them would
+    // fail as soon as a child loses the partitioning they depend on.
+    use super::enforce_distribution::replace_interleave_with_union;
+    let plan = plan.transform_down(replace_interleave_with_union).data()?;
+
+    // Phase 1: Join key reordering (top-down, from EnforceDistribution)
+    use super::enforce_distribution::{
+        PlanWithKeyRequirements, adjust_input_keys_ordering,
+    };
+    let top_down_join_key_reordering = config.optimizer.top_down_join_key_reordering;
+    let plan = if top_down_join_key_reordering {
+        let ctx = PlanWithKeyRequirements::new_default(plan);
+        ctx.transform_down(adjust_input_keys_ordering).data()?.plan
+    } else {
+        use super::enforce_distribution::reorder_join_keys_to_inputs;
+        plan.transform_up(|p| Ok(Transformed::yes(reorder_join_keys_to_inputs(p)?)))
+            .data()?
+    };
+
+    // Phase 2a: Distribution enforcement (bottom-up)
+    use super::enforce_distribution::{
+        DistributionContext, ensure_distribution_with_stats,
+    };
+    let dist_ctx = DistributionContext::new_default(plan);
+    // Share one statistics context across the whole distribution pass so each
+    // subtree's statistics are computed once instead of once per ancestor.
+    // Build it from the session's statistics registry so registered providers
+    // are consulted (an empty registry, the default, is unchanged behavior).
+    // `StatsCache` is keyed by raw node pointer, so reset it after any node
+    // whose plan pointer actually changed: a rewrite can free a cached node
+    // and a later allocation could reuse its address. A node that makes no
+    // change cannot free anything, so the cache safely persists across the
+    // no-op nodes that dominate a deep plan.
+    let stats_ctx = match context.statistics_registry() {
+        Some(registry) => StatisticsContext::new_with_registry(registry.clone()),
+        None => StatisticsContext::new(),
+    };
+    let dist_ctx = dist_ctx
+        .transform_up(|ctx| {
+            let before = Arc::clone(&ctx.plan);
+            let result = ensure_distribution_with_stats(ctx, config, &stats_ctx)?;
+            if !Arc::ptr_eq(&before, &result.data.plan) {
+                stats_ctx.reset_cache();
+            }
+            Ok(result)
+        })
+        .data()?;
+    Ok(dist_ctx.plan)
+}
+
+/// Phase 2b: enforce **ordering** requirements by inserting `SortExec`s on a
+/// distribution-fixed plan (bottom-up). This is the enforcement half that is
+/// *not* idempotent, so in the default pipeline it runs exactly once via the
+/// [`EnforceSorting`] analyzer rule. Exposed as a free function so the combined
+/// [`enforce_requirements`] (used by rules that disturb ordering, and by the
+/// [`EnsureRequirements`] compatibility shim) can reuse it.
+pub fn enforce_sorting_requirements(
+    plan: Arc<dyn ExecutionPlan>,
+) -> Result<Arc<dyn ExecutionPlan>> {
+    use super::enforce_sorting::{PlanWithCorrespondingSort, ensure_sorting};
+    let sort_ctx = PlanWithCorrespondingSort::new_default(plan);
+    let sort_ctx = sort_ctx.transform_up(ensure_sorting)?.data;
+    Ok(sort_ctx.plan)
+}
+
+/// Phases 0-2: full requirement enforcement (distribution via
+/// [`enforce_distribution_requirements`], then sorting via
+/// [`enforce_sorting_requirements`]). The default pipeline uses the
+/// finer-grained [`EnforceDistribution`] / [`EnforceSorting`] rules instead;
+/// this stays for the [`EnsureRequirements`] compatibility shim.
+pub fn enforce_requirements(
+    plan: Arc<dyn ExecutionPlan>,
+    context: &dyn PhysicalOptimizerContext,
+) -> Result<Arc<dyn ExecutionPlan>> {
+    let plan = enforce_distribution_requirements(plan, context)?;
+    enforce_sorting_requirements(plan)
+}
+
+/// Phase 3: sort and distribution *optimizations* that make an already-valid
+/// plan faster (parallelize sorts, order-preserving variants, sort pushdown,
+/// partial sort). Split out of enforcement so it can run in the optimizer phase,
+/// after other optimizer rules (such as `WindowTopN`) have produced the
+/// operators it parallelizes. Exposed as the [`OptimizeSorts`] rule.
+pub fn optimize_sorts(
+    plan: Arc<dyn ExecutionPlan>,
+    config: &ConfigOptions,
+) -> Result<Arc<dyn ExecutionPlan>> {
+    // 3a: Parallelize sorts (Coalesce+Sort → SPM+Sort)
+    use super::enforce_sorting::{
+        PlanWithCorrespondingCoalescePartitions, parallelize_sorts,
+        replace_with_partial_sort,
+    };
+    let plan = if config.optimizer.repartition_sorts {
+        let ctx = PlanWithCorrespondingCoalescePartitions::new_default(plan);
+        ctx.transform_up(parallelize_sorts).data()?.plan
+    } else {
+        plan
+    };
+
+    // 3b: Order-preserving variants
+    use super::enforce_sorting::replace_with_order_preserving_variants::{
+        OrderPreservationContext, replace_with_order_preserving_variants,
+    };
+    let ctx = OrderPreservationContext::new_default(plan);
+    let plan = ctx
+        .transform_up(|c| replace_with_order_preserving_variants(c, false, true, config))
+        .data()?
+        .plan;
+
+    // 3c: Sort pushdown (distribution-aware)
+    use super::enforce_sorting::sort_pushdown::{
+        SortPushDown, assign_initial_requirements, pushdown_sorts,
+    };
+    let mut sort_pushdown = SortPushDown::new_default(plan);
+    assign_initial_requirements(&mut sort_pushdown);
+    let adjusted = pushdown_sorts(sort_pushdown)?;
+
+    // 3d: Partial sort
+    adjusted
+        .plan
+        .transform_up(|p| Ok(Transformed::yes(replace_with_partial_sort(p)?)))
+        .data()
+}
+
+/// Enforces **distribution** requirements (Phases 0-2a) via
+/// [`enforce_distribution_requirements`]. In the default pipeline it runs as the
+/// [`PhysicalAnalyzerRule`] that makes the plan distribution-valid before the
+/// optimizer rules see it. It is idempotent enough to run more than once, and
+/// still implements [`PhysicalOptimizerRule`] so downstream pipelines that splice
+/// it in by position keep working; the default optimizer rules that change
+/// distribution (`JoinSelection`, `FilterPushdown`) instead call
+/// [`enforce_distribution_requirements`] directly to re-establish it themselves.
+#[derive(Default, Debug)]
+pub struct EnforceDistribution {}
+
+impl EnforceDistribution {
+    #[expect(missing_docs)]
+    pub fn new() -> Self {
+        Self {}
+    }
+}
+
+impl PhysicalOptimizerRule for EnforceDistribution {
+    fn optimize(
+        &self,
+        plan: Arc<dyn ExecutionPlan>,
+        config: &ConfigOptions,
+    ) -> Result<Arc<dyn ExecutionPlan>> {
+        enforce_distribution_requirements(plan, &ConfigOnlyContext::new(config))
+    }
+
+    fn optimize_with_context(
+        &self,
+        plan: Arc<dyn ExecutionPlan>,
+        context: &dyn PhysicalOptimizerContext,
+    ) -> Result<Arc<dyn ExecutionPlan>> {
+        enforce_distribution_requirements(plan, context)
+    }
+
+    fn name(&self) -> &str {
+        "EnforceDistribution"
+    }
+
+    fn schema_check(&self) -> bool {
+        true
+    }
+}
+
+impl PhysicalAnalyzerRule for EnforceDistribution {
+    fn analyze(
+        &self,
+        plan: Arc<dyn ExecutionPlan>,
+        config: &ConfigOptions,
+    ) -> Result<Arc<dyn ExecutionPlan>> {
+        enforce_distribution_requirements(plan, &ConfigOnlyContext::new(config))
+    }
+
+    fn analyze_with_context(
+        &self,
+        plan: Arc<dyn ExecutionPlan>,
+        context: &dyn PhysicalOptimizerContext,
+    ) -> Result<Arc<dyn ExecutionPlan>> {
+        enforce_distribution_requirements(plan, context)
+    }
+
+    fn name(&self) -> &str {
+        "EnforceDistribution"
+    }
+
+    fn schema_check(&self) -> bool {
+        true
+    }
+}
+
+/// Enforces **ordering** requirements (Phase 2b) via
+/// [`enforce_sorting_requirements`]. Not idempotent, so it runs exactly once in
+/// the default pipeline, as the ordering-enforcement [`PhysicalAnalyzerRule`]
+/// (after [`EnforceDistribution`], on the distribution-fixed plan). The later
+/// optimizer rules that disturb ordering (`WindowTopN`) re-establish it
+/// themselves via [`enforce_requirements`].
+#[derive(Default, Debug)]
+pub struct EnforceSorting {}
+
+impl EnforceSorting {
+    #[expect(missing_docs)]
+    pub fn new() -> Self {
+        Self {}
+    }
+}
+
+impl PhysicalOptimizerRule for EnforceSorting {

Review Comment:
   Shouldn't enforcing sorting be a PhysicalAnalyzer rule too? Until that is run the sort order is not correct for declared input requirements



##########
datafusion/physical-optimizer/src/optimizer.rs:
##########
@@ -89,9 +89,12 @@ impl PhysicalOptimizer {
         //   queries, and will likely increase the optimization time. Please extend
         //   existing rules when possible, rather than adding a new rule.
         let rules: Vec<Arc<dyn PhysicalOptimizerRule + Send + Sync>> = vec![
-            // If there is a output requirement of the query, make sure that
-            // this information is not lost across different rules during optimization.
-            Arc::new(OutputRequirements::new_add_mode()),
+            // The output-requirement boundary (`OutputRequirements` add mode) and

Review Comment:
   this seems like comments related to this PR (not something that will be relevant to future readers)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] feat: run physical requirement enforcement first, as a PhysicalAnalyzer phase [datafusion]

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on PR #25688:
URL: https://github.com/apache/datafusion/pull/25688#issuecomment-5930724119

   I think the structure of this PR looks good in general. I worry about:
   1. Plan changes -- they don't all look good to me
   2. Performance regression (can we perhaps combine EnforceDistribution and EnforceSort again and find some other ways to make OptimizeSort faster?)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] feat: run physical requirement enforcement first, as a PhysicalAnalyzer phase [datafusion]

Posted by "adriangbot (via GitHub)" <gi...@apache.org>.
adriangbot commented on PR #25688:
URL: https://github.com/apache/datafusion/pull/25688#issuecomment-5934125754

   🤖 Benchmark running (GKE) | [trigger](https://github.com/apache/datafusion/pull/25688#issuecomment-5934038705)
   **Instance:** `c4a-highcpu-48` (12 vCPU / 65 GiB) | `Linux bench-c5934038705-3004-qs59z 6.12.94+ #1 SMP Wed Aug 19 07:47:20 UTC 2026 aarch64 GNU/Linux`
   <details><summary>CPU Details (lscpu)</summary>
   
   ```
   Architecture:                            aarch64
   CPU op-mode(s):                          64-bit
   Byte Order:                              Little Endian
   CPU(s):                                  48
   On-line CPU(s) list:                     0-47
   Vendor ID:                               ARM
   Model name:                              Neoverse-V2
   Model:                                   1
   Thread(s) per core:                      1
   Core(s) per cluster:                     48
   Socket(s):                               -
   Cluster(s):                              1
   Stepping:                                r0p1
   BogoMIPS:                                2000.00
   Flags:                                   fp asimd evtstrm aes pmull sha1 sha2 crc32 atomics fphp asimdhp cpuid asimdrdm jscvt fcma lrcpc dcpop sha3 sm3 sm4 asimddp sha512 sve asimdfhm dit uscat ilrcpc flagm sb paca pacg dcpodp sve2 sveaes svepmull svebitperm svesha3 svesm4 flagm2 frint svei8mm svebf16 i8mm bf16 dgh rng bti
   L1d cache:                               3 MiB (48 instances)
   L1i cache:                               3 MiB (48 instances)
   L2 cache:                                96 MiB (48 instances)
   L3 cache:                                80 MiB (1 instance)
   NUMA node(s):                            1
   NUMA node0 CPU(s):                       0-47
   Vulnerability Gather data sampling:      Not affected
   Vulnerability Indirect target selection: Not affected
   Vulnerability Itlb multihit:             Not affected
   Vulnerability L1tf:                      Not affected
   Vulnerability Mds:                       Not affected
   Vulnerability Meltdown:                  Not affected
   Vulnerability Mmio stale data:           Not affected
   Vulnerability Reg file data sampling:    Not affected
   Vulnerability Retbleed:                  Not affected
   Vulnerability Spec rstack overflow:      Not affected
   Vulnerability Spec store bypass:         Mitigation; Speculative Store Bypass disabled via prctl
   Vulnerability Spectre v1:                Mitigation; __user pointer sanitization
   Vulnerability Spectre v2:                Mitigation; CSV2, BHB
   Vulnerability Srbds:                     Not affected
   Vulnerability Tsa:                       Not affected
   Vulnerability Tsx async abort:           Not affected
   Vulnerability Vmscape:                   Not affected
   ```
   
   </details>
   
   Comparing physical-analyzer-rule (d5ce43a9b9244eafcff95108b30d6f531324e651) to 9ee892b (merge-base) [diff](https://github.com/apache/datafusion/compare/9ee892b99d9f24b5e00cff0ce4a66e09126843ef..d5ce43a9b9244eafcff95108b30d6f531324e651)
   
   <details><summary>Run configuration</summary>
   
   ```yaml
   run benchmark sql_planner
   ```
   
   </details>
   
   Results will be posted here when complete
   
   ---
   [File an issue](https://github.com/adriangb/datafusion-benchmarking/issues) against this benchmark runner


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] feat: run physical requirement enforcement first, as a PhysicalAnalyzer phase [datafusion]

Posted by "adriangbot (via GitHub)" <gi...@apache.org>.
adriangbot commented on PR #25688:
URL: https://github.com/apache/datafusion/pull/25688#issuecomment-5935519732

   🤖 Benchmark completed (GKE) | [trigger](https://github.com/apache/datafusion/pull/25688#issuecomment-5934038705)
   
   **Instance:** `c4a-highcpu-48` (12 vCPU / 65 GiB)
   
   Comparing physical-analyzer-rule (d5ce43a9b9244eafcff95108b30d6f531324e651) to 9ee892b (merge-base) [diff](https://github.com/apache/datafusion/compare/9ee892b99d9f24b5e00cff0ce4a66e09126843ef..d5ce43a9b9244eafcff95108b30d6f531324e651)
   
   <details><summary>Run configuration</summary>
   
   ```yaml
   run benchmark sql_planner
   ```
   
   </details>
   
   <details><summary>CPU Details (lscpu)</summary>
   
   ```
   Architecture:                            aarch64
   CPU op-mode(s):                          64-bit
   Byte Order:                              Little Endian
   CPU(s):                                  48
   On-line CPU(s) list:                     0-47
   Vendor ID:                               ARM
   Model name:                              Neoverse-V2
   Model:                                   1
   Thread(s) per core:                      1
   Core(s) per cluster:                     48
   Socket(s):                               -
   Cluster(s):                              1
   Stepping:                                r0p1
   BogoMIPS:                                2000.00
   Flags:                                   fp asimd evtstrm aes pmull sha1 sha2 crc32 atomics fphp asimdhp cpuid asimdrdm jscvt fcma lrcpc dcpop sha3 sm3 sm4 asimddp sha512 sve asimdfhm dit uscat ilrcpc flagm sb paca pacg dcpodp sve2 sveaes svepmull svebitperm svesha3 svesm4 flagm2 frint svei8mm svebf16 i8mm bf16 dgh rng bti
   L1d cache:                               3 MiB (48 instances)
   L1i cache:                               3 MiB (48 instances)
   L2 cache:                                96 MiB (48 instances)
   L3 cache:                                80 MiB (1 instance)
   NUMA node(s):                            1
   NUMA node0 CPU(s):                       0-47
   Vulnerability Gather data sampling:      Not affected
   Vulnerability Indirect target selection: Not affected
   Vulnerability Itlb multihit:             Not affected
   Vulnerability L1tf:                      Not affected
   Vulnerability Mds:                       Not affected
   Vulnerability Meltdown:                  Not affected
   Vulnerability Mmio stale data:           Not affected
   Vulnerability Reg file data sampling:    Not affected
   Vulnerability Retbleed:                  Not affected
   Vulnerability Spec rstack overflow:      Not affected
   Vulnerability Spec store bypass:         Mitigation; Speculative Store Bypass disabled via prctl
   Vulnerability Spectre v1:                Mitigation; __user pointer sanitization
   Vulnerability Spectre v2:                Mitigation; CSV2, BHB
   Vulnerability Srbds:                     Not affected
   Vulnerability Tsa:                       Not affected
   Vulnerability Tsx async abort:           Not affected
   Vulnerability Vmscape:                   Not affected
   ```
   
   </details>
   
   <details><summary>Details</summary>
   <p>
   
   ```
   group                                                 HEAD                                   physical-analyzer-rule
   -----                                                 ----                                   ----------------------
   logical_aggregate_with_join                           1.00    410.3±1.65µs        ? ?/sec    1.00    411.3±1.74µs        ? ?/sec
   logical_correlated_subquery_exists                    1.00    246.2±0.99µs        ? ?/sec    1.01    248.7±1.07µs        ? ?/sec
   logical_correlated_subquery_in                        1.00    248.2±1.33µs        ? ?/sec    1.01    250.6±1.18µs        ? ?/sec
   logical_distinct_many_columns                         1.00    330.9±1.14µs        ? ?/sec    1.00    329.3±1.06µs        ? ?/sec
   logical_join_4_with_agg_and_filter                    1.00    200.1±0.64µs        ? ?/sec    1.00    200.1±0.96µs        ? ?/sec
   logical_join_8_with_agg_sort_limit                    1.01    370.7±1.75µs        ? ?/sec    1.00    365.8±1.08µs        ? ?/sec
   logical_join_chain_16                                 1.02    639.5±1.98µs        ? ?/sec    1.00    629.3±1.82µs        ? ?/sec
   logical_join_chain_4                                  1.00     78.1±0.40µs        ? ?/sec    1.01     79.1±0.23µs        ? ?/sec
   logical_join_chain_8                                  1.00    207.5±0.55µs        ? ?/sec    1.00    206.7±0.47µs        ? ?/sec
   logical_multiple_subqueries                           1.00    483.1±1.39µs        ? ?/sec    1.00    483.2±1.70µs        ? ?/sec
   logical_nested_cte_4_levels                           1.00    223.0±1.37µs        ? ?/sec    1.00    222.9±1.03µs        ? ?/sec
   logical_plan_struct_join_agg_sort                     1.04    134.1±0.90µs        ? ?/sec    1.00    129.3±0.87µs        ? ?/sec
   logical_plan_tpcds_all                                1.00     84.0±0.13ms        ? ?/sec    1.01     85.1±0.21ms        ? ?/sec
   logical_plan_tpch_all                                 1.00      5.6±0.02ms        ? ?/sec    1.00      5.6±0.02ms        ? ?/sec
   logical_scalar_subquery                               1.00    267.4±1.01µs        ? ?/sec    1.00    268.5±0.88µs        ? ?/sec
   logical_select_all_from_1000                          1.00      8.8±0.03ms        ? ?/sec    1.00      8.8±0.02ms        ? ?/sec
   logical_select_one_from_700                           1.00    295.5±1.55µs        ? ?/sec    1.00    294.1±1.60µs        ? ?/sec
   logical_trivial_join_high_numbered_columns            1.00    249.4±1.14µs        ? ?/sec    1.01    252.1±1.54µs        ? ?/sec
   logical_trivial_join_low_numbered_columns             1.00    236.2±1.41µs        ? ?/sec    1.00    237.1±1.31µs        ? ?/sec
   logical_union_4_branches                              1.00    390.9±1.68µs        ? ?/sec    1.00    391.0±1.42µs        ? ?/sec
   logical_union_8_branches                              1.00    786.3±1.92µs        ? ?/sec    1.00    784.9±1.97µs        ? ?/sec
   logical_wide_aggregate_100_exprs                      1.00      3.9±0.01ms        ? ?/sec    1.00      3.9±0.01ms        ? ?/sec
   logical_wide_case_50_exprs                            1.00   1799.2±6.45µs        ? ?/sec    1.01   1809.7±6.86µs        ? ?/sec
   logical_wide_filter_200_predicates                    1.00   1306.0±9.76µs        ? ?/sec    1.00   1312.5±6.31µs        ? ?/sec
   logical_wide_filter_50_predicates                     1.00    361.2±2.17µs        ? ?/sec    1.00    359.8±1.39µs        ? ?/sec
   optimizer_correlated_exists                           1.01    227.3±0.60µs        ? ?/sec    1.00    226.1±0.49µs        ? ?/sec
   optimizer_join_4_with_agg_filter                      1.03    420.3±1.63µs        ? ?/sec    1.00    409.1±1.40µs        ? ?/sec
   optimizer_join_chain_4                                1.02    161.6±0.33µs        ? ?/sec    1.00    158.9±0.20µs        ? ?/sec
   optimizer_join_chain_8                                1.01    548.3±1.35µs        ? ?/sec    1.00    545.5±0.81µs        ? ?/sec
   optimizer_select_all_from_1000                        1.00      6.7±0.01ms        ? ?/sec    1.00      6.7±0.02ms        ? ?/sec
   optimizer_select_one_from_700                         1.00    239.0±0.41µs        ? ?/sec    1.00    238.9±0.42µs        ? ?/sec
   optimizer_tpcds_all                                   1.00    287.5±0.42ms        ? ?/sec    1.00    288.5±1.01ms        ? ?/sec
   optimizer_tpch_all                                    1.00     15.9±0.04ms        ? ?/sec    1.00     15.9±0.13ms        ? ?/sec
   optimizer_wide_aggregate_100                          1.01   1793.9±4.57µs        ? ?/sec    1.00   1783.4±3.98µs        ? ?/sec
   optimizer_wide_filter_200                             1.00      3.9±0.01ms        ? ?/sec    1.01      3.9±0.01ms        ? ?/sec
   physical_intersection                                 1.00    575.3±1.46µs        ? ?/sec    1.01    578.9±2.15µs        ? ?/sec
   physical_join_consider_sort                           1.00   1027.4±2.26µs        ? ?/sec    1.01   1039.9±1.90µs        ? ?/sec
   physical_join_distinct                                1.00    229.9±1.36µs        ? ?/sec    1.00    229.1±1.33µs        ? ?/sec
   physical_many_self_joins                              1.00      7.8±0.02ms        ? ?/sec    1.00      7.8±0.02ms        ? ?/sec
   physical_plan_clickbench_all                          1.00    137.6±0.25ms        ? ?/sec    1.02    139.7±0.92ms        ? ?/sec
   physical_plan_clickbench_q1                           1.00   1343.2±8.35µs        ? ?/sec    1.07   1441.6±8.22µs        ? ?/sec
   physical_plan_clickbench_q10                          1.00   1943.8±4.00µs        ? ?/sec    1.00   1942.8±7.01µs        ? ?/sec
   physical_plan_clickbench_q11                          1.00      2.1±0.00ms        ? ?/sec    1.00      2.1±0.00ms        ? ?/sec
   physical_plan_clickbench_q12                          1.00      2.2±0.00ms        ? ?/sec    1.00      2.2±0.00ms        ? ?/sec
   physical_plan_clickbench_q13                          1.00   1968.6±6.42µs        ? ?/sec    1.00   1972.2±4.73µs        ? ?/sec
   physical_plan_clickbench_q14                          1.00      2.1±0.00ms        ? ?/sec    1.00      2.1±0.01ms        ? ?/sec
   physical_plan_clickbench_q15                          1.00      2.0±0.00ms        ? ?/sec    1.00      2.0±0.00ms        ? ?/sec
   physical_plan_clickbench_q16                          1.00   1733.1±3.84µs        ? ?/sec    1.00   1729.6±4.88µs        ? ?/sec
   physical_plan_clickbench_q17                          1.00   1779.9±4.27µs        ? ?/sec    1.00   1782.5±6.06µs        ? ?/sec
   physical_plan_clickbench_q18                          1.00   1632.6±3.43µs        ? ?/sec    1.00   1634.6±4.83µs        ? ?/sec
   physical_plan_clickbench_q19                          1.00   1977.2±4.19µs        ? ?/sec    1.00   1973.8±5.62µs        ? ?/sec
   physical_plan_clickbench_q2                           1.00   1732.0±3.82µs        ? ?/sec    1.00   1735.7±5.27µs        ? ?/sec
   physical_plan_clickbench_q20                          1.00   1510.8±4.58µs        ? ?/sec    1.00   1508.9±5.70µs        ? ?/sec
   physical_plan_clickbench_q21                          1.00   1723.0±6.17µs        ? ?/sec    1.00   1723.4±5.38µs        ? ?/sec
   physical_plan_clickbench_q22                          1.00      2.1±0.00ms        ? ?/sec    1.00      2.1±0.00ms        ? ?/sec
   physical_plan_clickbench_q23                          1.01      2.2±0.00ms        ? ?/sec    1.00      2.2±0.00ms        ? ?/sec
   physical_plan_clickbench_q24                          1.00      5.1±0.01ms        ? ?/sec    1.00      5.1±0.01ms        ? ?/sec
   physical_plan_clickbench_q25                          1.00   1822.3±4.01µs        ? ?/sec    1.00   1822.6±4.88µs        ? ?/sec
   physical_plan_clickbench_q26                          1.00   1687.8±4.44µs        ? ?/sec    1.00   1692.0±5.66µs        ? ?/sec
   physical_plan_clickbench_q27                          1.00   1852.4±4.25µs        ? ?/sec    1.00   1855.1±5.01µs        ? ?/sec
   physical_plan_clickbench_q28                          1.00      2.2±0.00ms        ? ?/sec    1.00      2.2±0.01ms        ? ?/sec
   physical_plan_clickbench_q29                          1.00      2.3±0.00ms        ? ?/sec    1.00      2.3±0.01ms        ? ?/sec
   physical_plan_clickbench_q3                           1.00   1626.1±2.99µs        ? ?/sec    1.00   1626.4±5.35µs        ? ?/sec
   physical_plan_clickbench_q30                          1.00     15.0±0.02ms        ? ?/sec    1.00     15.1±0.02ms        ? ?/sec
   physical_plan_clickbench_q31                          1.00      2.3±0.00ms        ? ?/sec    1.00      2.3±0.00ms        ? ?/sec
   physical_plan_clickbench_q32                          1.00      2.3±0.00ms        ? ?/sec    1.01      2.3±0.00ms        ? ?/sec
   physical_plan_clickbench_q33                          1.00   1938.8±3.86µs        ? ?/sec    1.00   1938.9±5.90µs        ? ?/sec
   physical_plan_clickbench_q34                          1.00   1744.8±4.06µs        ? ?/sec    1.00  1752.3±10.17µs        ? ?/sec
   physical_plan_clickbench_q35                          1.00   1785.8±3.46µs        ? ?/sec    1.01  1795.3±17.88µs        ? ?/sec
   physical_plan_clickbench_q36                          1.00      2.0±0.00ms        ? ?/sec    1.00      2.0±0.01ms        ? ?/sec
   physical_plan_clickbench_q37                          1.00      2.5±0.00ms        ? ?/sec    1.00      2.5±0.01ms        ? ?/sec
   physical_plan_clickbench_q38                          1.00      2.5±0.00ms        ? ?/sec    1.00      2.5±0.01ms        ? ?/sec
   physical_plan_clickbench_q39                          1.00      2.5±0.00ms        ? ?/sec    1.00      2.5±0.00ms        ? ?/sec
   physical_plan_clickbench_q4                           1.00   1466.6±3.87µs        ? ?/sec    1.00   1468.6±4.84µs        ? ?/sec
   physical_plan_clickbench_q40                          1.00      3.2±0.01ms        ? ?/sec    1.00      3.2±0.00ms        ? ?/sec
   physical_plan_clickbench_q41                          1.00      2.7±0.00ms        ? ?/sec    1.00      2.7±0.01ms        ? ?/sec
   physical_plan_clickbench_q42                          1.00      2.8±0.01ms        ? ?/sec    1.00      2.8±0.01ms        ? ?/sec
   physical_plan_clickbench_q43                          1.00      3.0±0.01ms        ? ?/sec    1.00      3.0±0.01ms        ? ?/sec
   physical_plan_clickbench_q44                          1.00   1540.9±4.01µs        ? ?/sec    1.00   1535.0±5.24µs        ? ?/sec
   physical_plan_clickbench_q45                          1.00   1547.9±3.53µs        ? ?/sec    1.00   1540.7±4.94µs        ? ?/sec
   physical_plan_clickbench_q46                          1.01   1789.8±4.06µs        ? ?/sec    1.00   1779.1±5.50µs        ? ?/sec
   physical_plan_clickbench_q47                          1.00      2.4±0.00ms        ? ?/sec    1.00      2.4±0.01ms        ? ?/sec
   physical_plan_clickbench_q48                          1.00      2.5±0.00ms        ? ?/sec    1.00      2.5±0.01ms        ? ?/sec
   physical_plan_clickbench_q49                          1.00      2.6±0.00ms        ? ?/sec    1.00      2.6±0.01ms        ? ?/sec
   physical_plan_clickbench_q5                           1.00   1582.6±5.10µs        ? ?/sec    1.00   1579.8±4.77µs        ? ?/sec
   physical_plan_clickbench_q50                          1.00      2.6±0.00ms        ? ?/sec    1.00      2.6±0.00ms        ? ?/sec
   physical_plan_clickbench_q51                          1.01  1903.8±11.68µs        ? ?/sec    1.00   1891.7±6.37µs        ? ?/sec
   physical_plan_clickbench_q52                          1.00      2.4±0.01ms        ? ?/sec    1.00      2.4±0.01ms        ? ?/sec
   physical_plan_clickbench_q53                          1.01   1750.5±3.91µs        ? ?/sec    1.00   1741.1±9.76µs        ? ?/sec
   physical_plan_clickbench_q54                          1.00   1752.9±4.50µs        ? ?/sec    1.00  1748.8±22.14µs        ? ?/sec
   physical_plan_clickbench_q55                          1.00   1691.5±4.93µs        ? ?/sec    1.00  1690.0±10.90µs        ? ?/sec
   physical_plan_clickbench_q56                          1.00   1692.4±4.66µs        ? ?/sec    1.00   1689.4±7.55µs        ? ?/sec
   physical_plan_clickbench_q57                          1.00   1792.2±5.32µs        ? ?/sec    1.01  1806.6±14.98µs        ? ?/sec
   physical_plan_clickbench_q58                          1.00      2.2±0.00ms        ? ?/sec    1.02      2.3±0.02ms        ? ?/sec
   physical_plan_clickbench_q59                          1.00   1694.4±3.55µs        ? ?/sec    1.01  1709.0±10.17µs        ? ?/sec
   physical_plan_clickbench_q6                           1.00   1589.7±4.36µs        ? ?/sec    1.00   1583.6±5.43µs        ? ?/sec
   physical_plan_clickbench_q60                          1.00   1695.2±4.50µs        ? ?/sec    1.00   1694.3±6.39µs        ? ?/sec
   physical_plan_clickbench_q7                           1.00   1413.3±4.17µs        ? ?/sec    1.10   1560.2±5.57µs        ? ?/sec
   physical_plan_clickbench_q8                           1.00   1908.4±3.87µs        ? ?/sec    1.00   1910.6±5.02µs        ? ?/sec
   physical_plan_clickbench_q9                           1.00   1856.9±3.91µs        ? ?/sec    1.00   1858.2±6.51µs        ? ?/sec
   physical_plan_struct_join_agg_sort                    1.00   1250.5±2.06µs        ? ?/sec    1.02   1273.4±2.72µs        ? ?/sec
   physical_plan_tpcds_all                               1.00    655.0±3.26ms        ? ?/sec    1.00    653.1±0.44ms        ? ?/sec
   physical_plan_tpch_all                                1.00     42.0±0.03ms        ? ?/sec    1.00     42.1±0.04ms        ? ?/sec
   physical_plan_tpch_q1                                 1.00   1417.9±2.93µs        ? ?/sec    1.01   1432.8±3.46µs        ? ?/sec
   physical_plan_tpch_q10                                1.00      2.3±0.00ms        ? ?/sec    1.00      2.3±0.00ms        ? ?/sec
   physical_plan_tpch_q11                                1.00      2.2±0.00ms        ? ?/sec    1.00      2.2±0.00ms        ? ?/sec
   physical_plan_tpch_q12                                1.00   1215.5±1.90µs        ? ?/sec    1.01   1223.4±2.12µs        ? ?/sec
   physical_plan_tpch_q13                                1.00   1001.1±1.97µs        ? ?/sec    1.01   1013.5±2.41µs        ? ?/sec
   physical_plan_tpch_q14                                1.01   1319.9±2.99µs        ? ?/sec    1.00   1313.3±5.54µs        ? ?/sec
   physical_plan_tpch_q16                                1.00   1592.7±1.90µs        ? ?/sec    1.01   1602.3±3.48µs        ? ?/sec
   physical_plan_tpch_q17                                1.00   1595.3±2.37µs        ? ?/sec    1.00   1595.5±4.78µs        ? ?/sec
   physical_plan_tpch_q18                                1.00   1888.0±2.58µs        ? ?/sec    1.01   1898.6±2.65µs        ? ?/sec
   physical_plan_tpch_q19                                1.00   1798.9±3.14µs        ? ?/sec    1.00   1799.2±2.50µs        ? ?/sec
   physical_plan_tpch_q2                                 1.00      3.5±0.00ms        ? ?/sec    1.01      3.5±0.00ms        ? ?/sec
   physical_plan_tpch_q20                                1.00      2.0±0.00ms        ? ?/sec    1.01      2.1±0.00ms        ? ?/sec
   physical_plan_tpch_q21                                1.00      2.7±0.00ms        ? ?/sec    1.00      2.7±0.01ms        ? ?/sec
   physical_plan_tpch_q22                                1.00   1473.9±2.35µs        ? ?/sec    1.01   1482.8±5.17µs        ? ?/sec
   physical_plan_tpch_q3                                 1.00   1753.2±3.04µs        ? ?/sec    1.01   1769.4±3.26µs        ? ?/sec
   physical_plan_tpch_q4                                 1.00   1110.5±1.67µs        ? ?/sec    1.01   1118.2±2.63µs        ? ?/sec
   physical_plan_tpch_q5                                 1.00      2.5±0.00ms        ? ?/sec    1.00      2.5±0.00ms        ? ?/sec
   physical_plan_tpch_q6                                 1.01    584.3±1.23µs        ? ?/sec    1.00    579.6±1.67µs        ? ?/sec
   physical_plan_tpch_q7                                 1.00      2.7±0.00ms        ? ?/sec    1.00      2.7±0.00ms        ? ?/sec
   physical_plan_tpch_q8                                 1.00      3.6±0.00ms        ? ?/sec    1.01      3.7±0.01ms        ? ?/sec
   physical_plan_tpch_q9                                 1.00      2.6±0.00ms        ? ?/sec    1.00      2.6±0.00ms        ? ?/sec
   physical_select_aggregates_from_200                   1.01     12.4±0.02ms        ? ?/sec    1.00     12.2±0.02ms        ? ?/sec
   physical_select_all_from_1000                         1.00     19.7±0.05ms        ? ?/sec    1.00     19.8±0.06ms        ? ?/sec
   physical_select_one_from_700                          1.00    745.5±2.24µs        ? ?/sec    1.01    755.0±3.18µs        ? ?/sec
   physical_sorted_union_order_by_10_int64               1.00      3.8±0.00ms        ? ?/sec    1.01      3.8±0.00ms        ? ?/sec
   physical_sorted_union_order_by_10_uint64              1.01      7.5±0.01ms        ? ?/sec    1.00      7.5±0.03ms        ? ?/sec
   physical_sorted_union_order_by_50_int64               1.00     83.0±0.26ms        ? ?/sec    1.01     83.5±0.19ms        ? ?/sec
   physical_sorted_union_order_by_50_uint64              1.00    294.8±0.45ms        ? ?/sec    1.01    298.6±3.95ms        ? ?/sec
   physical_theta_join_consider_sort                     1.00   1057.2±1.49µs        ? ?/sec    1.01   1065.4±2.17µs        ? ?/sec
   physical_unnest_to_join                               1.00    618.7±1.92µs        ? ?/sec    1.02    628.2±2.07µs        ? ?/sec
   physical_window_function_partition_by_12_on_values    1.00    656.8±1.41µs        ? ?/sec    1.01    660.5±1.23µs        ? ?/sec
   physical_window_function_partition_by_30_on_values    1.00   1302.8±1.63µs        ? ?/sec    1.01   1312.7±2.23µs        ? ?/sec
   physical_window_function_partition_by_4_on_values     1.03    411.6±1.29µs        ? ?/sec    1.00    401.3±0.71µs        ? ?/sec
   physical_window_function_partition_by_7_on_values     1.00    495.7±0.98µs        ? ?/sec    1.00    496.3±1.54µs        ? ?/sec
   physical_window_function_partition_by_8_on_values     1.00    532.7±0.86µs        ? ?/sec    1.00    531.3±1.33µs        ? ?/sec
   with_param_values_many_columns                        1.00    433.2±2.64µs        ? ?/sec    1.00    434.2±3.26µs        ? ?/sec
   ```
   
   </p>
   </details>
   
   <details><summary>Resource Usage</summary>
   
   **sql_planner — base (merge-base)**
   | Metric | Value |
   |--------|-------|
   | Wall time | 2060.4s |
   | Peak memory | 137.8 MiB |
   | Avg memory | 87.5 MiB |
   | CPU user | 1984.7s |
   | CPU sys | 1.3s |
   | Peak spill | 0 B |
   
   **sql_planner — branch**
   | Metric | Value |
   |--------|-------|
   | Wall time | 2045.5s |
   | Peak memory | 134.1 MiB |
   | Avg memory | 86.8 MiB |
   | CPU user | 1982.9s |
   | CPU sys | 1.4s |
   | Peak spill | 0 B |
   
   </details>
   
   
   ---
   [File an issue](https://github.com/adriangb/datafusion-benchmarking/issues) against this benchmark runner


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] feat: run physical requirement enforcement first, as a PhysicalAnalyzer phase [datafusion]

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on code in PR #25688:
URL: https://github.com/apache/datafusion/pull/25688#discussion_r4158012389


##########
datafusion/physical-optimizer/src/analyzer.rs:
##########
@@ -0,0 +1,153 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+//! Physical analyzer
+
+use std::sync::Arc;
+
+use crate::ensure_requirements::{EnforceDistribution, EnforceSorting};
+use crate::output_requirements::OutputRequirements;
+
+// Re-export from this module for convenience.
+pub use datafusion_session::PhysicalAnalyzerRule;
+
+/// A rule-based physical analyzer.
+///
+/// Analyzer rules make the plan *valid*: they enforce the invariants every
+/// operator declares (distribution, ordering) rather than making the plan
+/// faster, mirroring the logical layer's `Analyzer`/`Optimizer` split. The
+/// default planner runs the whole analyzer phase before the
+/// [`PhysicalOptimizer`](crate::optimizer::PhysicalOptimizer) phase, so every
+/// optimizer rule can assume it receives a valid plan; see
+/// [`PhysicalAnalyzerRule`] for details.
+#[derive(Clone, Debug)]
+pub struct PhysicalAnalyzer {
+    /// All rules to apply
+    pub rules: Vec<Arc<dyn PhysicalAnalyzerRule + Send + Sync>>,
+}
+
+impl Default for PhysicalAnalyzer {
+    fn default() -> Self {
+        Self::new()
+    }
+}
+
+impl PhysicalAnalyzer {
+    /// Create a new analyzer using the recommended list of rules
+    pub fn new() -> Self {
+        // All enforcement runs here, first, as the analyzer phase: it makes the
+        // plan *valid* (distribution first, then ordering) before any optimizer
+        // rule sees it, mirroring the logical Analyzer/Optimizer split. The
+        // optimizer rules that change these requirements (`JoinSelection`,
+        // `WindowTopN`, `FilterPushdown`) re-establish validity themselves, so
+        // enforcement is not repeated as an optimizer pass. The sort
+        // *optimizations* (`OptimizeSorts`) are not enforcement and stay in the
+        // optimizer phase.
+        let rules: Vec<Arc<dyn PhysicalAnalyzerRule + Send + Sync>> = vec![
+            // Establish the output-requirement boundary first, so enforcement can
+            // see it (parallelize top-level scans below it, preserve the query's
+            // final ordering). The matching remove pass runs late in the optimizer.
+            Arc::new(OutputRequirements::new_add_mode()),
+            Arc::new(EnforceDistribution::new()),

Review Comment:
   > JoinSelection and FilterPushdown re-establish distribution only, since neither changes any operator ordering.
   
   Maybe to cut down the initial PR scope we could keep them as the same pass (aka `EnforceDistribution`)
   
   Then as a follow on PR we could then split them into separate passes (and it would be clear how to measure / evaluate the impact)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] feat: run physical requirement enforcement first, as a PhysicalAnalyzer phase [datafusion]

Posted by "adriangbot (via GitHub)" <gi...@apache.org>.
adriangbot commented on PR #25688:
URL: https://github.com/apache/datafusion/pull/25688#issuecomment-5947785570

   🤖 Benchmark completed (GKE) | [trigger](https://github.com/apache/datafusion/pull/25688#issuecomment-5946668057)
   
   **Instance:** `c4a-highcpu-48` (12 vCPU / 65 GiB)
   
   Comparing physical-analyzer-rule (79c63dab6706c4eb16304173a226d5b31d24ce92) to 4d167a1 (merge-base) [diff](https://github.com/apache/datafusion/compare/4d167a167228a424ef8cc29fd6bea5f17fc23c2a..79c63dab6706c4eb16304173a226d5b31d24ce92)
   
   <details><summary>Run configuration</summary>
   
   ```yaml
   run benchmark sql_planner
   ```
   
   </details>
   
   <details><summary>CPU Details (lscpu)</summary>
   
   ```
   Architecture:                            aarch64
   CPU op-mode(s):                          64-bit
   Byte Order:                              Little Endian
   CPU(s):                                  48
   On-line CPU(s) list:                     0-47
   Vendor ID:                               ARM
   Model name:                              Neoverse-V2
   Model:                                   1
   Thread(s) per core:                      1
   Core(s) per cluster:                     48
   Socket(s):                               -
   Cluster(s):                              1
   Stepping:                                r0p1
   BogoMIPS:                                2000.00
   Flags:                                   fp asimd evtstrm aes pmull sha1 sha2 crc32 atomics fphp asimdhp cpuid asimdrdm jscvt fcma lrcpc dcpop sha3 sm3 sm4 asimddp sha512 sve asimdfhm dit uscat ilrcpc flagm sb paca pacg dcpodp sve2 sveaes svepmull svebitperm svesha3 svesm4 flagm2 frint svei8mm svebf16 i8mm bf16 dgh rng bti
   L1d cache:                               3 MiB (48 instances)
   L1i cache:                               3 MiB (48 instances)
   L2 cache:                                96 MiB (48 instances)
   L3 cache:                                80 MiB (1 instance)
   NUMA node(s):                            1
   NUMA node0 CPU(s):                       0-47
   Vulnerability Gather data sampling:      Not affected
   Vulnerability Indirect target selection: Not affected
   Vulnerability Itlb multihit:             Not affected
   Vulnerability L1tf:                      Not affected
   Vulnerability Mds:                       Not affected
   Vulnerability Meltdown:                  Not affected
   Vulnerability Mmio stale data:           Not affected
   Vulnerability Reg file data sampling:    Not affected
   Vulnerability Retbleed:                  Not affected
   Vulnerability Spec rstack overflow:      Not affected
   Vulnerability Spec store bypass:         Mitigation; Speculative Store Bypass disabled via prctl
   Vulnerability Spectre v1:                Mitigation; __user pointer sanitization
   Vulnerability Spectre v2:                Mitigation; CSV2, BHB
   Vulnerability Srbds:                     Not affected
   Vulnerability Tsa:                       Not affected
   Vulnerability Tsx async abort:           Not affected
   Vulnerability Vmscape:                   Not affected
   ```
   
   </details>
   
   <details><summary>Details</summary>
   <p>
   
   ```
   group                                                 HEAD                                   physical-analyzer-rule
   -----                                                 ----                                   ----------------------
   logical_aggregate_with_join                           1.00    401.8±1.66µs        ? ?/sec    1.00    400.4±1.66µs        ? ?/sec
   logical_correlated_subquery_exists                    1.01    246.5±0.75µs        ? ?/sec    1.00    244.6±0.79µs        ? ?/sec
   logical_correlated_subquery_in                        1.01    248.3±1.47µs        ? ?/sec    1.00    246.5±1.62µs        ? ?/sec
   logical_distinct_many_columns                         1.00    333.1±0.63µs        ? ?/sec    1.00    331.7±1.29µs        ? ?/sec
   logical_join_4_with_agg_and_filter                    1.01    201.2±1.45µs        ? ?/sec    1.00    199.4±0.67µs        ? ?/sec
   logical_join_8_with_agg_sort_limit                    1.02    365.4±5.87µs        ? ?/sec    1.00    357.2±1.61µs        ? ?/sec
   logical_join_chain_16                                 1.03   653.4±27.64µs        ? ?/sec    1.00    633.0±1.22µs        ? ?/sec
   logical_join_chain_4                                  1.03     80.3±0.83µs        ? ?/sec    1.00     78.3±0.23µs        ? ?/sec
   logical_join_chain_8                                  1.03    213.6±5.53µs        ? ?/sec    1.00    207.3±0.58µs        ? ?/sec
   logical_multiple_subqueries                           1.00    480.1±1.94µs        ? ?/sec    1.02    489.3±1.84µs        ? ?/sec
   logical_nested_cte_4_levels                           1.02    222.3±1.11µs        ? ?/sec    1.00    218.6±1.45µs        ? ?/sec
   logical_plan_struct_join_agg_sort                     1.01    126.7±0.65µs        ? ?/sec    1.00    126.0±0.70µs        ? ?/sec
   logical_plan_tpcds_all                                1.01     83.1±0.20ms        ? ?/sec    1.00     82.0±0.18ms        ? ?/sec
   logical_plan_tpch_all                                 1.01      5.6±0.03ms        ? ?/sec    1.00      5.6±0.01ms        ? ?/sec
   logical_scalar_subquery                               1.00    266.1±0.78µs        ? ?/sec    1.00    265.0±0.86µs        ? ?/sec
   logical_select_all_from_1000                          1.00      9.1±0.03ms        ? ?/sec    1.01      9.2±0.04ms        ? ?/sec
   logical_select_one_from_700                           1.00    290.5±1.43µs        ? ?/sec    1.02    295.3±2.00µs        ? ?/sec
   logical_trivial_join_high_numbered_columns            1.00    246.9±1.45µs        ? ?/sec    1.00    247.7±1.75µs        ? ?/sec
   logical_trivial_join_low_numbered_columns             1.00    234.0±1.34µs        ? ?/sec    1.00    234.4±1.57µs        ? ?/sec
   logical_union_4_branches                              1.00    391.5±1.78µs        ? ?/sec    1.00    392.2±7.14µs        ? ?/sec
   logical_union_8_branches                              1.00    792.7±1.91µs        ? ?/sec    1.00   789.7±13.04µs        ? ?/sec
   logical_wide_aggregate_1000_exprs                     1.01     44.3±0.12ms        ? ?/sec    1.00     44.0±0.08ms        ? ?/sec
   logical_wide_aggregate_100_exprs                      1.00   1640.7±2.94µs        ? ?/sec    1.00   1638.6±2.89µs        ? ?/sec
   logical_wide_case_50_exprs                            1.01   1816.5±4.75µs        ? ?/sec    1.00   1807.3±4.74µs        ? ?/sec
   logical_wide_filter_200_predicates                    1.01   1336.0±5.98µs        ? ?/sec    1.00   1325.3±6.68µs        ? ?/sec
   logical_wide_filter_50_predicates                     1.02    368.1±2.03µs        ? ?/sec    1.00    360.6±1.48µs        ? ?/sec
   optimizer_correlated_exists                           1.00    224.4±0.66µs        ? ?/sec    1.00    223.9±0.49µs        ? ?/sec
   optimizer_join_4_with_agg_filter                      1.02    422.4±0.77µs        ? ?/sec    1.00    413.7±1.40µs        ? ?/sec
   optimizer_join_chain_4                                1.02    163.9±0.27µs        ? ?/sec    1.00    161.4±0.53µs        ? ?/sec
   optimizer_join_chain_8                                1.00    550.3±0.79µs        ? ?/sec    1.00    549.3±0.87µs        ? ?/sec
   optimizer_select_all_from_1000                        1.00      7.1±0.04ms        ? ?/sec    1.00      7.1±0.02ms        ? ?/sec
   optimizer_select_one_from_700                         1.00    233.5±0.34µs        ? ?/sec    1.01    235.3±0.52µs        ? ?/sec
   optimizer_tpcds_all                                   1.03    291.2±2.55ms        ? ?/sec    1.00    284.0±0.42ms        ? ?/sec
   optimizer_tpch_all                                    1.03     16.0±0.06ms        ? ?/sec    1.00     15.5±0.02ms        ? ?/sec
   optimizer_wide_aggregate_100                          1.01   1800.2±3.04µs        ? ?/sec    1.00   1781.1±3.73µs        ? ?/sec
   optimizer_wide_filter_200                             1.01      4.0±0.01ms        ? ?/sec    1.00      3.9±0.01ms        ? ?/sec
   physical_intersection                                 1.01    574.6±2.43µs        ? ?/sec    1.00    567.8±2.42µs        ? ?/sec
   physical_join_consider_sort                           1.00   1039.6±7.16µs        ? ?/sec    1.00   1035.6±5.31µs        ? ?/sec
   physical_join_distinct                                1.01    227.7±1.50µs        ? ?/sec    1.00    226.4±1.52µs        ? ?/sec
   physical_many_self_joins                              1.00      7.6±0.01ms        ? ?/sec    1.01      7.7±0.03ms        ? ?/sec
   physical_plan_clickbench_all                          1.01    139.4±0.37ms        ? ?/sec    1.00    138.1±0.26ms        ? ?/sec
   physical_plan_clickbench_q1                           1.00   1387.7±7.54µs        ? ?/sec    1.00   1386.1±8.65µs        ? ?/sec
   physical_plan_clickbench_q10                          1.00      2.0±0.01ms        ? ?/sec    1.00      2.0±0.01ms        ? ?/sec
   physical_plan_clickbench_q11                          1.01      2.2±0.01ms        ? ?/sec    1.00      2.2±0.01ms        ? ?/sec
   physical_plan_clickbench_q12                          1.00      2.2±0.01ms        ? ?/sec    1.00      2.3±0.01ms        ? ?/sec
   physical_plan_clickbench_q13                          1.00      2.0±0.01ms        ? ?/sec    1.00      2.0±0.01ms        ? ?/sec
   physical_plan_clickbench_q14                          1.00      2.2±0.01ms        ? ?/sec    1.00      2.2±0.01ms        ? ?/sec
   physical_plan_clickbench_q15                          1.00      2.1±0.01ms        ? ?/sec    1.00      2.1±0.01ms        ? ?/sec
   physical_plan_clickbench_q16                          1.00   1796.3±6.09µs        ? ?/sec    1.00   1794.8±5.47µs        ? ?/sec
   physical_plan_clickbench_q17                          1.00   1845.0±5.95µs        ? ?/sec    1.00   1841.7±5.70µs        ? ?/sec
   physical_plan_clickbench_q18                          1.00   1698.2±6.22µs        ? ?/sec    1.00   1690.8±4.28µs        ? ?/sec
   physical_plan_clickbench_q19                          1.00      2.0±0.01ms        ? ?/sec    1.00      2.0±0.01ms        ? ?/sec
   physical_plan_clickbench_q2                           1.02   1789.5±7.01µs        ? ?/sec    1.00   1762.5±4.39µs        ? ?/sec
   physical_plan_clickbench_q20                          1.00   1569.2±6.26µs        ? ?/sec    1.00   1564.5±4.68µs        ? ?/sec
   physical_plan_clickbench_q21                          1.00   1783.9±7.80µs        ? ?/sec    1.01  1794.4±13.25µs        ? ?/sec
   physical_plan_clickbench_q22                          1.00      2.1±0.01ms        ? ?/sec    1.00      2.1±0.01ms        ? ?/sec
   physical_plan_clickbench_q23                          1.00      2.3±0.01ms        ? ?/sec    1.00      2.3±0.01ms        ? ?/sec
   physical_plan_clickbench_q24                          1.00      5.2±0.01ms        ? ?/sec    1.00      5.2±0.01ms        ? ?/sec
   physical_plan_clickbench_q25                          1.00   1880.9±6.59µs        ? ?/sec    1.00   1882.1±5.50µs        ? ?/sec
   physical_plan_clickbench_q26                          1.00   1744.0±6.39µs        ? ?/sec    1.00   1744.3±5.44µs        ? ?/sec
   physical_plan_clickbench_q27                          1.00   1912.0±6.29µs        ? ?/sec    1.00   1914.5±5.39µs        ? ?/sec
   physical_plan_clickbench_q28                          1.00      2.3±0.01ms        ? ?/sec    1.00      2.3±0.00ms        ? ?/sec
   physical_plan_clickbench_q29                          1.00      2.4±0.01ms        ? ?/sec    1.00      2.4±0.01ms        ? ?/sec
   physical_plan_clickbench_q3                           1.01   1675.3±6.90µs        ? ?/sec    1.00   1651.5±7.65µs        ? ?/sec
   physical_plan_clickbench_q30                          1.00     12.8±0.02ms        ? ?/sec    1.00     12.8±0.02ms        ? ?/sec
   physical_plan_clickbench_q31                          1.00      2.4±0.01ms        ? ?/sec    1.00      2.4±0.01ms        ? ?/sec
   physical_plan_clickbench_q32                          1.00      2.4±0.01ms        ? ?/sec    1.00      2.4±0.01ms        ? ?/sec
   physical_plan_clickbench_q33                          1.00      2.0±0.00ms        ? ?/sec    1.00   1998.5±3.97µs        ? ?/sec
   physical_plan_clickbench_q34                          1.00   1803.2±6.75µs        ? ?/sec    1.00   1809.2±4.56µs        ? ?/sec
   physical_plan_clickbench_q35                          1.00   1847.0±6.26µs        ? ?/sec    1.00   1849.6±5.89µs        ? ?/sec
   physical_plan_clickbench_q36                          1.00      2.1±0.01ms        ? ?/sec    1.00      2.1±0.01ms        ? ?/sec
   physical_plan_clickbench_q37                          1.01      2.5±0.01ms        ? ?/sec    1.00      2.5±0.01ms        ? ?/sec
   physical_plan_clickbench_q38                          1.01      2.5±0.01ms        ? ?/sec    1.00      2.5±0.00ms        ? ?/sec
   physical_plan_clickbench_q39                          1.02      2.6±0.01ms        ? ?/sec    1.00      2.6±0.01ms        ? ?/sec
   physical_plan_clickbench_q4                           1.02   1521.7±6.61µs        ? ?/sec    1.00   1492.0±4.35µs        ? ?/sec
   physical_plan_clickbench_q40                          1.00      3.2±0.01ms        ? ?/sec    1.00      3.2±0.01ms        ? ?/sec
   physical_plan_clickbench_q41                          1.00      2.8±0.01ms        ? ?/sec    1.00      2.8±0.01ms        ? ?/sec
   physical_plan_clickbench_q42                          1.01      2.9±0.01ms        ? ?/sec    1.00      2.9±0.01ms        ? ?/sec
   physical_plan_clickbench_q43                          1.01      3.1±0.01ms        ? ?/sec    1.00      3.1±0.01ms        ? ?/sec
   physical_plan_clickbench_q44                          1.01   1593.8±5.82µs        ? ?/sec    1.00   1577.8±4.56µs        ? ?/sec
   physical_plan_clickbench_q45                          1.01   1600.7±6.42µs        ? ?/sec    1.00   1582.4±5.26µs        ? ?/sec
   physical_plan_clickbench_q46                          1.01   1846.7±6.94µs        ? ?/sec    1.00   1831.6±6.23µs        ? ?/sec
   physical_plan_clickbench_q47                          1.01      2.4±0.01ms        ? ?/sec    1.00      2.4±0.00ms        ? ?/sec
   physical_plan_clickbench_q48                          1.01      2.6±0.01ms        ? ?/sec    1.00      2.6±0.00ms        ? ?/sec
   physical_plan_clickbench_q49                          1.01      2.6±0.01ms        ? ?/sec    1.00      2.6±0.01ms        ? ?/sec
   physical_plan_clickbench_q5                           1.01   1636.6±6.11µs        ? ?/sec    1.00   1613.1±3.82µs        ? ?/sec
   physical_plan_clickbench_q50                          1.00      2.7±0.01ms        ? ?/sec    1.01      2.7±0.02ms        ? ?/sec
   physical_plan_clickbench_q51                          1.01   1955.0±7.59µs        ? ?/sec    1.00   1933.4±5.38µs        ? ?/sec
   physical_plan_clickbench_q52                          1.01      2.5±0.01ms        ? ?/sec    1.00      2.4±0.01ms        ? ?/sec
   physical_plan_clickbench_q53                          1.01   1806.0±6.83µs        ? ?/sec    1.00   1787.4±4.09µs        ? ?/sec
   physical_plan_clickbench_q54                          1.01   1808.0±7.60µs        ? ?/sec    1.00   1787.8±5.01µs        ? ?/sec
   physical_plan_clickbench_q55                          1.01   1747.4±6.79µs        ? ?/sec    1.00   1724.2±4.29µs        ? ?/sec
   physical_plan_clickbench_q56                          1.02   1750.4±7.16µs        ? ?/sec    1.00   1723.9±4.13µs        ? ?/sec
   physical_plan_clickbench_q57                          1.02   1856.5±6.63µs        ? ?/sec    1.00   1827.8±4.80µs        ? ?/sec
   physical_plan_clickbench_q58                          1.01      2.3±0.01ms        ? ?/sec    1.00      2.3±0.01ms        ? ?/sec
   physical_plan_clickbench_q59                          1.01   1752.8±6.28µs        ? ?/sec    1.00   1729.1±4.58µs        ? ?/sec
   physical_plan_clickbench_q6                           1.02   1641.3±6.32µs        ? ?/sec    1.00   1615.5±4.19µs        ? ?/sec
   physical_plan_clickbench_q60                          1.01   1753.3±6.81µs        ? ?/sec    1.00   1727.9±3.52µs        ? ?/sec
   physical_plan_clickbench_q7                           1.02   1458.4±6.38µs        ? ?/sec    1.00   1431.6±3.62µs        ? ?/sec
   physical_plan_clickbench_q8                           1.02   1975.7±8.40µs        ? ?/sec    1.00   1942.6±4.92µs        ? ?/sec
   physical_plan_clickbench_q9                           1.02   1919.2±6.99µs        ? ?/sec    1.00   1890.1±4.90µs        ? ?/sec
   physical_plan_struct_join_agg_sort                    1.00   1269.7±2.66µs        ? ?/sec    1.00   1268.3±3.39µs        ? ?/sec
   physical_plan_tpcds_all                               1.00    657.2±0.51ms        ? ?/sec    1.00    654.7±1.19ms        ? ?/sec
   physical_plan_tpch_all                                1.00     42.7±0.04ms        ? ?/sec    1.00     42.7±0.31ms        ? ?/sec
   physical_plan_tpch_q1                                 1.01   1420.6±2.43µs        ? ?/sec    1.00   1410.5±4.10µs        ? ?/sec
   physical_plan_tpch_q10                                1.00      2.4±0.00ms        ? ?/sec    1.00      2.3±0.00ms        ? ?/sec
   physical_plan_tpch_q11                                1.01      2.2±0.00ms        ? ?/sec    1.00      2.2±0.00ms        ? ?/sec
   physical_plan_tpch_q12                                1.01   1249.4±4.02µs        ? ?/sec    1.00   1235.0±1.78µs        ? ?/sec
   physical_plan_tpch_q13                                1.03   1052.6±1.59µs        ? ?/sec    1.00   1026.0±2.28µs        ? ?/sec
   physical_plan_tpch_q14                                1.01   1345.1±4.55µs        ? ?/sec    1.00   1333.8±2.51µs        ? ?/sec
   physical_plan_tpch_q16                                1.01   1630.3±3.82µs        ? ?/sec    1.00   1613.2±2.07µs        ? ?/sec
   physical_plan_tpch_q17                                1.01   1628.2±4.08µs        ? ?/sec    1.00   1614.3±3.40µs        ? ?/sec
   physical_plan_tpch_q18                                1.01   1912.9±3.85µs        ? ?/sec    1.00   1899.5±2.69µs        ? ?/sec
   physical_plan_tpch_q19                                1.01   1832.8±4.31µs        ? ?/sec    1.00   1813.8±3.52µs        ? ?/sec
   physical_plan_tpch_q2                                 1.00      3.5±0.00ms        ? ?/sec    1.00      3.5±0.01ms        ? ?/sec
   physical_plan_tpch_q20                                1.01      2.1±0.00ms        ? ?/sec    1.00      2.1±0.00ms        ? ?/sec
   physical_plan_tpch_q21                                1.01      2.7±0.00ms        ? ?/sec    1.00      2.7±0.00ms        ? ?/sec
   physical_plan_tpch_q22                                1.01   1518.4±3.91µs        ? ?/sec    1.00   1499.8±2.44µs        ? ?/sec
   physical_plan_tpch_q3                                 1.01   1787.8±3.75µs        ? ?/sec    1.00   1764.2±3.11µs        ? ?/sec
   physical_plan_tpch_q4                                 1.01   1145.8±1.81µs        ? ?/sec    1.00   1130.8±2.74µs        ? ?/sec
   physical_plan_tpch_q5                                 1.00      2.5±0.00ms        ? ?/sec    1.00      2.5±0.00ms        ? ?/sec
   physical_plan_tpch_q6                                 1.02    596.6±2.02µs        ? ?/sec    1.00    585.7±1.43µs        ? ?/sec
   physical_plan_tpch_q7                                 1.00      2.7±0.00ms        ? ?/sec    1.00      2.7±0.00ms        ? ?/sec
   physical_plan_tpch_q8                                 1.00      3.7±0.01ms        ? ?/sec    1.00      3.6±0.00ms        ? ?/sec
   physical_plan_tpch_q9                                 1.00      2.6±0.00ms        ? ?/sec    1.00      2.6±0.00ms        ? ?/sec
   physical_select_aggregates_from_200                   1.01      7.9±0.01ms        ? ?/sec    1.00      7.8±0.02ms        ? ?/sec
   physical_select_all_from_1000                         1.00     20.6±0.07ms        ? ?/sec    1.00     20.6±0.08ms        ? ?/sec
   physical_select_one_from_700                          1.00    736.8±3.15µs        ? ?/sec    1.00    738.5±2.45µs        ? ?/sec
   physical_sorted_union_order_by_10_int64               1.00      3.8±0.00ms        ? ?/sec    1.03      3.9±0.04ms        ? ?/sec
   physical_sorted_union_order_by_10_uint64              1.00      7.5±0.01ms        ? ?/sec    1.00      7.5±0.01ms        ? ?/sec
   physical_sorted_union_order_by_50_int64               1.00     83.5±0.22ms        ? ?/sec    1.01     84.6±0.27ms        ? ?/sec
   physical_sorted_union_order_by_50_uint64              1.00    297.4±0.53ms        ? ?/sec    1.02    304.3±2.35ms        ? ?/sec
   physical_theta_join_consider_sort                     1.00   1065.5±7.30µs        ? ?/sec    1.00   1062.3±5.44µs        ? ?/sec
   physical_unnest_to_join                               1.01    621.1±1.84µs        ? ?/sec    1.00    615.9±2.05µs        ? ?/sec
   physical_window_function_partition_by_12_on_values    1.01    674.5±6.15µs        ? ?/sec    1.00    667.3±1.69µs        ? ?/sec
   physical_window_function_partition_by_30_on_values    1.00   1321.5±3.63µs        ? ?/sec    1.00   1315.7±3.91µs        ? ?/sec
   physical_window_function_partition_by_4_on_values     1.01    411.9±1.07µs        ? ?/sec    1.00    406.5±1.73µs        ? ?/sec
   physical_window_function_partition_by_7_on_values     1.01    506.0±1.18µs        ? ?/sec    1.00    501.5±1.23µs        ? ?/sec
   physical_window_function_partition_by_8_on_values     1.02    546.5±5.40µs        ? ?/sec    1.00    538.2±1.11µs        ? ?/sec
   with_param_values_many_columns                        1.02    444.2±2.95µs        ? ?/sec    1.00    437.5±1.94µs        ? ?/sec
   ```
   
   </p>
   </details>
   
   <details><summary>Resource Usage</summary>
   
   **sql_planner — base (merge-base)**
   | Metric | Value |
   |--------|-------|
   | Wall time | 2060.5s |
   | Peak memory | 136.7 MiB |
   | Avg memory | 88.9 MiB |
   | CPU user | 2014.1s |
   | CPU sys | 1.4s |
   | Peak spill | 0 B |
   
   **sql_planner — branch**
   | Metric | Value |
   |--------|-------|
   | Wall time | 2055.5s |
   | Peak memory | 136.9 MiB |
   | Avg memory | 89.1 MiB |
   | CPU user | 2005.2s |
   | CPU sys | 1.5s |
   | Peak spill | 0 B |
   
   </details>
   
   
   ---
   [File an issue](https://github.com/adriangb/datafusion-benchmarking/issues) against this benchmark runner


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] feat: run physical requirement enforcement first, as a PhysicalAnalyzer phase [datafusion]

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on PR #25688:
URL: https://github.com/apache/datafusion/pull/25688#issuecomment-5869974075

   Please just ping me when this is ready for another look. 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] feat: run physical requirement enforcement first, as a PhysicalAnalyzer phase [datafusion]

Posted by "2010YOUY01 (via GitHub)" <gi...@apache.org>.
2010YOUY01 commented on PR #25688:
URL: https://github.com/apache/datafusion/pull/25688#issuecomment-6017924769

   My current intuition is that we can keep refactoring the existing optimizer by making more invariants and boundaries explicit, as in #26069, and use them to continuously reduce overall complexity.
   
   I think the concerns from @alamb and @zhuqi-lucas are:
   - How should we enforce those invariants?
   - How far can we go with this approach? Adding more constraints might make future changes harder to make, and even increase maintenance overhead at some point.
   
   Those concerns make a lot of sense to me. My next step is to prototype the idea and try to identify/enforce ~3 more useful boundaries or invariants, to see whether this approach can consistently reduce complexity:
   
   - If the result is strong, I'll share it as a PoC PR.
   - Otherwise, I think the lighter-weight approach @zhuqi-lucas suggested makes sense: document these preconditions locally in the relevant optimizer rules, with debug assertions where practical, rather than introducing a general boundary mechanism.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] feat: run physical requirement enforcement first, as a PhysicalAnalyzer phase [datafusion]

Posted by "github-actions[bot] (via GitHub) via github" <gi...@datafusion.apache.org>.
github-actions[bot] commented on PR #25688:
URL: https://github.com/apache/datafusion/pull/25688#issuecomment-6729845780

   Marked as draft after 14 days without activity: merge conflicts.
   
   Please address these items and mark **Ready for review** when ready.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org