tlfua opened a new pull request, #27809:
URL: https://github.com/apache/datafusion/pull/27809
## Which issue does this PR close?
- Closes #9269.
## Rationale for this change
When a Hive partition column name contains `=`, reading the table silently
returns no rows, even though the data was written:
```sql
CREATE EXTERNAL TABLE partitioned_equals (payload VARCHAR, "a=b" VARCHAR)
STORED AS PARQUET LOCATION '/tmp/partitioned_equals/'
PARTITIONED BY ("a=b");
INSERT INTO partitioned_equals VALUES ('row1', 'x=y');
-- count: 1
SELECT payload, "a=b" FROM partitioned_equals;
-- main (f44b68c8e): 0 rows
-- this PR: row1 | x=y
```
The file is written to `a=b=x=y/<file>.parquet`, and reading that file
directly returns the row. The reader split the directory name at the first `=`,
so it saw the column name as `a` and skipped the file.
The original report in #9269 (column names with `'`) no longer reproduces on
main: #27808 fixed it. I checked the CSV case from the issue on `f44b68c8e`,
and it reads back all three rows. This PR fixes the remaining `a=b` case from
[this
comment](https://github.com/apache/datafusion/issues/9269#issuecomment-2039365128).
It now returns no rows instead of panicking.
## What changes are included in this PR?
`parse_partitions_for_path` now matches each directory against the expected
`<column>=` prefix and takes the rest as the value, instead of splitting at the
first `=`. Percent-decoding, directory order, and the handling of missing or
mismatched directories are unchanged.
## What is the testing strategy for this PR?
Added a `copy.slt` case that writes a row into a table partitioned by
`"a=b"` with the value `x=y` and reads it back. With the fix it returns `row1
x=y`, which also checks that `=` in the value is kept.
To check that the test covers the fix, I pushed the test alone on top of
`f44b68c8e` to my fork. The three CI jobs that run `copy.slt` failed on the new
query ([cargo
test](https://github.com/tlfua/datafusion/actions/runs/46098721454/job/140837462046),
[Substrait round-trip
SLT](https://github.com/tlfua/datafusion/actions/runs/46098721454/job/140837462037),
[benchmark
verify](https://github.com/tlfua/datafusion/actions/runs/46098721454/job/140837462041)):
```
1. query result mismatch:
[SQL] SELECT payload, "a=b" FROM partitioned_equals;
[Diff] (-expected|+actual)
- row1 x=y
at test_files/copy.slt:196
```
With the fix, the [fork CI
run](https://github.com/tlfua/datafusion/actions/runs/46099325429) passes. The
existing `test_parse_partitions_for_path` cases are unchanged.
## Are there any user-facing changes?
Yes: tables with `=` in a partition column name now return their rows
instead of none. No public API changes.
--
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]