Skip to content

[BUG] cast(9.95 as decimal(3,1)), actual: 9.9, expected: 10.0 #10809

@gerashegalov

Description

@gerashegalov

Repro

 ~/dist/spark-3.3.0-bin-hadoop3/bin/spark-shell  \
   --conf spark.plugins=com.nvidia.spark.SQLPlugin \
   --conf spark.rapids.sql.test.enabled=true \
   --conf spark.rapids.sql.explain=ALL 
   --jars dist/target/rapids-4-spark_2.12-24.06.0-SNAPSHOT-cuda11.jar 
scala> val df = Seq(9.95).toDF.coalesce(1)
df: org.apache.spark.sql.Dataset[org.apache.spark.sql.Row] = [value: double]

scala> spark.conf.set("spark.rapids.sql.enabled", true)

scala> df.selectExpr("cast(value as decimal(3,1))").collect()
24/05/13 11:34:42 WARN GpuOverrides: 
*Exec <ProjectExec> will run on GPU
  *Expression <Alias> cast(value#1 as decimal(3,1)) AS value#5 will run on GPU
    *Expression <Cast> cast(value#1 as decimal(3,1)) will run on GPU
  *Exec <CoalesceExec> will run on GPU
    ! <LocalTableScanExec> cannot run on GPU because GPU does not currently support the operator class org.apache.spark.sql.execution.LocalTableScanExec
      @Expression <AttributeReference> value#1 could run on GPU

res2: Array[org.apache.spark.sql.Row] = Array([9.9])

scala> spark.conf.set("spark.rapids.sql.enabled", false)

scala> df.selectExpr("cast(value as decimal(3,1))").collect()
res4: Array[org.apache.spark.sql.Row] = Array([10.0])

Related to #9682

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions