Skip to content

Commit 9def789

Browse files
committed
more comments
1 parent d48590e commit 9def789

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,9 @@ object TypeCoercion {
146146
}
147147

148148
/**
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.
150152
*/
151153
private def findWiderTypeWithoutStringPromotion(types: Seq[DataType]): Option[DataType] = {
152154
types.foldLeft[Option[DataType]](Some(NullType))((r, c) => r match {
@@ -502,6 +504,9 @@ object TypeCoercion {
502504
case None => c
503505
}
504506

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
505510
case g @ Greatest(children) if !haveSameType(children) =>
506511
val types = children.map(_.dataType)
507512
findWiderTypeWithoutStringPromotion(types) match {

0 commit comments

Comments
 (0)