-
Notifications
You must be signed in to change notification settings - Fork 28.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SPARK-49743][SQL] OptimizeCsvJsonExpr should not change schema fields when pruning GetArrayStructFields #48190
Open
nikhilsheoran-db
wants to merge
7
commits into
apache:master
Choose a base branch
from
nikhilsheoran-db:SPARK-49743
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+34
−3
Open
Changes from 4 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
b03be2e
Add test
nikhilsheoran-db 13a4df7
Add fix
nikhilsheoran-db 39f07da
Fix build error
nikhilsheoran-db 9ce3857
Fix indentation
nikhilsheoran-db f23ec0a
Address comment
nikhilsheoran-db 012545c
Add e2e test
nikhilsheoran-db 8832ab3
Merge remote-tracking branch 'origin/SPARK-49743' into SPARK-49743
nikhilsheoran-db File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -307,4 +307,21 @@ class OptimizeJsonExprsSuite extends PlanTest with ExpressionEvalHelper { | |
comparePlans(optimized, query.analyze) | ||
} | ||
} | ||
|
||
test("SPARK-49743: prune unnecessary columns from GetArrayStructFields does not change schema") { | ||
val options = Map.empty[String, String] | ||
val schema1 = ArrayType(StructType.fromDDL("a int, b int"), containsNull = true) | ||
|
||
val field1 = StructField("A", IntegerType) // Instead of "a", use "A" to test case sensitivity. | ||
val query1 = testRelation2 | ||
.select(GetArrayStructFields( | ||
JsonToStructs(schema1, options, $"json"), field1, 0, 2, true).as("a")) | ||
val optimized1 = Optimizer.execute(query1.analyze) | ||
|
||
val prunedSchema1 = ArrayType(StructType.fromDDL("a int"), containsNull = true) | ||
val expected1 = testRelation2 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ditto |
||
.select(GetArrayStructFields( | ||
JsonToStructs(prunedSchema1, options, $"json"), field1, 0, 1, true).as("a")).analyze | ||
comparePlans(optimized1, expected1) | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe just
schema
? I don't see there areschema2
,schema3
...etc.