File tree Expand file tree Collapse file tree 1 file changed +5
-7
lines changed
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions Expand file tree Collapse file tree 1 file changed +5
-7
lines changed Original file line number Diff line number Diff line change @@ -163,15 +163,13 @@ case class SortPrefix(child: SortOrder) extends UnaryExpression {
163163 StringPrefixComparator .computePrefix(raw.asInstanceOf [UTF8String ])
164164 case BinaryType => (raw) =>
165165 BinaryPrefixComparator .computePrefix(raw.asInstanceOf [Array [Byte ]])
166+ case dt : DecimalType if dt.precision <= Decimal .MAX_LONG_DIGITS =>
167+ _.asInstanceOf [Decimal ].toUnscaledLong
166168 case dt : DecimalType if dt.precision - dt.scale <= Decimal .MAX_LONG_DIGITS => (raw) => {
167169 val value = raw.asInstanceOf [Decimal ]
168- if (dt.precision <= Decimal .MAX_LONG_DIGITS ) {
169- value.toUnscaledLong
170- } else {
171- val p = Decimal .MAX_LONG_DIGITS
172- val s = p - (dt.precision - dt.scale)
173- if (value.changePrecision(p, s)) value.toUnscaledLong else Long .MinValue
174- }
170+ val p = Decimal .MAX_LONG_DIGITS
171+ val s = p - (dt.precision - dt.scale)
172+ if (value.changePrecision(p, s)) value.toUnscaledLong else Long .MinValue
175173 }
176174 case dt : DecimalType => (raw) =>
177175 DoublePrefixComparator .computePrefix(raw.asInstanceOf [Decimal ].toDouble)
You can’t perform that action at this time.
0 commit comments