This is an automated email from the ASF dual-hosted git repository.

jayzhan pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/datafusion.git


The following commit(s) were added to refs/heads/main by this push:
     new c2095e4200 Move bit_and_or_xor unit tests to slt (#10457)
c2095e4200 is described below

commit c2095e420088b4db2639829a11714839d59024f4
Author: NoeB <[email protected]>
AuthorDate: Sat May 11 14:30:22 2024 +0200

    Move bit_and_or_xor unit tests to slt (#10457)
    
    * move bit_and_or_xor unit tests to slt
    
    Signed-off-by: NoeB <[email protected]>
    
    * Apply suggestions from code review
    
    ---------
    
    Signed-off-by: NoeB <[email protected]>
---
 .../physical-expr/src/aggregate/bit_and_or_xor.rs  | 127 --------------
 datafusion/sqllogictest/test_files/aggregate.slt   | 195 +++++++++++++++++++++
 2 files changed, 195 insertions(+), 127 deletions(-)

diff --git a/datafusion/physical-expr/src/aggregate/bit_and_or_xor.rs 
b/datafusion/physical-expr/src/aggregate/bit_and_or_xor.rs
index 7244686a51..3fa225c5e4 100644
--- a/datafusion/physical-expr/src/aggregate/bit_and_or_xor.rs
+++ b/datafusion/physical-expr/src/aggregate/bit_and_or_xor.rs
@@ -693,130 +693,3 @@ where
             + self.values.capacity() * std::mem::size_of::<T::Native>()
     }
 }
