kevinmingtarja commented on issue #325:
URL:
https://github.com/apache/datafusion-comet/issues/325#issuecomment-2081332989
Current state for reference:
```
scala> import org.apache.spark.sql.types._
import org.apache.spark.sql.types._
scala> val inputs = Seq("", "0", "1", "+1.0", ".34", "-10.0",
"4e7").toDF("n")
inputs: org.apache.spark.sql.DataFrame = [n: string]
scala> inputs.write.mode("overwrite").parquet("test.parquet")
24/04/28 11:46:51 INFO src/lib.rs: Comet native library initialized
scala> val df = spark.read.parquet("test.parquet")
df: org.apache.spark.sql.DataFrame = [n: string]
scala> val df2 = df.withColumn("converted",
col("n").cast(DataTypes.createDecimalType(10, 2)))
df2: org.apache.spark.sql.DataFrame = [n: string, converted: decimal(10,2)]
scala> df2.show
+-----+---------+
| n|converted|
+-----+---------+
|-10.0| -10.00|
| +1.0| 1.00|
| .34| 0.34|
| 4e7| null|
| 1| 1.00|
| 0| 0.00|
| | 0.00|
+-----+---------+
scala> spark.conf.set("spark.comet.enabled", false)
scala> df2.show
+-----+-----------+
| n| converted|
+-----+-----------+
|-10.0| -10.00|
| +1.0| 1.00|
| .34| 0.34|
| 4e7|40000000.00|
| 1| 1.00|
| 0| 0.00|
| | null|
+-----+-----------+
```
Note: I encountered a `java.lang.AssertionError: assertion failed:
Decimal$DecimalIsFractional` on the second `df2.show`, but it seems like a
known issue and can safely be ignored:
https://kb.databricks.com/scala/decimal-is-fractional-error
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]