neilconway opened a new issue, #25946:
URL: https://github.com/apache/datafusion/issues/25946

   ### Describe the bug
   
   For a decimal column declared `NOT NULL`, `col % 1` returns 0 for every row: 
`1.50 % 1` returns `0.00`. The same expression on a nullable decimal column 
returns the correct `0.50`. Filters on the expression are wrong as well.
   
   ### To Reproduce
   
   ```sql
   CREATE TABLE t (d DECIMAL(10,2) NOT NULL, n DECIMAL(10,2)) AS VALUES (1.50, 
1.50);
   
   SELECT d % 1 AS not_null_col, n % 1 AS nullable_col FROM t;
   -- not_null_col: 0.00 (wrong), nullable_col: 0.50
   
   SELECT count(*) AS cnt FROM t WHERE d % 1 = 0;
   -- 1 (expected 0)
   
   SELECT d % CAST(1 AS DECIMAL(10,2)) AS dec_literal FROM t;
   -- 0.00 (wrong)
   ```
   
   ### Expected behavior
   
   `d % 1` returns `0.50`, matching the nullable column, and the `WHERE` query 
returns 0.
   
   ### Additional context
   
   Reproduced on `main` at commit 2b1fcae86, in both release and debug builds.
   
   *This bug report was generated by Claude.*
   


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