Skip to content

chore: Fix no-op Transformed flags#21964

Draft
Dandandan wants to merge 1 commit intoapache:mainfrom
Dandandan:fix-transformed-noop-flags
Draft

chore: Fix no-op Transformed flags#21964
Dandandan wants to merge 1 commit intoapache:mainfrom
Dandandan:fix-transformed-noop-flags

Conversation

@Dandandan
Copy link
Copy Markdown
Contributor

@Dandandan Dandandan commented Apr 30, 2026

Which issue does this PR close?

Just some cleanup.

Rationale for this change

Some optimizer paths were returning Transformed::yes even when they preserved the original plan or expression. That can cause unnecessary follow-up optimizer work and makes the transformed flag less useful as a fixed-point signal.

What changes are included in this PR?

  • Reports Transformed::no when filter pushdown through joins, aggregates, windows, or table scans does not actually change the plan.
  • Reports Transformed::no when constant simplification preserves an expression after a runtime simplification error.
  • Tracks whether placeholder type inference actually fills in placeholder type information before reporting a transformation.
  • Preserves Transformed::no in AggregateStatistics recursive child optimization when the optimized child is the same plan handle.

Are these changes tested?

Are there any user-facing changes?

No.

@github-actions github-actions Bot added logical-expr Logical plan and expressions optimizer Optimizer rules labels Apr 30, 2026
@Dandandan
Copy link
Copy Markdown
Contributor Author

run benchmark sql_planner

@adriangbot
Copy link
Copy Markdown

🤖 Criterion benchmark running (GKE) | trigger
Instance: c4a-highmem-16 (12 vCPU / 65 GiB) | Linux bench-c4355805994-1950-rsdhw 6.12.55+ #1 SMP Sun Feb 1 08:59:41 UTC 2026 aarch64 GNU/Linux

CPU Details (lscpu)
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

Comparing fix-transformed-noop-flags (ec28734) to 702f479 (merge-base) diff
BENCH_NAME=sql_planner
BENCH_COMMAND=cargo bench --features=parquet --bench sql_planner
BENCH_FILTER=
Results will be posted here when complete


File an issue against this benchmark runner

@adriangbot
Copy link
Copy Markdown

🤖 Criterion benchmark completed (GKE) | trigger

Instance: c4a-highmem-16 (12 vCPU / 65 GiB)

CPU Details (lscpu)
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