-
-#[cfg(test)]
-mod tests {
-    use super::*;
-    use crate::expressions::col;
-    use crate::expressions::tests::aggregate;
-    use crate::generic_test_op;
-    use arrow::array::*;
-    use arrow::datatypes::*;
-
-    #[test]
-    fn bit_and_i32() -> Result<()> {
-        let a: ArrayRef = Arc::new(Int32Array::from(vec![4, 7, 15]));
-        generic_test_op!(a, DataType::Int32, BitAnd, ScalarValue::from(4i32))
-    }
-
-    #[test]
-    fn bit_and_i32_with_nulls() -> Result<()> {
-        let a: ArrayRef =
-            Arc::new(Int32Array::from(vec![Some(1), None, Some(3), Some(5)]));
-        generic_test_op!(a, DataType::Int32, BitAnd, ScalarValue::from(1i32))
-    }
-
-    #[test]
-    fn bit_and_i32_all_nulls() -> Result<()> {
-        let a: ArrayRef = Arc::new(Int32Array::from(vec![None, None]));
-        generic_test_op!(a, DataType::Int32, BitAnd, ScalarValue::Int32(None))
-    }
-
-    #[test]
-    fn bit_and_u32() -> Result<()> {
-        let a: ArrayRef = Arc::new(UInt32Array::from(vec![4_u32, 7_u32, 
15_u32]));
-        generic_test_op!(a, DataType::UInt32, BitAnd, ScalarValue::from(4u32))
-    }
-
-    #[test]
-    fn bit_or_i32() -> Result<()> {
-        let a: ArrayRef = Arc::new(Int32Array::from(vec![4, 7, 15]));
-        generic_test_op!(a, DataType::Int32, BitOr, ScalarValue::from(15i32))
-    }
-
-    #[test]
-    fn bit_or_i32_with_nulls() -> Result<()> {
-        let a: ArrayRef =
-            Arc::new(Int32Array::from(vec![Some(1), None, Some(3), Some(5)]));
-        generic_test_op!(a, DataType::Int32, BitOr, ScalarValue::from(7i32))
-    }
-
-    #[test]
-    fn bit_or_i32_all_nulls() -> Result<()> {
-        let a: ArrayRef = Arc::new(Int32Array::from(vec![None, None]));
-        generic_test_op!(a, DataType::Int32, BitOr, ScalarValue::Int32(None))
-    }
-
-    #[test]
-    fn bit_or_u32() -> Result<()> {
-        let a: ArrayRef = Arc::new(UInt32Array::from(vec![4_u32, 7_u32, 
15_u32]));
-        generic_test_op!(a, DataType::UInt32, BitOr, ScalarValue::from(15u32))
-    }
-
-    #[test]
-    fn bit_xor_i32() -> Result<()> {
-        let a: ArrayRef = Arc::new(Int32Array::from(vec![4, 7, 4, 7, 15]));
-        generic_test_op!(a, DataType::Int32, BitXor, ScalarValue::from(15i32))
-    }
-
-    #[test]
-    fn bit_xor_i32_with_nulls() -> Result<()> {
-        let a: ArrayRef = Arc::new(Int32Array::from(vec![
-            Some(1),
-            Some(1),
-            None,
-            Some(3),
-            Some(5),
-        ]));
-        generic_test_op!(a, DataType::Int32, BitXor, ScalarValue::from(6i32))
-    }
-
-    #[test]
-    fn bit_xor_i32_all_nulls() -> Result<()> {
-        let a: ArrayRef = Arc::new(Int32Array::from(vec![None, None]));
-        generic_test_op!(a, DataType::Int32, BitXor, ScalarValue::Int32(None))
-    }
-
-    #[test]
-    fn bit_xor_u32() -> Result<()> {
-        let a: ArrayRef =
-            Arc::new(UInt32Array::from(vec![4_u32, 7_u32, 4_u32, 7_u32, 
15_u32]));
-        generic_test_op!(a, DataType::UInt32, BitXor, ScalarValue::from(15u32))
-    }
-
-    #[test]
-    fn bit_xor_distinct_i32() -> Result<()> {
-        let a: ArrayRef = Arc::new(Int32Array::from(vec![4, 7, 4, 7, 15]));
-        generic_test_op!(a, DataType::Int32, DistinctBitXor, 
ScalarValue::from(12i32))
-    }
-
-    #[test]
-    fn bit_xor_distinct_i32_with_nulls() -> Result<()> {
-        let a: ArrayRef = Arc::new(Int32Array::from(vec![
-            Some(1),
-            Some(1),
-            None,
-            Some(3),
-            Some(5),
-        ]));
-        generic_test_op!(a, DataType::Int32, DistinctBitXor, 
ScalarValue::from(7i32))
-    }
-
-    #[test]
-    fn bit_xor_distinct_i32_all_nulls() -> Result<()> {
-        let a: ArrayRef = Arc::new(Int32Array::from(vec![None, None]));
-        generic_test_op!(a, DataType::Int32, DistinctBitXor, 
ScalarValue::Int32(None))
-    }
-
-    #[test]
-    fn bit_xor_distinct_u32() -> Result<()> {
-        let a: ArrayRef =
-            Arc::new(UInt32Array::from(vec![4_u32, 7_u32, 4_u32, 7_u32, 
15_u32]));
-        generic_test_op!(
-            a,
-            DataType::UInt32,
-            DistinctBitXor,
-            ScalarValue::from(12u32)
-        )
-    }
-}
diff --git a/datafusion/sqllogictest/test_files/aggregate.slt 
b/datafusion/sqllogictest/test_files/aggregate.slt
index 40f78e7f4d..1e0d522492 100644
--- a/datafusion/sqllogictest/test_files/aggregate.slt
+++ b/datafusion/sqllogictest/test_files/aggregate.slt
@@ -2285,6 +2285,201 @@ ORDER BY tag
 33 11 NULL 33 11 NULL 33 11 NULL B
 
 
