Skip to content

Commit 8917cce

Browse files
test: add apply_schema mismatch test (#1210)
## What changes are proposed in this pull request? Discovered test gap in #1199 (see #1199 (comment)) - this fixes it. ## How was this change tested? test-only
1 parent 7ba3af0 commit 8917cce

File tree

1 file changed

+35
-0
lines changed
  • kernel/src/engine/arrow_expression

1 file changed

+35
-0
lines changed

kernel/src/engine/arrow_expression/tests.rs

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -900,3 +900,38 @@ fn test_null_scalar_map() -> DeltaResult<()> {
900900

901901
Ok(())
902902
}
903+
904+
#[test]
905+
fn test_apply_schema_column_count_mismatch() {
906+
use super::apply_schema::apply_schema;
907+
use crate::schema::StructType;
908+
909+
// Create a struct array with 3 columns
910+
let struct_array = StructArray::from(vec![
911+
(
912+
Arc::new(Field::new("a", DataType::Int32, false)),
913+
create_array!(Int32, [1]) as ArrayRef,
914+
),
915+
(
916+
Arc::new(Field::new("b", DataType::Int32, false)),
917+
create_array!(Int32, [2]) as ArrayRef,
918+
),
919+
(
920+
Arc::new(Field::new("c", DataType::Int32, false)),
921+
create_array!(Int32, [3]) as ArrayRef,
922+
),
923+
]);
924+
925+
// Create a schema with only 2 fields (mismatch)
926+
let schema = KernelDataType::Struct(Box::new(StructType::new([
927+
StructField::not_null("a", KernelDataType::INTEGER),
928+
StructField::not_null("b", KernelDataType::INTEGER),
929+
])));
930+
931+
let result = apply_schema(&struct_array, &schema);
932+
933+
assert_result_error_with_message(
934+
result,
935+
"Passed struct had 3 columns, but transformed column has 2",
936+
);
937+
}

0 commit comments

Comments
 (0)