group                                                 fix-transformed-noop-flags             main
-----                                                 --------------------------             ----
logical_aggregate_with_join                           1.01    422.5±2.62µs        ? ?/sec    1.00    419.2±1.99µs        ? ?/sec
logical_plan_struct_join_agg_sort                     1.05    177.7±0.69µs        ? ?/sec    1.00    169.8±1.03µs        ? ?/sec
logical_select_all_from_1000                          1.00      8.4±0.03ms        ? ?/sec    1.00      8.3±0.04ms        ? ?/sec
logical_select_one_from_700                           1.00    275.6±1.39µs        ? ?/sec    1.00    275.6±1.60µs        ? ?/sec
logical_trivial_join_high_numbered_columns            1.01    254.7±1.71µs        ? ?/sec    1.00    253.3±1.00µs        ? ?/sec
logical_trivial_join_low_numbered_columns             1.00    241.7±0.88µs        ? ?/sec    1.00    240.6±1.01µs        ? ?/sec
physical_intersection                                 1.02    585.1±2.36µs        ? ?/sec    1.00    575.9±1.84µs        ? ?/sec
physical_join_consider_sort                           1.01   1031.0±7.98µs        ? ?/sec    1.00   1016.4±2.21µs        ? ?/sec
physical_join_distinct                                1.00    236.3±0.74µs        ? ?/sec    1.00    235.1±0.82µs        ? ?/sec
physical_many_self_joins                              1.01      7.8±0.02ms        ? ?/sec    1.00      7.8±0.02ms        ? ?/sec
physical_plan_clickbench_all                          1.01    132.5±0.48ms        ? ?/sec    1.00    131.4±0.63ms        ? ?/sec
physical_plan_clickbench_q1                           1.00   1393.1±8.50µs        ? ?/sec    1.00   1392.2±5.94µs        ? ?/sec
physical_plan_clickbench_q10                          1.01      2.1±0.02ms        ? ?/sec    1.00      2.1±0.01ms        ? ?/sec
physical_plan_clickbench_q11                          1.00      2.3±0.02ms        ? ?/sec    1.00      2.3±0.01ms        ? ?/sec
physical_plan_clickbench_q12                          1.00      2.4±0.01ms        ? ?/sec    1.01      2.4±0.02ms        ? ?/sec
physical_plan_clickbench_q13                          1.00      2.1±0.01ms        ? ?/sec    1.01      2.1±0.01ms        ? ?/sec
physical_plan_clickbench_q14                          1.00      2.3±0.02ms        ? ?/sec    1.00      2.3±0.01ms        ? ?/sec
physical_plan_clickbench_q15                          1.00      2.2±0.02ms        ? ?/sec    1.01      2.2±0.02ms        ? ?/sec
physical_plan_clickbench_q16                          1.00  1792.9±11.89µs        ? ?/sec    1.00  1800.5±10.87µs        ? ?/sec
physical_plan_clickbench_q17                          1.00  1848.2±11.33µs        ? ?/sec    1.00   1849.0±7.34µs        ? ?/sec
physical_plan_clickbench_q18                          1.00   1660.4±8.71µs        ? ?/sec    1.01   1672.0±6.64µs        ? ?/sec
physical_plan_clickbench_q19                          1.01      2.1±0.01ms        ? ?/sec    1.00      2.1±0.01ms        ? ?/sec
physical_plan_clickbench_q2                           1.00   1794.7±6.74µs        ? ?/sec    1.01   1816.9±7.27µs        ? ?/sec
physical_plan_clickbench_q20                          1.01   1560.4±5.46µs        ? ?/sec    1.00   1552.3±6.96µs        ? ?/sec
physical_plan_clickbench_q21                          1.00   1812.1±7.77µs        ? ?/sec    1.00   1804.0±7.35µs        ? ?/sec
physical_plan_clickbench_q22                          1.01      2.3±0.01ms        ? ?/sec    1.00      2.2±0.01ms        ? ?/sec
physical_plan_clickbench_q23                          1.01      2.5±0.02ms        ? ?/sec    1.00      2.5±0.01ms        ? ?/sec
physical_plan_clickbench_q24                          1.01      5.9±0.04ms        ? ?/sec    1.00      5.9±0.04ms        ? ?/sec
physical_plan_clickbench_q25                          1.00   1966.1±9.93µs        ? ?/sec    1.00  1972.8±10.80µs        ? ?/sec
physical_plan_clickbench_q26                          1.00   1778.6±8.65µs        ? ?/sec    1.01  1798.7±15.26µs        ? ?/sec
physical_plan_clickbench_q27                          1.00  1982.8±14.47µs        ? ?/sec    1.00   1985.5±9.75µs        ? ?/sec
physical_plan_clickbench_q28                          1.01      2.5±0.03ms        ? ?/sec    1.00      2.5±0.02ms        ? ?/sec
physical_plan_clickbench_q29                          1.01      2.7±0.02ms        ? ?/sec    1.00      2.7±0.03ms        ? ?/sec
physical_plan_clickbench_q3                           1.00   1666.1±9.55µs        ? ?/sec    1.00   1668.8±5.66µs        ? ?/sec
physical_plan_clickbench_q30                          1.00     16.7±0.04ms        ? ?/sec    1.00     16.7±0.04ms        ? ?/sec
physical_plan_clickbench_q31                          1.01      2.6±0.02ms        ? ?/sec    1.00      2.5±0.02ms        ? ?/sec
physical_plan_clickbench_q32                          1.01      2.6±0.02ms        ? ?/sec    1.00      2.5±0.01ms        ? ?/sec
physical_plan_clickbench_q33                          1.02      2.1±0.01ms        ? ?/sec    1.00      2.0±0.01ms        ? ?/sec
physical_plan_clickbench_q34                          1.02   1819.5±8.66µs        ? ?/sec    1.00   1778.1±6.93µs        ? ?/sec
physical_plan_clickbench_q35                          1.02   1890.5±7.54µs        ? ?/sec    1.00  1855.6±15.03µs        ? ?/sec
physical_plan_clickbench_q36                          1.03      2.2±0.01ms        ? ?/sec    1.00      2.2±0.02ms        ? ?/sec
physical_plan_clickbench_q37                          1.02      2.8±0.02ms        ? ?/sec    1.00      2.7±0.02ms        ? ?/sec
physical_plan_clickbench_q38                          1.03      2.7±0.02ms        ? ?/sec    1.00      2.7±0.01ms        ? ?/sec
physical_plan_clickbench_q39                          1.02      2.8±0.02ms        ? ?/sec    1.00      2.7±0.02ms        ? ?/sec
physical_plan_clickbench_q4                           1.00   1458.0±6.92µs        ? ?/sec    1.00   1454.8±5.32µs        ? ?/sec
physical_plan_clickbench_q40                          1.02      3.6±0.03ms        ? ?/sec    1.00      3.6±0.03ms        ? ?/sec
physical_plan_clickbench_q41                          1.02      3.1±0.03ms        ? ?/sec    1.00      3.0±0.02ms        ? ?/sec
physical_plan_clickbench_q42                          1.02      3.3±0.04ms        ? ?/sec    1.00      3.2±0.02ms        ? ?/sec
physical_plan_clickbench_q43                          1.02      3.4±0.03ms        ? ?/sec    1.00      3.4±0.02ms        ? ?/sec
physical_plan_clickbench_q44                          1.01   1574.6±8.04µs        ? ?/sec    1.00   1559.9±5.57µs        ? ?/sec
physical_plan_clickbench_q45                          1.00   1556.5±6.18µs        ? ?/sec    1.00   1562.1±6.22µs        ? ?/sec
physical_plan_clickbench_q46                          1.00   1909.1±8.74µs        ? ?/sec    1.00   1914.5±7.64µs        ? ?/sec
physical_plan_clickbench_q47                          1.00      2.7±0.02ms        ? ?/sec    1.01      2.7±0.02ms        ? ?/sec
physical_plan_clickbench_q48                          1.00      2.9±0.02ms        ? ?/sec    1.01      2.9±0.03ms        ? ?/sec
physical_plan_clickbench_q49                          1.00      3.0±0.02ms        ? ?/sec    1.00      3.0±0.03ms        ? ?/sec
physical_plan_clickbench_q5                           1.00   1595.2±6.61µs        ? ?/sec    1.00   1594.7±5.46µs        ? ?/sec
physical_plan_clickbench_q50                          1.00      3.0±0.02ms        ? ?/sec    1.01      3.0±0.03ms        ? ?/sec
physical_plan_clickbench_q51                          1.00      2.0±0.01ms        ? ?/sec    1.01      2.0±0.01ms        ? ?/sec
physical_plan_clickbench_q6                           1.00   1603.8±6.47µs        ? ?/sec    1.00   1602.3±5.74µs        ? ?/sec
physical_plan_clickbench_q7                           1.01   1637.7±7.31µs        ? ?/sec    1.00   1616.2±5.97µs        ? ?/sec
physical_plan_clickbench_q8                           1.01   1950.9±8.63µs        ? ?/sec    1.00  1933.1±10.13µs        ? ?/sec
physical_plan_clickbench_q9                           1.00  1948.5±18.20µs        ? ?/sec    1.02  1978.2±12.31µs        ? ?/sec
physical_plan_struct_join_agg_sort                    1.03   1402.7±4.04µs        ? ?/sec    1.00   1367.0±2.66µs        ? ?/sec
physical_plan_tpcds_all                               1.01    749.8±1.54ms        ? ?/sec    1.00    745.1±3.87ms        ? ?/sec
physical_plan_tpch_all                                1.02     49.4±0.12ms        ? ?/sec    1.00     48.4±0.14ms        ? ?/sec
physical_plan_tpch_q1                                 1.02   1606.1±3.20µs        ? ?/sec    1.00   1576.8±7.17µs        ? ?/sec
physical_plan_tpch_q10                                1.01      3.1±0.01ms        ? ?/sec    1.00      3.0±0.01ms        ? ?/sec
physical_plan_tpch_q11                                1.02      2.2±0.00ms        ? ?/sec    1.00      2.2±0.01ms        ? ?/sec
physical_plan_tpch_q12                                1.02   1365.8±3.44µs        ? ?/sec    1.00  1341.7±10.29µs        ? ?/sec
physical_plan_tpch_q13                                1.00   1005.5±2.36µs        ? ?/sec    1.00   1002.0±2.87µs        ? ?/sec
physical_plan_tpch_q14                                1.01   1466.8±3.28µs        ? ?/sec    1.00   1452.7±4.02µs        ? ?/sec
physical_plan_tpch_q16                                1.01   1694.4±3.86µs        ? ?/sec    1.00   1682.3±3.76µs        ? ?/sec
physical_plan_tpch_q17                                1.02   1844.5±4.68µs        ? ?/sec    1.00   1809.6±4.05µs        ? ?/sec
physical_plan_tpch_q18                                1.01   1937.9±4.41µs        ? ?/sec    1.00   1918.9±3.60µs        ? ?/sec
physical_plan_tpch_q19                                1.01      2.5±0.01ms        ? ?/sec    1.00      2.5±0.01ms        ? ?/sec
physical_plan_tpch_q2                                 1.01      4.4±0.02ms        ? ?/sec    1.00      4.4±0.02ms        ? ?/sec
physical_plan_tpch_q20                                1.01      2.4±0.01ms        ? ?/sec    1.00      2.4±0.01ms        ? ?/sec
physical_plan_tpch_q21                                1.01      3.2±0.01ms        ? ?/sec    1.00      3.2±0.01ms        ? ?/sec
physical_plan_tpch_q22                                1.01   1585.6±3.28µs        ? ?/sec    1.00   1569.1±3.88µs        ? ?/sec
physical_plan_tpch_q3                                 1.01      2.1±0.00ms        ? ?/sec    1.00      2.0±0.01ms        ? ?/sec
physical_plan_tpch_q4                                 1.02   1187.3±3.81µs        ? ?/sec    1.00   1161.0±1.78µs        ? ?/sec
physical_plan_tpch_q5                                 1.01      2.6±0.01ms        ? ?/sec    1.00      2.6±0.01ms        ? ?/sec
physical_plan_tpch_q6                                 1.05    691.9±1.61µs        ? ?/sec    1.00    656.4±2.04µs        ? ?/sec
physical_plan_tpch_q7                                 1.01      3.3±0.01ms        ? ?/sec    1.00      3.2±0.01ms        ? ?/sec
physical_plan_tpch_q8                                 1.01      4.3±0.02ms        ? ?/sec    1.00      4.2±0.02ms        ? ?/sec
physical_plan_tpch_q9                                 1.01      3.0±0.01ms        ? ?/sec    1.00      2.9±0.01ms        ? ?/sec
physical_select_aggregates_from_200                   1.01     15.0±0.07ms        ? ?/sec    1.00     14.9±0.03ms        ? ?/sec
physical_select_all_from_1000                         1.00     18.1±0.06ms        ? ?/sec    1.00     18.1±0.06ms        ? ?/sec
physical_select_one_from_700                          1.00    726.8±2.69µs        ? ?/sec    1.00    724.7±2.87µs        ? ?/sec
physical_sorted_union_order_by_10_int64               1.00      4.8±0.01ms        ? ?/sec    1.00      4.8±0.02ms        ? ?/sec
physical_sorted_union_order_by_10_uint64              1.00     11.8±0.03ms        ? ?/sec    1.00     11.8±0.04ms        ? ?/sec
physical_sorted_union_order_by_50_int64               1.00    115.4±0.30ms        ? ?/sec    1.00    115.6±0.31ms        ? ?/sec
physical_sorted_union_order_by_50_uint64              1.00    624.0±1.97ms        ? ?/sec    1.00    625.2±1.81ms        ? ?/sec
physical_theta_join_consider_sort                     1.00   1065.4±6.34µs        ? ?/sec    1.00  1060.1±14.42µs        ? ?/sec
physical_unnest_to_join                               1.02    634.0±2.10µs        ? ?/sec    1.00    623.6±1.85µs        ? ?/sec
physical_window_function_partition_by_12_on_values    1.01    762.1±1.31µs        ? ?/sec    1.00    756.0±4.19µs        ? ?/sec
physical_window_function_partition_by_30_on_values    1.00  1510.3±11.03µs        ? ?/sec    1.01   1519.0±9.88µs        ? ?/sec
physical_window_function_partition_by_4_on_values     1.03    465.0±1.11µs        ? ?/sec    1.00    452.7±0.99µs        ? ?/sec
physical_window_function_partition_by_7_on_values     1.02    573.4±1.98µs        ? ?/sec    1.00    563.2±1.49µs        ? ?/sec
physical_window_function_partition_by_8_on_values     1.01    613.8±1.54µs        ? ?/sec    1.00    607.8±1.63µs        ? ?/sec
with_param_values_many_columns                        1.01    468.0±3.23µs        ? ?/sec    1.00    461.5±2.96µs        ? ?/sec

