Commit c8f2fa6
fix: propagate column statistics through CAST in projections
When join keys involve CAST expressions (e.g. CAST(id AS Float64)),
the column statistics were lost in ProjectionExec because it only
propagated stats for plain Column and Literal expressions.
Propagate distinct_count and null_count through numeric CAST
expressions in ProjectionExec::project_statistics. The distinct
count is made Inexact since casting can reduce (but never increase)
the number of distinct values. min/max/sum are cleared since they
may not be valid after type conversion.
This fixes join cardinality estimation for queries with type
mismatches in join keys (common in TPC-DS where fact table FKs
are Float64 and dimension PKs are Int32).
TPC-DS Q99: 10.4s → ~60ms.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>1 parent 5ba06ac commit c8f2fa6
1 file changed
+64
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
714 | 714 | | |
715 | 715 | | |
716 | 716 | | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
| 730 | + | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
717 | 735 | | |
718 | 736 | | |
719 | 737 | | |
| |||
3104 | 3122 | | |
3105 | 3123 | | |
3106 | 3124 | | |
| 3125 | + | |
| 3126 | + | |
| 3127 | + | |
| 3128 | + | |
| 3129 | + | |
| 3130 | + | |
| 3131 | + | |
| 3132 | + | |
| 3133 | + | |
| 3134 | + | |
| 3135 | + | |
| 3136 | + | |
| 3137 | + | |
| 3138 | + | |
| 3139 | + | |
| 3140 | + | |
| 3141 | + | |
| 3142 | + | |
| 3143 | + | |
| 3144 | + | |
| 3145 | + | |
| 3146 | + | |
| 3147 | + | |
| 3148 | + | |
| 3149 | + | |
| 3150 | + | |
| 3151 | + | |
| 3152 | + | |
| 3153 | + | |
| 3154 | + | |
| 3155 | + | |
| 3156 | + | |
| 3157 | + | |
| 3158 | + | |
| 3159 | + | |
| 3160 | + | |
| 3161 | + | |
| 3162 | + | |
| 3163 | + | |
| 3164 | + | |
| 3165 | + | |
| 3166 | + | |
| 3167 | + | |
| 3168 | + | |
| 3169 | + | |
| 3170 | + | |
3107 | 3171 | | |
0 commit comments