Skip to content

Commit

Permalink
Use withGpuSparkSession to customize SparkConf (#9769)
Browse files Browse the repository at this point in the history
Fixes #9768 

withGpuSparkSession for (Ansi)CastOpSuite @ (ansi) cast decimal to string

---------

Signed-off-by: Gera Shegalov <[email protected]>
  • Loading branch information
gerashegalov authored Nov 20, 2023
1 parent 0e6fda6 commit c6b0a50
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -458,14 +458,14 @@ class AnsiCastOpSuite extends GpuExpressionTestSuite {
}

test("ansi_cast decimal to string") {
val sqlCtx = SparkSession.getActiveSession.get.sqlContext
sqlCtx.setConf("spark.sql.legacy.allowNegativeScaleOfDecimal", "true")

Seq(10, 15, 18).foreach { precision =>
Seq(-precision, -5, 0, 5, precision).foreach { scale =>
testCastToString(DataTypes.createDecimalType(precision, scale),
ansiMode = true,
comparisonFunc = None)
withGpuSparkSession { spark =>
spark.conf.set("spark.sql.legacy.allowNegativeScaleOfDecimal", true.toString)
Seq(10, 15, 18).foreach { precision =>
Seq(-precision, -5, 0, 5, precision).foreach { scale =>
testCastToString(DataTypes.createDecimalType(precision, scale),
ansiMode = true,
comparisonFunc = None)
}
}
}
}
Expand Down
14 changes: 7 additions & 7 deletions tests/src/test/scala/com/nvidia/spark/rapids/CastOpSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -445,13 +445,13 @@ class CastOpSuite extends GpuExpressionTestSuite {
}

test("cast decimal to string") {
val sqlCtx = SparkSession.getActiveSession.get.sqlContext
sqlCtx.setConf("spark.sql.legacy.allowNegativeScaleOfDecimal", "true")

Seq(10, 15, 28).foreach { precision =>
Seq(-precision, -5, 0, 5, precision).foreach { scale =>
testCastToString(DataTypes.createDecimalType(precision, scale),
comparisonFunc = None)
withGpuSparkSession { spark =>
spark.conf.set("spark.sql.legacy.allowNegativeScaleOfDecimal", true.toString)
Seq(10, 15, 28).foreach { precision =>
Seq(-precision, -5, 0, 5, precision).foreach { scale =>
testCastToString(DataTypes.createDecimalType(precision, scale),
comparisonFunc = None)
}
}
}
}
Expand Down

0 comments on commit c6b0a50

Please sign in to comment.