Resource Usage

base (merge-base)

Metric Value
Wall time 1235.3s
Peak memory 19.7 GiB
Avg memory 19.7 GiB
CPU user 1478.7s
CPU sys 1.8s
Peak spill 0 B

branch

Metric Value
Wall time 1250.3s
Peak memory 19.7 GiB
Avg memory 19.7 GiB
CPU user 1490.4s
CPU sys 1.2s
Peak spill 0 B

File an issue against this benchmark runner

@Dandandan Dandandan changed the title Fix no-op Transformed flags chore: Fix no-op Transformed flags May 1, 2026
@Dandandan Dandandan marked this pull request as ready for review May 1, 2026 05:56
@Dandandan Dandandan marked this pull request as draft May 1, 2026 08:11
joroKr21 added a commit to coralogix/arrow-datafusion that referenced this pull request May 1, 2026
joroKr21 added a commit to coralogix/arrow-datafusion that referenced this pull request May 1, 2026
joroKr21 added a commit to coralogix/arrow-datafusion that referenced this pull request May 1, 2026
.cloned()
.collect();

let scan_filters_changed = new_scan_filters != scan.filters;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that check is not enough because some predicates that were already in the scan can be eliminated from the filter when the support is exact (not partial)

joroKr21 added a commit to coralogix/arrow-datafusion that referenced this pull request May 1, 2026
joroKr21 added a commit to coralogix/arrow-datafusion that referenced this pull request May 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core Core DataFusion crate logical-expr Logical plan and expressions optimizer Optimizer rules

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants