HyukjinKwon commented on a change in pull request #28860:
URL: https://github.com/apache/spark/pull/28860#discussion_r446110366
##########
File path:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/complexTypeExtractors.scala
##########
@@ -95,6 +112,50 @@ object ExtractValue {
trait ExtractValue extends Expression
+object ExtractNestedArray {
+
+ type ReturnType = Option[(DataType, Boolean, Seq[Boolean])]
+
+ def unapply(dataType: DataType): ReturnType = {
+ extractArrayType(dataType)
+ }
+
+ def extractArrayType(dataType: DataType): ReturnType = {
+ dataType match {
+ case ArrayType(dt, containsNull) =>
+ extractArrayType(dt) match {
+ case Some((d, cn, seq)) => Some(d, cn, containsNull +: seq)
+ case None => Some(dt, containsNull, Seq.empty[Boolean])
+ }
+ case _ => None
+ }
+ }
+}
+
+/**
+ * Extract GetArrayStructField from Expression
+ */
+object ExtractGetArrayStructField {
+
+ type ReturnType = Option[(Expression, Int)]
+
+ def unapply(expr: Expression): ReturnType = {
+ extractArrayStruct(expr)
+ }
+
+ def extractArrayStruct(expr: Expression): ReturnType = {
+ expr match {
+ case gas @ GetArrayStructFields(child, _, _, _, _) =>
+ extractArrayStruct(child) match {
+ case Some((e, deep)) => Some(e, deep + 1)
Review comment:
`deep` -> `depth`?
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]