Skip to content

Commit c7c5d80

Browse files
committed
cargo fmt
1 parent b81b419 commit c7c5d80

File tree

2 files changed

+20
-13
lines changed

2 files changed

+20
-13
lines changed

datafusion/physical-expr/src/expressions/cast.rs

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,8 @@ impl CastExpr {
177177
}
178178

179179
fn preserves_child_field_semantics(&self, input_schema: &Schema) -> Result<bool> {
180-
Ok(self.resolved_target_field(input_schema)? == self.expr.return_field(input_schema)?)
180+
Ok(self.resolved_target_field(input_schema)?
181+
== self.expr.return_field(input_schema)?)
181182
}
182183

183184
/// Check if casting from the specified source type to the target type is a
@@ -347,7 +348,9 @@ pub(crate) fn cast_with_target_field_and_options(
347348
cast_options.clone(),
348349
);
349350

350-
if expr_type == *cast_type && candidate.preserves_child_field_semantics(input_schema)? {
351+
if expr_type == *cast_type
352+
&& candidate.preserves_child_field_semantics(input_schema)?
353+
{
351354
return Ok(Arc::clone(&expr));
352355
}
353356

@@ -930,15 +933,15 @@ mod tests {
930933
#[test]
931934
fn field_aware_same_type_cast_preserves_explicit_target_field() -> Result<()> {
932935
let schema = Schema::new(vec![Field::new("a", Int32, false)]);
933-
let expr = cast_with_target_field_and_options(
934-
col("a", &schema)?,
935-
&schema,
936-
Arc::new(Field::new("logical_a", Int32, true).with_metadata(HashMap::from([(
937-
"target_meta".to_string(),
938-
"1".to_string(),
939-
)]))),
940-
None,
941-
)?;
936+
let expr =
937+
cast_with_target_field_and_options(
938+
col("a", &schema)?,
939+
&schema,
940+
Arc::new(Field::new("logical_a", Int32, true).with_metadata(
941+
HashMap::from([("target_meta".to_string(), "1".to_string())]),
942+
)),
943+
None,
944+
)?;
942945

943946
let cast_expr = expr
944947
.as_any()

datafusion/physical-expr/src/planner.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -542,7 +542,8 @@ mod tests {
542542
}
543543

544544
#[test]
545-
fn test_create_physical_expr_same_type_cast_preserves_explicit_target_field() -> Result<()> {
545+
fn test_create_physical_expr_same_type_cast_preserves_explicit_target_field()
546+
-> Result<()> {
546547
let schema = Schema::new(vec![Field::new("value", DataType::Int32, false)]);
547548
let df_schema = DFSchema::try_from(schema.clone())?;
548549
let target_field = Arc::new(
@@ -563,7 +564,10 @@ mod tests {
563564
.downcast_ref::<CastExpr>()
564565
.expect("same-type cast with explicit field should preserve CastExpr");
565566
assert_eq!(cast_expr.target_field(), &target_field);
566-
assert_eq!(physical_expr.return_field(&schema)?.name(), "same_type_cast");
567+
assert_eq!(
568+
physical_expr.return_field(&schema)?.name(),
569+
"same_type_cast"
570+
);
567571

568572
Ok(())
569573
}

0 commit comments

Comments
 (0)