MohamedAbdeen21 opened a new issue, #9785:
URL: https://github.com/apache/arrow-datafusion/issues/9785
### Describe the bug
Assume a table `test` that is partitioned on columns `a` then `b`, creating
an external table and setting wrong order for the partition columns (`b` then
`a`) doesn't raise an error, but querying it causes a panic.
### To Reproduce
copy these queries into panic.sql
```sql
CREATE EXTERNAL TABLE test(name string, year string, month string)
PARTITIONED BY (year, month) STORED AS csv LOCATION 'tmp/';
INSERT INTO test VALUES('name', '2024', '03');
-- notice the different ordering in the PARTITIONED BY clause
CREATE EXTERNAL TABLE test2(name string, year string, month string)
PARTITIONED BY (month, year) STORED AS csv LOCATION 'tmp/';
SELECT * FROM test2;
```
And run
```console
$ datafusion-cli -f panic.sql
DataFusion CLI v36.0.0
0 rows in set. Query took 0.002 seconds.
+-------+
| count |
+-------+
| 1 |
+-------+
1 row in set. Query took 0.004 seconds.
0 rows in set. Query took 0.001 seconds.
thread 'main' panicked at
/home/user/dev/arrow-datafusion/datafusion/core/src/datasource/physical_plan/file_scan_config.rs:261:54:
index out of bounds: the len is 0 but the index is 0
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
```
### Expected behavior
Should never panic. Instead, return an error on table creation or at least
on the queries after.
### Additional context
_No response_
--
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]