Repository navigation
Commit 1b69820
fix(sql): fold numeric casts of literals as DataFusion does
Type coercion turns a literal compared with a column of another type into
a cast: `latency < 100` on a DOUBLE column became
`latency < CAST(100 AS DOUBLE)`, which summary coverage cannot read as a
constant. Fold a cast of a literal to an integer or float type with
DataFusion's `ScalarValue::cast_to`, the evaluation its constant folding
uses; the predicate lowers as `latency < 100.0`. A cast that fails to
evaluate is kept.
DataFusion's whole SimplifyExpressions rule is not run: it also folds
timestamp casts into timestamp literals, which the IR cannot write yet, and
rewrites REGEXP_LIKE into the `~` operator (#650).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01W7qG9aFyPij5uWsyAJCxDW1 parent 32e4dad commit 1b69820
2 files changed
Lines changed: 37 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
146 | 146 | | |
147 | 147 | | |
148 | 148 | | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
149 | 168 | | |
150 | 169 | | |
151 | 170 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2217 | 2217 | | |
2218 | 2218 | | |
2219 | 2219 | | |
| 2220 | + | |
| 2221 | + | |
| 2222 | + | |
| 2223 | + | |
| 2224 | + | |
| 2225 | + | |
| 2226 | + | |
| 2227 | + | |
| 2228 | + | |
| 2229 | + | |
| 2230 | + | |
| 2231 | + | |
| 2232 | + | |
| 2233 | + | |
| 2234 | + | |
| 2235 | + | |
| 2236 | + | |
| 2237 | + | |
2220 | 2238 | | |
2221 | 2239 | | |
2222 | 2240 | | |
| |||
0 commit comments