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-37577][SQL] Fix ClassCastException: ArrayType cannot be cast to StructType for Generate Pruning #34845
Conversation
Kubernetes integration test starting |
Kubernetes integration test status failure |
This comment has been minimized.
This comment has been minimized.
Thank you for pinging me, @viirya . |
StructField("o", ArrayType(StructType( | ||
Seq(StructField("s", StringType, false), | ||
StructField("b", ArrayType(StructType( | ||
Seq(StructField("e", StringType, false))), true), false) |
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.
Can we use more intrusive field names? o
, s
, b
, e
looks a little confusing.
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.
sure, i will update it.
Kubernetes integration test starting |
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/NestedColumnAliasing.scala
Show resolved
Hide resolved
Kubernetes integration test status failure |
Test build #146051 has finished for PR 34845 at commit
|
Kubernetes integration test starting |
Kubernetes integration test status failure |
Test build #146053 has finished for PR 34845 at commit
|
// `extractFieldName` could cause `ClassCastException` error. We need to get the | ||
// field name before replacing down the attribute/other extractor. | ||
val fieldName = g.extractFieldName | ||
val newChild = replaceGenerator(generator, g.child) |
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.
Can we do a manual top-down traversal via mapChildren
? It's weird to see a recursive call inside transformDown
.
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.
Okay, let me rewrite it using mapChildren
.
Kubernetes integration test starting |
Kubernetes integration test status failure |
Test build #146080 has finished for PR 34845 at commit
|
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.
+1, LGTM from my side, @viirya . Thank you.
Retest this please |
Kubernetes integration test starting |
Kubernetes integration test status failure |
Test build #146114 has finished for PR 34845 at commit
|
Thank you, @viirya , @HyukjinKwon , @cloud-fan . Merged to master. Could you make a backport to branch-3.2, @viirya ? |
Thanks. I will make a backport to branch-3.2. |
…ast to StructType for Generate Pruning ### What changes were proposed in this pull request? This patch fixes a bug in nested column pruning for Generate. The bug happens after we replace extractor's reference attribute with generator's input, then when we try to replace a top extractor (e.g. `GetStructField`), if the replaced child expression is array type, `extractFieldName` will fail by throwing `ClassCastException`. This is the backport from #34845 to branch-3.2. ### Why are the changes needed? In particular, when we transform the extractor and replace with generator's input, we cannot simply do a transform up because because if we replace the attribute, `extractFieldName` could cause `ClassCastException` error. We need to get the field name before replacing down the attribute/other extractor. ### Does this PR introduce _any_ user-facing change? No ### How was this patch tested? Added test. Closes #34885 from viirya/SPARK-37577-3.2. Authored-by: Liang-Chi Hsieh <viirya@gmail.com> Signed-off-by: Dongjoon Hyun <dongjoon@apache.org>
…ast to StructType for Generate Pruning ### What changes were proposed in this pull request? This patch fixes a bug in nested column pruning for Generate. The bug happens after we replace extractor's reference attribute with generator's input, then when we try to replace a top extractor (e.g. `GetStructField`), if the replaced child expression is array type, `extractFieldName` will fail by throwing `ClassCastException`. This is the backport from apache#34845 to branch-3.2. ### Why are the changes needed? In particular, when we transform the extractor and replace with generator's input, we cannot simply do a transform up because because if we replace the attribute, `extractFieldName` could cause `ClassCastException` error. We need to get the field name before replacing down the attribute/other extractor. ### Does this PR introduce _any_ user-facing change? No ### How was this patch tested? Added test. Closes apache#34885 from viirya/SPARK-37577-3.2. Authored-by: Liang-Chi Hsieh <viirya@gmail.com> Signed-off-by: Dongjoon Hyun <dongjoon@apache.org>
…ast to StructType for Generate Pruning ### What changes were proposed in this pull request? This patch fixes a bug in nested column pruning for Generate. The bug happens after we replace extractor's reference attribute with generator's input, then when we try to replace a top extractor (e.g. `GetStructField`), if the replaced child expression is array type, `extractFieldName` will fail by throwing `ClassCastException`. This is the backport from apache#34845 to branch-3.2. ### Why are the changes needed? In particular, when we transform the extractor and replace with generator's input, we cannot simply do a transform up because because if we replace the attribute, `extractFieldName` could cause `ClassCastException` error. We need to get the field name before replacing down the attribute/other extractor. ### Does this PR introduce _any_ user-facing change? No ### How was this patch tested? Added test. Closes apache#34885 from viirya/SPARK-37577-3.2. Authored-by: Liang-Chi Hsieh <viirya@gmail.com> Signed-off-by: Dongjoon Hyun <dongjoon@apache.org>
…ast to StructType for Generate Pruning ### What changes were proposed in this pull request? This patch fixes a bug in nested column pruning for Generate. The bug happens after we replace extractor's reference attribute with generator's input, then when we try to replace a top extractor (e.g. `GetStructField`), if the replaced child expression is array type, `extractFieldName` will fail by throwing `ClassCastException`. This is the backport from apache#34845 to branch-3.2. ### Why are the changes needed? In particular, when we transform the extractor and replace with generator's input, we cannot simply do a transform up because because if we replace the attribute, `extractFieldName` could cause `ClassCastException` error. We need to get the field name before replacing down the attribute/other extractor. ### Does this PR introduce _any_ user-facing change? No ### How was this patch tested? Added test. Closes apache#34885 from viirya/SPARK-37577-3.2. Authored-by: Liang-Chi Hsieh <viirya@gmail.com> Signed-off-by: Dongjoon Hyun <dongjoon@apache.org>
What changes were proposed in this pull request?
This patch fixes a bug in nested column pruning for Generate. The bug happens after we replace extractor's reference attribute with generator's input, then when we try to replace a top extractor (e.g.
GetStructField
), if the replaced child expression is array type,extractFieldName
will fail by throwingClassCastException
.Why are the changes needed?
In particular, when we transform the extractor and replace with generator's input, we cannot simply do a transform up because because if we replace the attribute,
extractFieldName
could causeClassCastException
error. We need to get the field name before replacing down the attribute/other extractor.Does this PR introduce any user-facing change?
No
How was this patch tested?
Added test.