You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2021/10/01 06:26:05 UTC

[GitHub] [arrow-datafusion] Dandandan commented on a change in pull request #1066: WIP: Extended Tokomak optimizer

Dandandan commented on a change in pull request #1066:
URL: https://github.com/apache/arrow-datafusion/pull/1066#discussion_r719973613



##########
File path: datafusion/src/optimizer/tokomak/rules/constant_folding.rs
##########
@@ -0,0 +1,315 @@
+use super::super::TokomakDataType;
+use crate::physical_plan::type_coercion::data_types;
+use crate::{
+    error::DataFusionError,
+    logical_plan::Operator,
+    optimizer::tokomak::{scalar::TokomakScalar, Tokomak, TokomakExpr},
+    physical_plan::{
+        expressions::{CastExpr, TryCastExpr},
+        functions::{BuiltinScalarFunction, FunctionVolatility, Signature},
+        ColumnarValue,
+    },
+    scalar::ScalarValue,
+};
+use arrow::datatypes::DataType;
+use std::convert::TryInto;
+
+use super::utils::*;
+use egg::{rewrite as rw, *};
+
+fn rules() -> Vec<Rewrite<TokomakExpr, ()>> {
+    let a: Var = "?a".parse().unwrap();
+    let b: Var = "?b".parse().unwrap();
+    //let c: Var = "?c".parse().unwrap();
+    //let d: Var = "?d".parse().unwrap();
+    //let x: Var ="?x".parse().unwrap();
+    let func: Var = "?func".parse().unwrap();
+    let args: Var = "?args".parse().unwrap();
+    vec![
+        //Move these 4 to simplification
+        rw!("const-prop-between"; "(and (>= ?e ?a) (<= ?e ?b))"=> "false" if var_gt(a,b)),
+        rw!("const-prop-between_inverted"; "(and (< ?e ?a)(> ?e ?b))" => "true" if var_gt(a,b)),
+        rw!("const-prop-binop-col-eq"; "(= ?a ?a)" => "(is_not_null ?a)"),
+        rw!("const-prop-binop-col-neq"; "(<> ?a ?a)" => "false"),
+        rw!("const-prop-add"; "(+ ?a ?b)"=>{ const_binop(a,b, Operator::Plus) } ),

Review comment:
       Could we generalize these rules somehow to apply for all (binary) operators?




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

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