kosiew opened a new pull request, #16761:
URL: https://github.com/apache/datafusion/pull/16761

   ## Which issue does this PR close?
   
   - Closes #16760
   
   ## Rationale for this change
   
   Currently, binary arithmetic expressions involving `NULL` (e.g., `NULL - 
DATE '1984-02-28'`) fail coercion because they do not account for `NULL` types 
explicitly. This patch adds support for type coercion when one operand is 
`NULL`, aligning behavior with SQL semantics where operations involving `NULL` 
should return `NULL`.
   
   ## What changes are included in this PR?
   
   - Added logic in `BinaryTypeCoercer` to handle `NULL` in binary arithmetic 
expressions by coercing it to the non-null side's type.
   - Updated signature resolution to include this new coercion case.
   - Added SQL logic tests verifying expected behavior for `NULL` arithmetic 
with `DATE` values.
   
   ## Are these changes tested?
   
   Yes. New test cases are added in `dates.slt` to validate arithmetic 
involving `NULL`, ensuring that:
   - `NULL - DATE` returns `NULL`
   - `DATE - NULL` returns `NULL`
   
   ## Are there any user-facing changes?
   
   Yes. Users can now perform arithmetic operations with `NULL` operands in SQL 
queries without encountering coercion errors. This improves compatibility and 
correctness with standard SQL behavior.
   
   


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

Reply via email to