File tree Expand file tree Collapse file tree 2 files changed +7
-8
lines changed
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions Expand file tree Collapse file tree 2 files changed +7
-8
lines changed Original file line number Diff line number Diff line change @@ -679,8 +679,7 @@ trait ComplexTypeMergingExpression extends Expression {
679679 * A collection of data types used for resolution the output type of the expression. By default,
680680 * data types of all child expressions. The collection must not be empty.
681681 */
682- @ transient
683- lazy val inputTypesForMerging : Seq [DataType ] = children.map(_.dataType)
682+ @ transient lazy val inputTypesForMerging : Seq [DataType ] = children.map(_.dataType)
684683
685684 /**
686685 * A method determining whether the input types are equal ignoring nullable, containsNull and
@@ -707,12 +706,14 @@ trait ComplexTypeMergingExpression extends Expression {
707706 StructType (newFields)
708707 }
709708
710- override def dataType : DataType = {
709+ @ transient override lazy val dataType : DataType = {
711710 require(
712711 inputTypesForMerging.nonEmpty,
713712 " The collection of input data types must not be empty." )
714713 require(
715- areInputTypesForMergingEqual,
714+ inputTypesForMerging.sliding(2 , 1 ).forall {
715+ case Seq (dt1, dt2) => DataType .equalsIgnoreCaseAndNullability(dt1, dt2)
716+ },
716717 " All input types must be the same except nullable, containsNull, valueContainsNull flags." )
717718 inputTypesForMerging.reduceLeft(mergeTwoDataTypes)
718719 }
Original file line number Diff line number Diff line change @@ -34,8 +34,7 @@ import org.apache.spark.sql.types._
3434case class If (predicate : Expression , trueValue : Expression , falseValue : Expression )
3535 extends ComplexTypeMergingExpression {
3636
37- @ transient
38- override lazy val inputTypesForMerging : Seq [DataType ] = {
37+ @ transient override lazy val inputTypesForMerging : Seq [DataType ] = {
3938 Seq (trueValue.dataType, falseValue.dataType)
4039 }
4140
@@ -125,8 +124,7 @@ case class CaseWhen(
125124 override def children : Seq [Expression ] = branches.flatMap(b => b._1 :: b._2 :: Nil ) ++ elseValue
126125
127126 // both then and else expressions should be considered.
128- @ transient
129- override lazy val inputTypesForMerging : Seq [DataType ] = {
127+ @ transient override lazy val inputTypesForMerging : Seq [DataType ] = {
130128 branches.map(_._2.dataType) ++ elseValue.map(_.dataType)
131129 }
132130
You can’t perform that action at this time.
0 commit comments