tlfua opened a new pull request, #27808:
URL: https://github.com/apache/datafusion/pull/27808
## Which issue does this PR close?
- Closes #9714.
## Rationale for this change
`PARTITIONED BY` column names in `COPY TO` and `CREATE EXTERNAL TABLE` did
not go through identifier normalization, unlike the column names in the schema:
- A quoted name such as `"'test2'"` kept its double quotes, so it did not
match the column `'test2'`.
- An unquoted name such as `COL2` was not lowercased, so it did not match
the column `col2`.
## What changes are included in this PR?
- `datafusion_sql::parser`: `CopyToStatement::partitioned_by` and
`CreateExternalTable::table_partition_cols` now hold `Ident` instead of the
stringified ident.
- `SqlToRel` normalizes these idents with the same `IdentNormalizer` it uses
for column definitions.
- The upgrade guide (57.0.0) covers the behavior change and the API change.
## What is the testing strategy for this PR?
- Re-enabled the commented-out quoted `PARTITIONED BY` test in `copy.slt`,
and added cases for unquoted uppercase names and quoted mixed-case names.
- Added planner tests in `sql_integration.rs` for both `COPY TO` and `CREATE
EXTERNAL TABLE`, including with normalization disabled.
- Added a parser round-trip test for quoted `PARTITIONED BY` idents.
Commands run:
- `cargo test -p datafusion-sql`: passed
- `cargo test -p datafusion-sqllogictest --test sqllogictests -- copy
create_external_table listing_table_partitions`: passed
- `cargo clippy -p datafusion-sql -p datafusion-benchmarks -p datafusion-cli
--all-targets --all-features -- -D warnings`: passed
- `cargo fmt --all -- --check` and `./ci/scripts/doc_prettier_check.sh`:
passed
## Are there any user-facing changes?
Yes.
- Unquoted `PARTITIONED BY` names are now lowercased, the same as other
identifiers. Names with uppercase letters must be quoted, for example
`PARTITIONED BY ("Year")`.
- Breaking public API change: `CopyToStatement::partitioned_by` and
`CreateExternalTable::table_partition_cols` changed from `Vec<String>` to
`Vec<Ident>`. This needs the `api change` label.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]