You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2019/02/04 14:53:09 UTC

[GitHub] maropu commented on a change in pull request #23726: [SPARK-26812][SQL] Report correct nullability for complex datatypes in Union

maropu commented on a change in pull request #23726: [SPARK-26812][SQL] Report correct nullability for complex datatypes in Union
URL: https://github.com/apache/spark/pull/23726#discussion_r253499819
 
 

 ##########
 File path: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/logical/basicLogicalOperators.scala
 ##########
 @@ -230,9 +231,19 @@ case class Union(children: Seq[LogicalPlan]) extends LogicalPlan {
   }
 
   // updating nullability to make all the children consistent
-  override def output: Seq[Attribute] =
-    children.map(_.output).transpose.map(attrs =>
-      attrs.head.withNullability(attrs.exists(_.nullable)))
+  override def output: Seq[Attribute] = {
+    children.map(_.output).transpose.map { attrs =>
+      val firstAttr = attrs.head
+      val outAttr = try {
+        firstAttr.withDataType(attrs.map(_.dataType).reduce(StructType.merge))
+      } catch {
+        // If the data types are not compatible (eg. Decimals with different precision/scale)
+        // return the first type
 
 Review comment:
   All type compatibly checks should be in `resolved`?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org