viirya commented on code in PR #7718:
URL: https://github.com/apache/datafusion-comet/pull/7718#discussion_r4703069458
##########
native/core/src/parquet/schema_adapter.rs:
##########
@@ -1474,6 +1474,15 @@ impl SparkPhysicalExprAdapter {
return Ok(Transformed::no(expr));
}
+ // These ARROW:schema representations need the same replacement
decoder
+ // as nested binary values. The scalar cast delegates them to
Arrow.
+ let needs_binary_decode = target_type == &DataType::Utf8
Review Comment:
Top-level `Dictionary(_, Binary)` stays on the Spark `Cast`. That path
decodes every entry on each batch and fails past 2 GiB without the
`spark.comet.batchSize` hint, which the updated `parquet.md` bullet now
promises for any binary dictionary. Could this use the same guard as
`parquet_convert_array_impl` (`Binary | LargeBinary`) so both shapes share one
path? If `Binary` should stay on the `Cast`, a note on why would help.
##########
native/core/src/parquet/parquet_support.rs:
##########
@@ -385,26 +386,33 @@ fn parquet_convert_array_impl(
// keeps the dictionary, succeeds (#7254).
(Dictionary(_, value_type), Utf8) if matches!(value_type.as_ref(),
Binary | LargeBinary) => {
let dictionary = array.as_any_dictionary();
- let keys = dictionary.normalized_keys();
- let key_nulls = dictionary.keys().nulls();
+ // An all-null batch can have no dictionary entries.
Review Comment:
This return also fixes a crash on `main` and `branch-1.2`. An all-null
`struct<s: dictionary<int32, binary>>` read as `struct<s: string>` reaches this
arm with empty `values()`, and `normalized_keys()` panics on `assert_ne!(v_len,
0)`. I reproduced it through `scan_parquet`: it panics without this hunk and
returns three nulls with it. Could you add the nested case to the tests and
mention the fix in the description so it can be backported?
##########
native/spark-expr/src/conversion_funcs/cast.rs:
##########
@@ -1094,6 +1097,11 @@ fn cast_binary_to_string<O: OffsetSizeTrait>(
}
};
written.expect("writing to a string builder cannot fail");
+ // Other output styles can overflow when append_value records the row
offset.
+ let end = builder.values_slice().len();
+ if !utf8_style && end > O::MAX_OFFSET {
Review Comment:
This guards the `Basic`, `Hex`, `HexDiscrete` and `Base64` styles, which a
Parquet scan never sets, and nothing exercises it. Could it go in its own PR
with a test?
--
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]