Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -3001,6 +3001,29 @@ public void testMergeToWapBranchWithTableBranchIdentifier() {
});
}

@TestTemplate
public void testMergePreservesNullableStructWithRequiredChildren() {
// Regression test for https://github.com/apache/iceberg/issues/16246
// A nullable struct with non-nullable children should not have its children
// silently nullified when a MERGE updates a different column.
createAndInitTable(
"id INT, status STRING, info STRUCT<type:STRING NOT NULL, attr:STRING NOT NULL>",
"{ \"id\": 1, \"status\": \"active\", \"info\": { \"type\": \"A\", \"attr\": \"val1\" } }");
createOrReplaceView("source", "{ \"id\": 1, \"status\": \"inactive\" }");

sql(
"MERGE INTO %s t USING source s "
+ "ON t.id == s.id "
+ "WHEN MATCHED THEN "
+ " UPDATE SET t.status = s.status",
commitTarget());

assertEquals(
"Struct children should be preserved after MERGE updates a different column",
ImmutableList.of(row(1, "inactive", row("A", "val1"))),
sql("SELECT * FROM %s", selectTarget()));
}

private void checkJoinAndFilterConditions(String query, String join, String icebergFilters) {
// disable runtime filtering for easier validation
withSQLConf(
Expand Down