alamb commented on a change in pull request #2103:
URL: https://github.com/apache/arrow-datafusion/pull/2103#discussion_r836798190



##########
File path: datafusion-jit/src/ast.rs
##########
@@ -137,6 +138,58 @@ pub enum Literal {
     Typed(TypedLit),
 }
 
+impl TryFrom<datafusion_expr::Expr> for Expr {
+    type Error = DataFusionError;
+
+    fn try_from(value: datafusion_expr::Expr) -> Result<Self, Self::Error> {
+        match &value {
+            datafusion_expr::Expr::BinaryExpr { left, op, right } => {
+                let op = match op {
+                    datafusion_expr::Operator::Eq => BinaryExpr::Eq,
+                    datafusion_expr::Operator::NotEq => BinaryExpr::Ne,
+                    datafusion_expr::Operator::Lt => BinaryExpr::Lt,
+                    datafusion_expr::Operator::LtEq => BinaryExpr::Le,
+                    datafusion_expr::Operator::Gt => BinaryExpr::Gt,
+                    datafusion_expr::Operator::GtEq => BinaryExpr::Ge,
+                    datafusion_expr::Operator::Plus => BinaryExpr::Add,
+                    datafusion_expr::Operator::Minus => BinaryExpr::Sub,
+                    datafusion_expr::Operator::Multiply => BinaryExpr::Mul,
+                    datafusion_expr::Operator::Divide => BinaryExpr::Div,
+                    _ => {
+                        return Err(DataFusionError::NotImplemented(format!(
+                            "Compiling binary expression {} not yet supported",
+                            value
+                        )))
+                    }
+                };
+                Ok(Expr::Binary(op(
+                    Box::new((*left.clone()).try_into()?),
+                    Box::new((*right.clone()).try_into()?),
+                )))
+            }
+            datafusion_expr::Expr::Literal(s) => {
+                let lit = match s {
+                    ScalarValue::Boolean(Some(b)) => TypedLit::Bool(*b),
+                    ScalarValue::Float32(Some(f)) => TypedLit::Float(*f),
+                    ScalarValue::Float64(Some(f)) => TypedLit::Double(*f),
+                    ScalarValue::Int64(Some(i)) => TypedLit::Int(*i),
+                    _ => {
+                        return Err(DataFusionError::NotImplemented(format!(
+                            "Scalar {} not yet supported",

Review comment:
       ```suggestion
                               Compiling Scalar {} not yet supported in JIT 
mode",
   ```




-- 
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...@arrow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to