-
Notifications
You must be signed in to change notification settings - Fork 246
Closed
Labels
enhancementNew feature or requestNew feature or requestgood first issueGood for newcomersGood for newcomershelp wantedExtra attention is neededExtra attention is needed
Description
What is the problem the feature request solves?
Comet is not consistent with Spark when casting between decimals. Here is a test to demonstrate this.
test("cast between decimals with different precision and scale") {
val rowData = Seq(
Row(BigDecimal("12345.6789")),
Row(BigDecimal("9876.5432")),
Row(BigDecimal("123.4567"))
)
val df = spark.createDataFrame(
spark.sparkContext.parallelize(rowData),
StructType(Seq(StructField("a", DataTypes.createDecimalType(10,4))))
)
castTest(df, DataTypes.createDecimalType(6,2))
}Spark Result
+----------+-------+
| a| a|
+----------+-------+
| 123.4567| 123.46|
| 9876.5432|9876.54|
|12345.6789| null|
+----------+-------+
Comet Result
java.lang.ArithmeticException: Cannot convert 12345.68 (bytes: [B@4f834a43, integer: 1234568) to decimal with precision: 6 and scale: 2
at org.apache.comet.vector.CometVector.getDecimal(CometVector.java:86)
Describe the potential solution
No response
Additional context
No response
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or requestgood first issueGood for newcomersGood for newcomershelp wantedExtra attention is neededExtra attention is needed