From 942d814766251f879803f2a2cfa759cf57aa496c Mon Sep 17 00:00:00 2001
From: Denis Smirnov <sd@picodata.io>
Date: Tue, 1 Feb 2022 15:25:17 +0700
Subject: [PATCH] feat: remove plan.add_bool() (duplicates add_cond())

---
 src/ir/expression.rs                          | 13 -------------
 src/ir/operator/tests.rs                      |  2 +-
 src/ir/transformation/redistribution/tests.rs | 14 +++++++-------
 3 files changed, 8 insertions(+), 21 deletions(-)

diff --git a/src/ir/expression.rs b/src/ir/expression.rs
index 1a5f0a0094..13a1a3fbc1 100644
--- a/src/ir/expression.rs
+++ b/src/ir/expression.rs
@@ -224,19 +224,6 @@ impl Nodes {
 }
 
 impl Plan {
-    /// Add boolean node.
-    ///
-    /// # Errors
-    /// - when left or right nodes are invalid
-    pub fn add_bool(
-        &mut self,
-        left: usize,
-        op: operator::Bool,
-        right: usize,
-    ) -> Result<usize, QueryPlannerError> {
-        self.nodes.add_bool(left, op, right)
-    }
-
     /// Returns a list of columns from the child node outputs.
     /// If the column list is empty then copy all the columns to a new tuple.
     ///
diff --git a/src/ir/operator/tests.rs b/src/ir/operator/tests.rs
index d061c48ee1..7ff7b76dbf 100644
--- a/src/ir/operator/tests.rs
+++ b/src/ir/operator/tests.rs
@@ -306,7 +306,7 @@ fn selection_with_sub_query() {
         .add_row_from_sub_query(id, &children[..], children.len() - 1, &["b"])
         .unwrap();
     let a_id = plan.add_row_from_child(id, scan_t1_id, &["a"]).unwrap();
-    let eq_id = plan.add_bool(a_id, Bool::Eq, b_id).unwrap();
+    let eq_id = plan.add_cond(a_id, Bool::Eq, b_id).unwrap();
 
     let select_id = plan.add_select(&children[..], eq_id, id).unwrap();
     plan.set_top(select_id).unwrap();
diff --git a/src/ir/transformation/redistribution/tests.rs b/src/ir/transformation/redistribution/tests.rs
index b59d63f73b..e6ce627aee 100644
--- a/src/ir/transformation/redistribution/tests.rs
+++ b/src/ir/transformation/redistribution/tests.rs
@@ -39,7 +39,7 @@ fn segment_motion_for_sub_query() {
         .add_row_from_sub_query(id, &children[..], children.len() - 1, &["b"])
         .unwrap();
     let a_id = plan.add_row_from_child(id, scan_t1_id, &["a"]).unwrap();
-    let eq_id = plan.add_bool(a_id, Bool::Eq, b_id).unwrap();
+    let eq_id = plan.add_cond(a_id, Bool::Eq, b_id).unwrap();
 
     let select_id = plan.add_select(&children[..], eq_id, id).unwrap();
     plan.set_top(select_id).unwrap();
@@ -108,7 +108,7 @@ fn full_motion_less_for_sub_query() {
         .add_row_from_sub_query(id, &children[..], children.len() - 1, &["b"])
         .unwrap();
     let a_id = plan.add_row_from_child(id, scan_t1_id, &["a"]).unwrap();
-    let less_id = plan.add_bool(a_id, Bool::Lt, b_id).unwrap();
+    let less_id = plan.add_cond(a_id, Bool::Lt, b_id).unwrap();
 
     let select_id = plan.add_select(&children[..], less_id, id).unwrap();
     plan.set_top(select_id).unwrap();
@@ -162,7 +162,7 @@ fn full_motion_non_segment_outer_for_sub_query() {
         .add_row_from_sub_query(id, &children[..], children.len() - 1, &["a"])
         .unwrap();
     let b_id = plan.add_row_from_child(id, scan_t1_id, &["b"]).unwrap();
-    let eq_id = plan.add_bool(b_id, Bool::Eq, a_id).unwrap();
+    let eq_id = plan.add_cond(b_id, Bool::Eq, a_id).unwrap();
 
     let select_id = plan.add_select(&children[..], eq_id, id).unwrap();
     plan.set_top(select_id).unwrap();
@@ -208,7 +208,7 @@ fn local_sub_query() {
         .add_row_from_sub_query(id, &children[..], children.len() - 1, &["a"])
         .unwrap();
     let outer_a_id = plan.add_row_from_child(id, scan_t1_id, &["a"]).unwrap();
-    let eq_id = plan.add_bool(outer_a_id, Bool::Eq, inner_a_id).unwrap();
+    let eq_id = plan.add_cond(outer_a_id, Bool::Eq, inner_a_id).unwrap();
 
     let select_id = plan.add_select(&children[..], eq_id, id).unwrap();
     plan.set_top(select_id).unwrap();
@@ -270,7 +270,7 @@ fn multiple_sub_queries() {
         .unwrap();
     let sq1_outer_a_id = plan.add_row_from_child(id, scan_t1_id, &["a"]).unwrap();
     let less_id = plan
-        .add_bool(sq1_outer_a_id, Bool::Lt, sq1_inner_a_id)
+        .add_cond(sq1_outer_a_id, Bool::Lt, sq1_inner_a_id)
         .unwrap();
 
     let sq2_inner_a_id = plan
@@ -278,10 +278,10 @@ fn multiple_sub_queries() {
         .unwrap();
     let sq2_outer_a_id = plan.add_row_from_child(id, scan_t1_id, &["a"]).unwrap();
     let eq_id = plan
-        .add_bool(sq2_outer_a_id, Bool::Eq, sq2_inner_a_id)
+        .add_cond(sq2_outer_a_id, Bool::Eq, sq2_inner_a_id)
         .unwrap();
 
-    let or_id = plan.add_bool(less_id, Bool::Or, eq_id).unwrap();
+    let or_id = plan.add_cond(less_id, Bool::Or, eq_id).unwrap();
 
     let select_id = plan.add_select(&children[..], or_id, id).unwrap();
     plan.set_top(select_id).unwrap();
-- 
GitLab