+# bit_and_i32
+statement ok
+create table t (c int) as values (4), (7), (15);
+
+query IT
+Select bit_and(c), arrow_typeof(bit_and(c))  from t;
+----
+4 Int32
+
+statement ok
+drop table t;
+
+# bit_and_i32_with_nulls
+statement ok
+create table t (c int) as values (1), (NULL), (3), (5);
+
+query IT
+Select bit_and(c), arrow_typeof(bit_and(c)) from t;
+----
+1 Int32
+
+statement ok
+drop table t;
+
+# bit_and_i32_all_nulls
+statement ok
+create table t (c int) as values (NULL), (NULL);
+
+query IT
+Select bit_and(c), arrow_typeof(bit_and(c)) from t;
+----
+NULL Int32
+
+statement ok
+drop table t;
+
+# bit_and_u32
+statement ok
+create table t (c int unsigned) as values (4), (7), (15);
+
+query IT
+Select bit_and(c), arrow_typeof(bit_and(c)) from t;
+----
+4 UInt32
+
+statement ok
+drop table t;
+
+# bit_or_i32
+statement ok
+create table t (c int) as values (4), (7), (15);
+
+query IT
+Select bit_or(c), arrow_typeof(bit_or(c))  from t;
+----
+15 Int32
+
+statement ok
+drop table t;
+
+# bit_or_i32_with_nulls
+statement ok
+create table t (c int) as values (1), (NULL), (3), (5);
+
+query IT
+Select bit_or(c), arrow_typeof(bit_or(c))  from t;
+----
+7 Int32
+
+statement ok
+drop table t;
+
+#bit_or_i32_all_nulls
+statement ok
+create table t (c int) as values (NULL), (NULL);
+
+query IT
+Select bit_or(c), arrow_typeof(bit_or(c))  from t;
+----
+NULL Int32
+
+statement ok
+drop table t;
+
+
+#bit_or_u32
+statement ok
+create table t (c int unsigned) as values (4), (7), (15);
+
+query IT
+Select bit_or(c), arrow_typeof(bit_or(c))  from t;
+----
+15 UInt32
+
+statement ok
+drop table t;
+
+#bit_xor_i32
+statement ok
+create table t (c int) as values (4), (7), (4), (7), (15);
+
+query IT
+Select bit_xor(c), arrow_typeof(bit_xor(c))  from t;
+----
+15 Int32
+
+statement ok
+drop table t;
+
+# bit_xor_i32_with_nulls
+statement ok
+create table t (c int) as values (1), (1), (NULL), (3), (5);
+
+query IT
+Select bit_xor(c), arrow_typeof(bit_xor(c))  from t;
+----
+6 Int32
+
+statement ok
+drop table t;
+
+# bit_xor_i32_all_nulls
+statement ok
+create table t (c int) as values (NULL), (NULL);
+
+query IT
+Select bit_xor(c), arrow_typeof(bit_xor(c))  from t;
+----
+NULL Int32
+
+statement ok
+drop table t;
+
+# bit_xor_u32
+statement ok
+create table t (c int unsigned) as values (4), (7), (4), (7), (15);
+
+query IT
+Select bit_xor(c), arrow_typeof(bit_xor(c))  from t;
+----
+15 UInt32
+
+statement ok
+drop table t;
+
+# bit_xor_distinct_i32
+statement ok
+create table t (c int) as values (4), (7), (4), (7), (15);
+
+query IT
+Select bit_xor(DISTINCT c), arrow_typeof(bit_xor(DISTINCT c))  from t;
+----
+12 Int32
+
+statement ok
+drop table t;
+
+# bit_xor_distinct_i32_with_nulls
+statement ok
+create table t (c int) as values (1), (1), (NULL), (3), (5);
+
+query IT
+Select bit_xor(DISTINCT c), arrow_typeof(bit_xor(DISTINCT c))  from t;
+----
+7 Int32
+
+
+statement ok
+drop table t;
+
+# bit_xor_distinct_i32_all_nulls
+statement ok
+create table t (c int ) as values (NULL), (NULL);
+
+query IT
+Select bit_xor(DISTINCT c), arrow_typeof(bit_xor(DISTINCT c))  from t;
+----
+NULL Int32
+
+
+statement ok
+drop table t;
+
+# bit_xor_distinct_u32
+statement ok
+create table t (c int unsigned) as values (4), (7), (4), (7), (15);
+
+query IT
+Select bit_xor(DISTINCT c), arrow_typeof(bit_xor(DISTINCT c))  from t;
+----
+12 UInt32
+
+statement ok
+drop table t;
+
 statement ok
 create table bool_aggregate_functions (
   c1 boolean not null,


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to