wForget commented on PR #1428: URL: https://github.com/apache/datafusion-comet/pull/1428#issuecomment-2684022663
Integral divide of `decimal` type has inconsistent behavior. test: ``` test("test integral divide") { withTable("t1", "t2") { if (isSpark34Plus) { // Decimal support requires Spark 3.4 or later sql("create table t2(c1 DECIMAL(38, 37), c2 DECIMAL(38, 37)) using parquet") sql("insert into t2 values(6.0096743305738933273387748827369321010, 6.0096763826458053191384497987259478584)") checkSparkAnswerAndOperator("select c1 / c2, cast((c1 / c2 ) as long), c1 div c2 from t2 order by c1") } } } ``` Results do not match: ``` == Results == !== Correct Answer - 1 == == Spark Answer - 1 == struct<(c1 / c2):decimal(38,6),CAST((c1 / c2) AS BIGINT):bigint,(c1 div c2):bigint> struct<(c1 / c2):decimal(38,6),CAST((c1 / c2) AS BIGINT):bigint,(c1 div c2):bigint> ![1.000000,1,0] [1.000000,1,1] ``` This is due to the rounding behavior of `decimal_div`: https://github.com/apache/datafusion-comet/blob/58a36b62004c1e300d7f3113d9a64713a94c0db9/native/spark-expr/src/math_funcs/div.rs#L72-L76 -- 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: github-unsubscr...@datafusion.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org For additional commands, e-mail: github-h...@datafusion.apache.org