File tree Expand file tree Collapse file tree 1 file changed +6
-1
lines changed
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Original file line number Diff line number Diff line change @@ -146,7 +146,9 @@ object TypeCoercion {
146
146
}
147
147
148
148
/**
149
- * Similar to [[findWiderCommonType ]], but can't promote to string.
149
+ * Similar to [[findWiderCommonType ]], but can't promote to string. This is also similar to
150
+ * [[findTightestCommonType ]], but can handle decimal types. If the wider decimal type exceeds
151
+ * system limitation, this rule will truncate the decimal type before return it.
150
152
*/
151
153
private def findWiderTypeWithoutStringPromotion (types : Seq [DataType ]): Option [DataType ] = {
152
154
types.foldLeft[Option [DataType ]](Some (NullType ))((r, c) => r match {
@@ -502,6 +504,9 @@ object TypeCoercion {
502
504
case None => c
503
505
}
504
506
507
+ // When finding wider type for `Greatest` and `Least`, we should handle decimal types even if
508
+ // we need to truncate, but we should not promote one side to string if the other side is
509
+ // string.g
505
510
case g @ Greatest (children) if ! haveSameType(children) =>
506
511
val types = children.map(_.dataType)
507
512
findWiderTypeWithoutStringPromotion(types) match {
You can’t perform that action at this time.
0 commit comments