Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions docs/source/user-guide/latest/compatibility/scans.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ The following features are not supported and cause Comet to fall back to Spark:
Comet Parquet scan regardless.
- A read schema that repeats a Parquet field id, at the top level or within a struct, when
`spark.sql.parquet.fieldId.read.enabled=true`.
- A read schema that carries Parquet field ids when `spark.sql.parquet.fieldId.read.enabled=true`
and Parquet encryption is configured. When a file has an `INT96` timestamp, Comet restores the
field ids of its structs, lists and maps through the file footer, which it cannot rewrite for a
decrypted read. Which files need this is not known when the query is planned, so every such
scan falls back ([#6131](https://github.com/apache/datafusion-comet/issues/6131)).

The following limitation may produce incorrect results without falling back to Spark:

Expand Down
19 changes: 19 additions & 0 deletions native/core/src/parquet/cast_column.rs
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,25 @@ impl PhysicalExpr for CometCastColumnExpr {
fn evaluate(&self, batch: &RecordBatch) -> DataFusionResult<ColumnarValue> {
let value = self.expr.evaluate(batch)?;

// Under field-id matching the physical field may carry nested ids that
// `restore_field_ids` put back and the decoder, built from DataFusion's INT96-coerced
// schema, leaves off. Relabel the decoded array to the physical type first, so the
// conversion below resolves nested fields by those ids (#6131).
let physical_type = self.input_physical_field.data_type();
let value = match value {
ColumnarValue::Array(array)
if self
.parquet_options
.as_ref()
.is_some_and(|options| options.use_field_id)
&& array.data_type() != physical_type
&& array.data_type().equals_datatype(physical_type) =>
{
ColumnarValue::Array(relabel_array(array, physical_type))
}
other => other,
};

if self.target_field.has_valid_extension_type::<VariantType>() {
return match value {
ColumnarValue::Array(array) => Ok(ColumnarValue::Array(normalize_variant_array(
Expand Down
Loading