viirya commented on a change in pull request #34845:
URL: https://github.com/apache/spark/pull/34845#discussion_r766944588
##########
File path:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/NestedColumnAliasing.scala
##########
@@ -414,6 +409,23 @@ object GeneratorNestedColumnAliasing {
None
}
+ /**
+ * Replace the reference attribute of extractor expression with generator
input.
+ */
+ private def replaceGenerator(generator: ExplodeBase, expr: Expression):
Expression = {
+ expr.transformDown {
+ case a: Attribute if expr.references.contains(a) =>
+ generator.child
+ case g: GetStructField =>
+ // We cannot simply do a transformUp instead 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.
+ val fieldName = g.extractFieldName
+ val newChild = replaceGenerator(generator, g.child)
Review comment:
Okay, let me rewrite it using `mapChildren`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]