Skip to content

Commit 97045ec

Browse files
authored
Produce informative error on physical schema mismatch (#13434)
Include details that can help understand the problem.
1 parent e3c4541 commit 97045ec

File tree

1 file changed

+35
-1
lines changed

1 file changed

+35
-1
lines changed

datafusion/core/src/physical_planner.rs

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -659,7 +659,41 @@ impl DefaultPhysicalPlanner {
659659
if !options.execution.skip_physical_aggregate_schema_check
660660
&& &physical_input_schema != physical_input_schema_from_logical
661661
{
662-
return internal_err!("Physical input schema should be the same as the one converted from logical input schema.");
662+
let mut differences = Vec::new();
663+
if physical_input_schema.fields().len()
664+
!= physical_input_schema_from_logical.fields().len()
665+
{
666+
differences.push(format!(
667+
"Different number of fields: (physical) {} vs (logical) {}",
668+
physical_input_schema.fields().len(),
669+
physical_input_schema_from_logical.fields().len()
670+
));
671+
}
672+
for (i, (physical_field, logical_field)) in physical_input_schema
673+
.fields()
674+
.iter()
675+
.zip(physical_input_schema_from_logical.fields())
676+
.enumerate()
677+
{
678+
if physical_field.name() != logical_field.name() {
679+
differences.push(format!(
680+
"field name at index {}: (physical) {} vs (logical) {}",
681+
i,
682+
physical_field.name(),
683+
logical_field.name()
684+
));
685+
}
686+
if physical_field.data_type() != logical_field.data_type() {
687+
differences.push(format!("field data type at index {} [{}]: (physical) {} vs (logical) {}", i, physical_field.name(), physical_field.data_type(), logical_field.data_type()));
688+
}
689+
if physical_field.is_nullable() != logical_field.is_nullable() {
690+
differences.push(format!("field nullability at index {} [{}]: (physical) {} vs (logical) {}", i, physical_field.name(), physical_field.is_nullable(), logical_field.is_nullable()));
691+
}
692+
}
693+
return internal_err!("Physical input schema should be the same as the one converted from logical input schema. Differences: {}", differences
694+
.iter()
695+
.map(|s| format!("\n\t- {}", s))
696+
.join(""));
663697
}
664698

665699
let groups = self.create_grouping_physical_expr(

0 commit comments

Comments
 (0)