Skip to content

Commit bb92d38

Browse files
committed
fix: cast list of structs and other cast fixes
1 parent b940692 commit bb92d38

File tree

4 files changed

+8
-19
lines changed

4 files changed

+8
-19
lines changed

native/core/src/execution/planner.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,6 @@ impl PhysicalPlanner {
328328
)));
329329
}
330330
let field = input_schema.field(idx);
331-
//dbg!(field);
332331
Ok(Arc::new(Column::new(field.name().as_str(), idx)))
333332
}
334333
ExprStruct::Unbound(unbound) => {
@@ -1092,8 +1091,6 @@ impl PhysicalPlanner {
10921091
let data_schema = convert_spark_types_to_arrow_schema(scan.data_schema.as_slice());
10931092
let required_schema: SchemaRef =
10941093
convert_spark_types_to_arrow_schema(scan.required_schema.as_slice());
1095-
// dbg!(&data_schema);
1096-
// dbg!(&required_schema);
10971094
let partition_schema: SchemaRef =
10981095
convert_spark_types_to_arrow_schema(scan.partition_schema.as_slice());
10991096
let projection_vector: Vec<usize> = scan

native/core/src/parquet/parquet_support.rs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -158,11 +158,9 @@ fn cast_array(
158158
};
159159
let from_type = array.data_type();
160160

161+
// Try Comet specific handlers first, then arrow-rs cast if supported,
162+
// return uncasted data otherwise
161163
match (from_type, to_type) {
162-
// If Arrow cast supports the cast, delegate the cast to Arrow
163-
_ if can_cast_types(from_type, to_type) => {
164-
Ok(cast_with_options(&array, to_type, &PARQUET_OPTIONS)?)
165-
}
166164
(Struct(_), Struct(_)) => Ok(cast_struct_to_struct(
167165
array.as_struct(),
168166
from_type,
@@ -180,6 +178,10 @@ fn cast_array(
180178
.with_timezone(Arc::clone(tz)),
181179
))
182180
}
181+
// If Arrow cast supports the cast, delegate the cast to Arrow
182+
_ if can_cast_types(from_type, to_type) => {
183+
Ok(cast_with_options(&array, to_type, &PARQUET_OPTIONS)?)
184+
}
183185
_ => Ok(array),
184186
}
185187
}
@@ -192,11 +194,6 @@ fn cast_list_to_list(
192194
) -> DataFusionResult<ArrayRef> {
193195
match (from_type, to_type) {
194196
(DataType::List(_), DataType::List(to_inner_type)) => {
195-
//dbg!(from_type);
196-
//dbg!(to_type);
197-
//dbg!(from_inner_type);
198-
//dbg!(to_inner_type);
199-
200197
let cast_field = cast_array(
201198
Arc::clone(array.values()),
202199
to_inner_type.data_type(),
@@ -316,6 +313,8 @@ pub(crate) fn prepare_object_store(
316313
#[cfg(test)]
317314
mod tests {
318315
use crate::parquet::parquet_support::prepare_object_store;
316+
use arrow::compute::can_cast_types;
317+
use arrow::datatypes::DataType;
319318
use datafusion::execution::object_store::ObjectStoreUrl;
320319
use datafusion::execution::runtime_env::RuntimeEnv;
321320
use object_store::path::Path;

native/spark-expr/src/struct_funcs/get_struct_field.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,6 @@ impl PhysicalExpr for GetStructField {
8181

8282
fn evaluate(&self, batch: &RecordBatch) -> DataFusionResult<ColumnarValue> {
8383
let child_value = self.child.evaluate(batch)?;
84-
//dbg!(&batch);
85-
//dbg!(&child_value);
8684

8785
match child_value {
8886
ColumnarValue::Array(array) => {

spark/src/main/scala/org/apache/comet/serde/QueryPlanSerde.scala

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1962,11 +1962,6 @@ object QueryPlanSerde extends Logging with CometExprShim {
19621962
val childExpr = exprToProtoInternal(child, inputs, binding)
19631963
val ordinalExpr = exprToProtoInternal(ordinal, inputs, binding)
19641964

1965-
// val childExpr = exprToProtoInternal(child, inputs, binding)
1966-
// val ordinalExpr =
1967-
// exprToProtoInternal(Add(Cast(ordinal, LongType), Literal(1L)), inputs, binding)
1968-
// scalarFunctionExprToProto("array_element", childExpr, ordinalExpr)
1969-
19701965
if (childExpr.isDefined && ordinalExpr.isDefined) {
19711966
val listExtractBuilder = ExprOuterClass.ListExtract
19721967
.newBuilder()

0 commit comments

Comments
 (0)