Commit 4e0161d
authored
fix: Don't treat quoted column names as placeholder variables in SQL (#19339)
## Which issue does this PR close?
Closes #19249
## Rationale for this change
SQL allows for column names to begin with `@`, so long as the identifier
is quoted. For example, `SELECT "@column" FROM table`. Both PostgreSQL
and MySQL allow for this at least. The existing SQL parser treats these
column names as placeholder variables, because it does not check if the
identifier is quoted. This change corrects that behavior.
## What changes are included in this PR?
sql/src/expr/identifier.rs - fix to check if identifiers are quoted
sql/tests/common/mod.rs - new test table
sql/tests/sql_integration.rs - unit test
## Are these changes tested?
Yes, `test_parse_quoted_column_name_with_at_sign` unit test was added to
verify quoted column names beginning with `@` are treated as column
names instead of placeholder variables.
## Are there any user-facing changes?
It's possible users are relying on the existing behavior.1 parent 458b491 commit 4e0161d
File tree
3 files changed
+49
-4
lines changed- datafusion/sql
- src/expr
- tests
- common
3 files changed
+49
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
40 | | - | |
| 40 | + | |
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
| |||
111 | 111 | | |
112 | 112 | | |
113 | 113 | | |
114 | | - | |
| 114 | + | |
115 | 115 | | |
116 | 116 | | |
117 | 117 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
227 | 227 | | |
228 | 228 | | |
229 | 229 | | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
230 | 235 | | |
231 | 236 | | |
232 | 237 | | |
| |||
244 | 249 | | |
245 | 250 | | |
246 | 251 | | |
247 | | - | |
248 | | - | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
249 | 257 | | |
250 | 258 | | |
251 | 259 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4522 | 4522 | | |
4523 | 4523 | | |
4524 | 4524 | | |
| 4525 | + | |
| 4526 | + | |
| 4527 | + | |
| 4528 | + | |
| 4529 | + | |
| 4530 | + | |
| 4531 | + | |
| 4532 | + | |
| 4533 | + | |
| 4534 | + | |
| 4535 | + | |
| 4536 | + | |
| 4537 | + | |
| 4538 | + | |
| 4539 | + | |
| 4540 | + | |
| 4541 | + | |
| 4542 | + | |
| 4543 | + | |
| 4544 | + | |
| 4545 | + | |
| 4546 | + | |
| 4547 | + | |
| 4548 | + | |
| 4549 | + | |
| 4550 | + | |
| 4551 | + | |
| 4552 | + | |
| 4553 | + | |
| 4554 | + | |
| 4555 | + | |
| 4556 | + | |
| 4557 | + | |
| 4558 | + | |
| 4559 | + | |
| 4560 | + | |
| 4561 | + | |
4525 | 4562 | | |
4526 | 4563 | | |
4527 | 4564 | | |
| |||
0 commit comments