Commit 03037cd
fix: propagate column statistics through CAST in join key expressions
When join keys contain CAST expressions (e.g. CAST(id AS Float64)),
the cardinality estimator could not extract column statistics because
it only handled plain Column references. This caused unknown stats,
leading to poor join ordering (e.g. putting a 1.4M-row fact table
on the hash join build side instead of a 5-row dimension table).
Extract the underlying column index through numeric CAST expressions,
since casting can only reduce (never increase) distinct count, making
the source column's stats a valid upper bound.
TPC-DS Q99: 10.4s → ~60ms.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>1 parent 5ba06ac commit 03037cd
1 file changed
+26
-7
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
460 | 460 | | |
461 | 461 | | |
462 | 462 | | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
463 | 485 | | |
464 | 486 | | |
465 | 487 | | |
| |||
470 | 492 | | |
471 | 493 | | |
472 | 494 | | |
473 | | - | |
474 | | - | |
475 | | - | |
476 | | - | |
477 | | - | |
478 | | - | |
479 | | - | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
480 | 499 | | |
481 | 500 | | |
482 | 501 | | |
| |||
0 commit comments