martin-g commented on code in PR #19926:
URL: https://github.com/apache/datafusion/pull/19926#discussion_r2716588101


##########
datafusion/sqllogictest/test_files/scalar.slt:
##########
@@ -951,15 +951,29 @@ query TR
 select arrow_typeof(round('12345.55'::decimal(10,2), -1)),
        round('12345.55'::decimal(10,2), -1);
 ----
-Decimal128(10, 2) 12350
+Decimal128(11, 2) 12350
 
 # round decimal256 keeps decimals
 query TR
 select arrow_typeof(round('1234.5678'::decimal(50,4), 2)),
        round('1234.5678'::decimal(50,4), 2);
 ----
-Decimal256(50, 4) 1234.57
+Decimal256(51, 4) 1234.57

Review Comment:
   I was going to ask whether the increase of the precision could be done only 
when really needed.
   And I went checking what the other DBs do:
   
   1) Postgres (Supabase)
   `SELECT pg_typeof(round(999.9::DECIMAL(4,1)));` returns `numeric` (Not 
helpful)
   
   2) Apache Spark (v4.0.1)
   ```
   spark-sql (default)> SELECT typeof(round(999.9::DECIMAL(4,1))), 
round(999.9::DECIMAL(4,1));
   decimal(4,0)    1000
   Time taken: 0.032 seconds, Fetched 1 row(s)
   ```
   Reduced the scale!
   
   3) DuckDB
   ```
   SELECT typeof(round(999.9::DECIMAL(4,1))), round(999.9::DECIMAL(4,1));
   
┌────────────────────────────────────────────┬────────────────────────────────────┐
   │ typeof(round(CAST(999.9 AS DECIMAL(4,1)))) │ round(CAST(999.9 AS 
DECIMAL(4,1))) │
   │                  varchar                   │            decimal(4,0)       
     │
   
├────────────────────────────────────────────┼────────────────────────────────────┤
   │ DECIMAL(4,0)                               │                1000           
     │
   
└────────────────────────────────────────────┴────────────────────────────────────┘
   ```
   Reduced the scale!



-- 
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]

Reply via email to