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

   ### Describe the bug
   
   When converting `BinaryExpr` expressions to Substrait using 
`from_binary_expr`, the resulting scalar function omits the `output_type` 
field. This happens via the `make_binary_op_scalar_func` helper, which always 
sets `output_type: None` 
([ref](https://github.com/apache/datafusion/blob/07a310fea8d287805d1490e9dc3c1b7b1c2775d8/datafusion/substrait/src/logical_plan/producer.rs#L1337))
   
   <img width="686" alt="Image" 
src="https://github.com/user-attachments/assets/6ed2b553-cf67-4492-9c7a-5c536d04703e";
 />
   
   According to the [Substrait 
specification](https://substrait.io/expressions/scalar_functions/), 
`output_type` should be specified when the return type can be determined. For 
most binary expressions (e.g., arithmetic or comparison), the return type is 
well-defined and static.
   
   <img width="868" alt="Image" 
src="https://github.com/user-attachments/assets/b29641c2-8260-438a-ad7e-bb57ae3761e1";
 />
   
   ### To Reproduce
   
   1. Convert any binary expression (a + b, a = b, a AND b, etc.) using 
`to_substrait_rex`.
   2. Inspect the resulting Expression’s scalar function.
   3. Observe that `output_type` is None.
   
   ### Expected behavior
   
   `output_type` should be populated with the correct type derived from the 
operator and operand types, aligning with Substrait spec expectations and 
improving downstream plan validation and usage.
   
   ### Additional context
   
   This affects:
   - `make_binary_op_scalar_func`
   - `from_binary_expr`
   
   Similar omissions of output_type can also be found in:
   - `from_scalar_function`
   - `from_window_function`
   - `from_in_list` (when negated)
   - `from_in_subquery` (when negated)
   - `from_like` (when negated)
   
   This issue focuses on `BinaryExpr` to keep the scope targeted, but these 
other cases could benefit from a similar treatment in follow-up work.


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