@@ -220,19 +220,21 @@ object HiveTypeCoercion {
220220 // Skip nodes who's children have not been resolved yet.
221221 case e if ! e.childrenResolved => e
222222
223+ case b @ BinaryOperator (left, right)
224+ if left.dataType == NullType && right.dataType == NullType =>
225+ // If both inputs are null type (from null literals), cast the null type into some
226+ // specific type the expression expects, so expressions don't need to handle NullType
227+ val newLeft = Cast (left, b.inputType.defaultConcreteType)
228+ val newRight = Cast (right, b.inputType.defaultConcreteType)
229+ b.makeCopy(Array (newLeft, newRight))
230+
223231 case b @ BinaryOperator (left, right) if left.dataType != right.dataType =>
224232 findTightestCommonTypeOfTwo(left.dataType, right.dataType).map { commonType =>
225233 if (b.inputType.acceptsType(commonType)) {
226234 // If the expression accepts the tighest common type, cast to that.
227235 val newLeft = if (left.dataType == commonType) left else Cast (left, commonType)
228236 val newRight = if (right.dataType == commonType) right else Cast (right, commonType)
229237 b.makeCopy(Array (newLeft, newRight))
230- } else if (commonType == NullType ) {
231- // If the common type is null type (from null literals), cast the null type into the
232- // first accepted type.
233- val newLeft = Cast (left, b.inputType.defaultConcreteType)
234- val newRight = Cast (right, b.inputType.defaultConcreteType)
235- b.makeCopy(Array (newLeft, newRight))
236238 } else {
237239 // Otherwise, don't do anything with the expression.
238240 b
0 commit comments