Commit 374806c
fix(sql): return planner error for malformed typed literals (#21454)
## Which issue does this PR close?
- Closes #21431.
## Rationale for this change
Planning a malformed typed literal such as `time 17542368000000000`
currently panics in `datafusion-sql` because the planner assumes every
`TypedString` payload is string-backed and calls
`into_string().unwrap()`.
Invalid SQL should surface as a normal planner error rather than
aborting the planning path.
## What changes are included in this PR?
- Replace the `unwrap()` in the `SQLExpr::TypedString` planning path
with explicit validation.
- Return a planner error when the typed literal payload is not
string-backed.
- Add a regression test covering the invalid `TIME` typed literal
reported in the issue.
## Are these changes tested?
- `cargo test -p datafusion-sql`
## Are there any user-facing changes?
Users now receive a planner error for malformed typed literals instead
of a panic.
Signed-off-by: Asish Kumar <officialasishkumar@gmail.com>
Co-authored-by: Jonah Gao <jonahgao@msn.com>1 parent 540d8ec commit 374806c
2 files changed
+35
-6
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
306 | 306 | | |
307 | 307 | | |
308 | 308 | | |
309 | | - | |
310 | | - | |
311 | | - | |
312 | | - | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
313 | 322 | | |
314 | 323 | | |
315 | 324 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
29 | | - | |
| 29 | + | |
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
38 | | - | |
| 38 | + | |
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
| |||
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
| 55 | + | |
55 | 56 | | |
56 | 57 | | |
57 | 58 | | |
| |||
254 | 255 | | |
255 | 256 | | |
256 | 257 | | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
257 | 277 | | |
258 | 278 | | |
259 | 279 | | |
| |||
0 commit comments