Github user dongjoon-hyun commented on a diff in the pull request: https://github.com/apache/spark/pull/17251#discussion_r108854595 --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/generators.scala --- @@ -156,9 +157,21 @@ case class Stack(children: Seq[Expression]) extends Generator { } } + private def findDataType(column: Integer): DataType = { + // Find the first data type except NullType + for (i <- (column + 1) until children.length by numFields) { + if (children(i).dataType != NullType) { + return children(i).dataType + } + } + // If all values of the column are NullType, use it. + children(column + 1).dataType + } + override def elementSchema: StructType = StructType(children.tail.take(numFields).zipWithIndex.map { - case (e, index) => StructField(s"col$index", e.dataType) + case (e, index) if e.dataType != NullType => StructField(s"col$index", e.dataType) + case (_, index) => StructField(s"col$index", findDataType(index)) --- End diff -- Sure!
--- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. --- --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org