Skip to content

Commit 6541ec4

Browse files
committed
added union check rule
1 parent 728af88 commit 6541ec4

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/CheckAnalysis.scala

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,18 @@ trait CheckAnalysis {
105105

106106
cleaned.foreach(checkValidAggregateExpression)
107107

108+
case u @ Union(left, right) if left.output.size != right.output.size =>
109+
failAnalysis(
110+
s"union's left child and right child have different output size. " +
111+
s"union node: $u left output size: ${left.output.size}, " +
112+
s"right output size: ${right.output.size}")
113+
114+
case u @ Union(left, right) if left.output.zip(right.output).exists(z => z._1.dataType != z._2.dataType) =>
115+
failAnalysis(
116+
s"union's left child and right child have different output types." +
117+
s"union node: $u. left output datatypes: ${left.output.map(_.dataType)}, " +
118+
s"right output datatypes: ${right.output.map(_.dataType)}")
119+
108120
case _ => // Fallbacks to the following checks
109121
}
110122

0 commit comments

Comments
 (0)