Skip to content

Commit ca737c6

Browse files
committed
fix
1 parent e4f0c68 commit ca737c6

7 files changed

Lines changed: 20 additions & 16 deletions

File tree

sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/Cast.scala

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,7 @@ case class Cast(child: Expression, dataType: DataType, timeZoneId: Option[String
537537
if (longValue == longValue.toShort) {
538538
longValue.toShort
539539
} else {
540-
throw new ArithmeticException(s"Casting $t to short causes overflow.")
540+
throw new ArithmeticException(s"Casting $t to short causes overflow")
541541
}
542542
})
543543
case TimestampType =>
@@ -548,12 +548,12 @@ case class Cast(child: Expression, dataType: DataType, timeZoneId: Option[String
548548
x.exactNumeric.asInstanceOf[Numeric[Any]].toInt(b)
549549
} catch {
550550
case _: ArithmeticException =>
551-
throw new ArithmeticException(s"Casting $b to short causes overflow.")
551+
throw new ArithmeticException(s"Casting $b to short causes overflow")
552552
}
553553
if (intValue == intValue.toShort) {
554554
intValue.toShort
555555
} else {
556-
throw new ArithmeticException(s"Casting $b to short causes overflow.")
556+
throw new ArithmeticException(s"Casting $b to short causes overflow")
557557
}
558558
case x: NumericType =>
559559
b => x.numeric.asInstanceOf[Numeric[Any]].toInt(b).toShort
@@ -578,7 +578,7 @@ case class Cast(child: Expression, dataType: DataType, timeZoneId: Option[String
578578
if (longValue == longValue.toByte) {
579579
longValue.toByte
580580
} else {
581-
throw new ArithmeticException(s"Casting $t to byte causes overflow.")
581+
throw new ArithmeticException(s"Casting $t to byte causes overflow")
582582
}
583583
})
584584
case TimestampType =>
@@ -589,12 +589,12 @@ case class Cast(child: Expression, dataType: DataType, timeZoneId: Option[String
589589
x.exactNumeric.asInstanceOf[Numeric[Any]].toInt(b)
590590
} catch {
591591
case _: ArithmeticException =>
592-
throw new ArithmeticException(s"Casting $b to byte causes overflow.")
592+
throw new ArithmeticException(s"Casting $b to byte causes overflow")
593593
}
594594
if (intValue == intValue.toByte) {
595595
intValue.toByte
596596
} else {
597-
throw new ArithmeticException(s"Casting $b to byte causes overflow.")
597+
throw new ArithmeticException(s"Casting $b to byte causes overflow")
598598
}
599599
case x: NumericType =>
600600
b => x.numeric.asInstanceOf[Numeric[Any]].toInt(b).toByte

sql/catalyst/src/main/scala/org/apache/spark/sql/types/Decimal.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ final class Decimal extends Ordered[Decimal] with Serializable {
239239
def toByte: Byte = toLong.toByte
240240

241241
private def overflowException(dataType: String) =
242-
throw new ArithmeticException(s"Casting $this to $dataType causes overflow.")
242+
throw new ArithmeticException(s"Casting $this to $dataType causes overflow")
243243

244244
/**
245245
* @return the Byte value that is equal to the rounded decimal.

sql/catalyst/src/main/scala/org/apache/spark/sql/types/numerics.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,13 +114,13 @@ object LongExactNumeric extends LongIsIntegral with Ordering.LongOrdering {
114114
if (x == x.toInt) {
115115
x.toInt
116116
} else {
117-
throw new ArithmeticException(s"Casting $x to int causes overflow.")
117+
throw new ArithmeticException(s"Casting $x to int causes overflow")
118118
}
119119
}
120120

121121
object FloatExactNumeric extends FloatIsFractional with Ordering.FloatOrdering {
122122
private def overflowException(x: Float, dataType: String) =
123-
throw new ArithmeticException(s"Casting $x to $dataType causes overflow.")
123+
throw new ArithmeticException(s"Casting $x to $dataType causes overflow")
124124

125125
private val intUpperBound = Int.MaxValue.toFloat
126126
private val intLowerBound = Int.MinValue.toFloat
@@ -152,7 +152,7 @@ object FloatExactNumeric extends FloatIsFractional with Ordering.FloatOrdering {
152152

153153
object DoubleExactNumeric extends DoubleIsFractional with Ordering.DoubleOrdering {
154154
private def overflowException(x: Double, dataType: String) =
155-
throw new ArithmeticException(s"Casting $x to $dataType causes overflow.")
155+
throw new ArithmeticException(s"Casting $x to $dataType causes overflow")
156156

157157
private val intUpperBound = Int.MaxValue.toDouble
158158
private val intLowerBound = Int.MinValue.toDouble

sql/core/src/test/resources/sql-tests/results/pgSQL/float4.sql.out

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ SELECT int(float('-2147483900'))
337337
struct<>
338338
-- !query 37 output
339339
java.lang.ArithmeticException
340-
Casting -2.1474839E9 to int causes overflow.
340+
Casting -2.1474839E9 to int causes overflow
341341

342342

343343
-- !query 38
@@ -370,7 +370,7 @@ SELECT bigint(float('-9223380000000000000'))
370370
struct<>
371371
-- !query 41 output
372372
java.lang.ArithmeticException
373-
Casting -9.22338E18 to int causes overflow.
373+
Casting -9.22338E18 to int causes overflow
374374

375375

376376
-- !query 42

sql/core/src/test/resources/sql-tests/results/pgSQL/float8.sql.out

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -829,7 +829,7 @@ SELECT bigint(double('-9223372036854780000'))
829829
struct<>
830830
-- !query 93 output
831831
java.lang.ArithmeticException
832-
Casting -9.22337203685478E18 to long causes overflow.
832+
Casting -9.22337203685478E18 to long causes overflow
833833

834834

835835
-- !query 94

sql/core/src/test/resources/sql-tests/results/pgSQL/int8.sql.out

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -658,7 +658,7 @@ SELECT CAST(double('922337203685477580700.0') AS bigint)
658658
struct<>
659659
-- !query 66 output
660660
java.lang.ArithmeticException
661-
Casting 9.223372036854776E20 to long causes overflow.
661+
Casting 9.223372036854776E20 to long causes overflow
662662

663663

664664
-- !query 67
@@ -725,7 +725,7 @@ SELECT string(int(shiftleft(bigint(-1), 63))+1)
725725
struct<>
726726
-- !query 72 output
727727
java.lang.ArithmeticException
728-
Casting -9223372036854775808 to int causes overflow.
728+
Casting -9223372036854775808 to int causes overflow
729729

730730

731731
-- !query 73

sql/core/src/test/scala/org/apache/spark/sql/SQLQueryTestSuite.scala

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import org.apache.spark.sql.catalyst.plans.logical.sql.{DescribeColumnStatement,
2929
import org.apache.spark.sql.catalyst.rules.RuleExecutor
3030
import org.apache.spark.sql.catalyst.util.{fileToString, stringToFile}
3131
import org.apache.spark.sql.execution.HiveResult.hiveResultString
32+
import org.apache.spark.sql.execution.SQLExecution
3233
import org.apache.spark.sql.execution.command.{DescribeColumnCommand, DescribeCommandBase}
3334
import org.apache.spark.sql.internal.SQLConf
3435
import org.apache.spark.sql.test.SharedSparkSession
@@ -403,7 +404,10 @@ class SQLQueryTestSuite extends QueryTest with SharedSparkSession {
403404
val df = session.sql(sql)
404405
val schema = df.schema
405406
// Get answer, but also get rid of the #1234 expression ids that show up in explain plans
406-
val answer = hiveResultString(df.queryExecution.executedPlan).map(replaceNotIncludedMsg)
407+
val answer =
408+
SQLExecution.withNewExecutionId(session, df.queryExecution, Some(sql)) {
409+
hiveResultString(df.queryExecution.executedPlan).map(replaceNotIncludedMsg)
410+
}
407411

408412
// If the output is not pre-sorted, sort it.
409413
if (isSorted(df.queryExecution.analyzed)) (schema, answer) else (schema, answer.sorted)

0 commit comments

Comments
 (0)