Repository navigation
Spark 4.1: Add tests for MERGE INTO schema evolution nested case - #15028
Conversation
|
PTAL @huaxingao @singhpk234 @szehon-ho I went through the discussions in Spark PRs related to this feature. |
szehon-ho
left a comment
There was a problem hiding this comment.
Yea , was going to do this, you beat me to it :)
The only missing part here is that there is a flag that needs to be set (as its disabled by default in Spark 4.1.x). We will probably turn it on in later version if there are no complaints on the behavior
42a9fe1 to
acd524a
Compare
|
@szehon-ho Thanks for the original features and tests, This new test is a small tweak based on your existing one.
Please let me know if any further changes are needed. @huaxingao @singhpk234 |
|
PTAL @huaxingao @singhpk234 |
szehon-ho
left a comment
There was a problem hiding this comment.
looks mostly fine, but i wonder if we should hold the pr until 4.1.1 is supported in iceberg
| public void testMergeWithSchemaEvolutionNestedStructSourceHasFewerFields() { | ||
| assumeThat(branch).as("Schema evolution does not work for branches currently").isNull(); | ||
|
|
||
| spark.conf().set("spark.sql.mergeNestedTypeCoercion.enabled", "true"); |
There was a problem hiding this comment.
should be in try/catch. Do we have any utility in iceberg spark test cases to wrap code in spark configs?
There was a problem hiding this comment.
Yes correct, There is withSQLConf at spark/v4.1/spark/src/test/java/org/apache/iceberg/spark/TestBase.java::186 which handles spark configs required for some action and It handles try block in its implementation.
I took reference from testMergeToWapBranch() at spark/v4.1/spark-extensions/src/test/java/org/apache/iceberg/spark/extensions/TestMerge.java::2914 which implements similar thing.
Ready for review.
|
sorry, just re-read and see test is running already against 4.1.1 , that's great. only one comment |
singhpk234
left a comment
There was a problem hiding this comment.
LGTM as well, thanks @varun-lakhyani !
| + "{ \"id\": 3, \"s\": { \"c1\": 30, \"c2\": \"c\" } }"); | ||
|
|
||
| // Rows should have null for missing c3 nested field from source | ||
| ImmutableList<Object[]> expectedRows = |
There was a problem hiding this comment.
nit, can we move this block in the with? its a bit disjointing to see the expectation before the merge :)
There was a problem hiding this comment.
I felt the same way but found lot of places where this was followed as one referenced here.
Should I push the change with expected rows inside withSQLConf after MERGE command?
There was a problem hiding this comment.
i see, thanks for checking. well, i did it all this way in the other tests in this file, and we both agree, so id say let's just do it?
There was a problem hiding this comment.
Done. Updated in latest commit
|
PTAL @szehon-ho. |
|
merged, thanks @varun-lakhyani , and all for reviews |
|
Thanks @huaxingao @singhpk234 @szehon-ho for reviews and merging |
Extends Tests for PR #14970
This PR creates a test for MERGE INTO schema evolution in nested case where source has fewer fields than target and by default it keeps the non existing fields in target intact and null for new source rows.
Spark Updates can be found at https://issues.apache.org/jira/browse/SPARK-54274
This specific feature https://issues.apache.org/jira/browse/SPARK-54621
It also renames an existing nested test like other tests so can be better understood
(
testMergeWithSchemaEvolutionNestedStruct()->testMergeWithSchemaEvolutionNestedStructSourceHasMoreFields())