andygrove commented on a change in pull request #7998:
URL: https://github.com/apache/arrow/pull/7998#discussion_r472562916



##########
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:
       I'm pretty sure this still isn't correct, but is closer than what we had 
before.




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


Reply via email to