Skip to content

Commit 22a966d

Browse files
author
Davies Liu
committed
fix test
1 parent 7f9b428 commit 22a966d

File tree

4 files changed

+12
-13
lines changed

4 files changed

+12
-13
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -751,7 +751,7 @@ object HiveTypeCoercion {
751751

752752
// If input is a numeric type but not decimal, and we expect a decimal type,
753753
// cast the input to decimal.
754-
case (d: NumericType, _: DecimalType) => Cast(e, DecimalType.forType(d))
754+
case (d: NumericType, DecimalType) => Cast(e, DecimalType.forType(d))
755755
// For any other numeric types, implicitly cast to each other, e.g. long -> int, int -> long
756756
case (_: NumericType, target: NumericType) => Cast(e, target)
757757

@@ -760,7 +760,7 @@ object HiveTypeCoercion {
760760
case (TimestampType, DateType) => Cast(e, DateType)
761761

762762
// Implicit cast from/to string
763-
case (StringType, _: DecimalType) => Cast(e, DecimalType.SYSTEM_DEFAULT)
763+
case (StringType, DecimalType) => Cast(e, DecimalType.SYSTEM_DEFAULT)
764764
case (StringType, target: NumericType) => Cast(e, target)
765765
case (StringType, DateType) => Cast(e, DateType)
766766
case (StringType, TimestampType) => Cast(e, TimestampType)

sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/analysis/AnalysisSuite.scala

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,14 @@
1717

1818
package org.apache.spark.sql.catalyst.analysis
1919

20+
import org.apache.spark.sql.catalyst.dsl.expressions._
21+
import org.apache.spark.sql.catalyst.dsl.plans._
2022
import org.apache.spark.sql.catalyst.expressions._
2123
import org.apache.spark.sql.catalyst.plans.logical._
2224
import org.apache.spark.sql.types._
23-
import org.apache.spark.sql.catalyst.SimpleCatalystConf
24-
import org.apache.spark.sql.catalyst.dsl.expressions._
25-
import org.apache.spark.sql.catalyst.dsl.plans._
2625

2726
class AnalysisSuite extends AnalysisTest {
28-
import TestRelations._
27+
import org.apache.spark.sql.catalyst.analysis.TestRelations._
2928

3029
test("union project *") {
3130
val plan = (1 to 100)
@@ -96,7 +95,7 @@ class AnalysisSuite extends AnalysisTest {
9695
assert(pl(1).dataType == DoubleType)
9796
assert(pl(2).dataType == DoubleType)
9897
// StringType will be promoted into Decimal(38, 18)
99-
assert(pl(3).dataType == DecimalType(38, 29))
98+
assert(pl(3).dataType == DecimalType(38, 22))
10099
assert(pl(4).dataType == DoubleType)
101100
}
102101

sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/analysis/DecimalPrecisionSuite.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -136,10 +136,10 @@ class DecimalPrecisionSuite extends SparkFunSuite with BeforeAndAfter {
136136
checkType(Multiply(i, u), DecimalType(38, 18))
137137
checkType(Multiply(u, u), DecimalType(38, 36))
138138

139-
checkType(Divide(u, d1), DecimalType(38, 21))
140-
checkType(Divide(u, d2), DecimalType(38, 24))
141-
checkType(Divide(u, i), DecimalType(38, 29))
142-
checkType(Divide(u, u), DecimalType(38, 38))
139+
checkType(Divide(u, d1), DecimalType(38, 18))
140+
checkType(Divide(u, d2), DecimalType(38, 19))
141+
checkType(Divide(u, i), DecimalType(38, 23))
142+
checkType(Divide(u, u), DecimalType(38, 18))
143143

144144
checkType(Remainder(d1, u), DecimalType(19, 18))
145145
checkType(Remainder(d2, u), DecimalType(21, 18))

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1622,9 +1622,9 @@ class SQLQuerySuite extends QueryTest with SharedSQLContext {
16221622
checkAnswer(sql("select 10.3000 / 3.0"), Row(BigDecimal("3.4333333")))
16231623
checkAnswer(sql("select 10.30000 / 30.0"), Row(BigDecimal("0.343333333")))
16241624
checkAnswer(sql("select 10.300000000000000000 / 3.00000000000000000"),
1625-
Row(BigDecimal("3.4333333333333333333333333333333333333", new MathContext(38))))
1625+
Row(BigDecimal("3.433333333333333333333333333", new MathContext(38))))
16261626
checkAnswer(sql("select 10.3000000000000000000 / 3.00000000000000000"),
1627-
Row(null))
1627+
Row(BigDecimal("3.4333333333333333333333333333", new MathContext(38))))
16281628
}
16291629

16301630
test("SPARK-10215 Div of Decimal returns null") {

0 commit comments

Comments
 (0)