alamb commented on a change in pull request #7998:
URL: https://github.com/apache/arrow/pull/7998#discussion_r473002717
##########
File path: rust/datafusion/src/execution/physical_plan/expressions.rs
##########
@@ -966,11 +966,32 @@ impl fmt::Display for BinaryExpr {
impl PhysicalExpr for BinaryExpr {
fn data_type(&self, input_schema: &Schema) -> Result<DataType> {
- self.left.data_type(input_schema)
+ Ok(match self.op {
+ Operator::And
+ | Operator::Or
+ | Operator::Not
+ | Operator::NotLike
+ | Operator::Like
+ | Operator::Lt
+ | Operator::LtEq
+ | Operator::Eq
+ | Operator::NotEq
+ | Operator::Gt
+ | Operator::GtEq => DataType::Boolean,
+ Operator::Plus
+ | Operator::Minus
+ | Operator::Multiply
+ | Operator::Divide
+ | Operator::Modulus => {
+ // this assumes that the left and right expressions have
already been co-coerced
+ // to the same type
+ self.left.data_type(input_schema)?
Review comment:
it might be worth a ticket to track the work that `data_type for
BinaryExpr is incorrect
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]