Comments (3)
Thank you for the report @samuelcolvin. I will look into this and try to make a self contained reproducer. This panic should not be possible. I suspect there could be a bug in how dictionary encoded arrays are handled in the relevant code, since that could cause this panic but I have yet to confirm.
from arrow-datafusion.
I was unable to reproduce this panic on main or v38. @samuelcolvin if you are able to provide more details about the parquet files which are triggering the issue (schema, sanitized values, directory structure) that may help reproduce.
Here is what I tried to reproduce:
datafusion-cli
DataFusion CLI v38.0.0
> COPY (values ('1', 'a', 'x'), ('2', 'b', 'y'), ('3', 'c', 'z')) TO 'test_files/scratch/copy/partitioned_table3/' STORED AS parquet PARTITIONED BY (column1, column3)
;
+-------+
| count |
+-------+
| 3 |
+-------+
1 row(s) fetched.
Elapsed 0.003 seconds.
> CREATE EXTERNAL TABLE validate_partitioned_parquet3 STORED AS PARQUET
LOCATION 'test_files/scratch/copy/partitioned_table3/' PARTITIONED BY (column1, column3);
0 row(s) fetched.
Elapsed 0.001 seconds.
> COPY validate_partitioned_parquet3
TO 'test_files/scratch/copy/partitioned_table3_rewrite'
PARTITIONED BY (column1, column3)
STORED AS PARQUET;
+-------+
| count |
+-------+
| 3 |
+-------+
1 row(s) fetched.
Elapsed 0.003 seconds.
And trying to force dictionary encoding where possible also runs without panic
DataFusion CLI v38.0.0
> COPY (values
('c', arrow_cast('foo', 'Dictionary(Int32, Utf8)'), arrow_cast('foo2', 'Dictionary(Int32, Utf8)')),
('d', arrow_cast('bar', 'Dictionary(Int32, Utf8)'), arrow_cast('bar2', 'Dictionary(Int32, Utf8)')))
to 'test_files/scratch/copy/part_dict_test' STORED AS PARQUET PARTITIONED BY (column2, column3);
+-------+
| count |
+-------+
| 2 |
+-------+
1 row(s) fetched.
Elapsed 0.004 seconds.
> CREATE EXTERNAL TABLE dict_partitioned_test STORED AS PARQUET
LOCATION 'test_files/scratch/copy/part_dict_test/' PARTITIONED BY (column2, column3);
0 row(s) fetched.
Elapsed 0.001 seconds.
> select * from dict_partitioned_test;
+---------+---------+---------+
| column1 | column2 | column3 |
+---------+---------+---------+
| d | bar | bar2 |
| c | foo | foo2 |
+---------+---------+---------+
2 row(s) fetched.
Elapsed 0.002 seconds.
> COPY (select column1, arrow_cast(column2, 'Dictionary(Int32, Utf8)') as column2,
arrow_cast(column3, 'Dictionary(Int32, Utf8)') as column3 from dict_partitioned_test)
TO 'test_files/scratch/copy/part_dict_test_rewrite'
PARTITIONED BY (column2, column3)
STORED AS PARQUET;
+-------+
| count |
+-------+
| 2 |
+-------+
1 row(s) fetched.
Elapsed 0.003 seconds.
The line that is panicking with index OOB would only happen if one of the partition arrays in the RecordBatch
was extracted with fewer values than RecordBatch::num_rows()
.
For plain Utf8 arrays, this seems completely impossible given this code executes first (array.value(i) would panic first):
datafusion/datafusion/core/src/datasource/file_format/write/demux.rs
Lines 339 to 341 in c775e4d
For dictionary encoded arrays, I could imagine something in the downcast / iteration code here producing fewer values. I thought that the iteration over the downcasted array should always produce exactly RecordBatch::num_rows()
values, but perhaps there is a case where this is wrong.
datafusion/datafusion/core/src/datasource/file_format/write/demux.rs
Lines 346 to 353 in c775e4d
Finally, the arrays constructed above are accessed like this:
datafusion/datafusion/core/src/datasource/file_format/write/demux.rs
Lines 378 to 385 in c775e4d
from arrow-datafusion.
Has this been fixed @samuelcolvin ?
from arrow-datafusion.
Related Issues (20)
- Add support for `newlines_in_values` to `CsvOptions` HOT 4
- Move `sql_compound_identifier_to_expr` to `ExprPlanner` HOT 6
- DataFusion weekly project plan (Andrew Lamb) - July 15, 2024 HOT 1
- Release DataFusion `41.0.0`
- ExprPlanner not propagated to SqlToRel HOT 7
- Update the parquet code `prune_pages_in_one_row_group` to use the `StatisticsExtractor`
- Optimize CASE WHEN for "expression or null" case HOT 1
- Add has_side_effects to PhysicalExpr HOT 1
- `SanityCheckPlan` Error during planning: ... does not satisfy parent order requirements: ... HOT 1
- Move spill related functions to `spill.rs` HOT 5
- Consolidate optimizer readme into datafusion user guide HOT 2
- Reduce repetition in `try_process_group_by_unnest` and `try_process_unnest`
- Investigate memory use in debug builds for deeply nested array constants
- [EPIC] Extract remaining physical optimizer out of core
- Leverage dictionary-encode when turning a scalar columnar value into an array HOT 3
- [Proposal] Decouple logical from physical types HOT 15
- Chore: fix typos in the code
- Explore Updating VariadicAny Signature to take 0 Args HOT 2
- Resources exhuasted errors are confusing return the biggest memory consumers. HOT 4
- `SHOW NONSENSE` does not error
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from arrow-datafusion.