@@ -680,6 +680,99 @@ TYPED_TEST(TestCompareDecimal, DifferentParameters) {
680
680
}
681
681
}
682
682
683
+ template <typename ArrowType>
684
+ class TestCompareList : public ::testing::Test {};
685
+ TYPED_TEST_SUITE (TestCompareList, ListArrowTypes);
686
+
687
+ TYPED_TEST (TestCompareList, ArrayScalar) {
688
+ const auto int_value_typ = std::make_shared<Int32Type>();
689
+ const auto int_ty = std::make_shared<TypeParam>(std::move (int_value_typ));
690
+ const auto bin_value_typ = std::make_shared<StringType>();
691
+ const auto bin_ty = std::make_shared<TypeParam>(std::move (bin_value_typ));
692
+
693
+ const std::vector<std::pair<std::string, std::string>> cases = {
694
+ {" equal" , " [1, 0, 0, null]" },
695
+ {" not_equal" , " [0, 1, 1, null]" },
696
+ };
697
+ const auto lhs_int = ArrayFromJSON (int_ty, R"( [[1, 2, 3], [4, 5, 6], [42], null])" );
698
+ const auto lhs_bin = ArrayFromJSON (
699
+ bin_ty, R"( [["a", "b", "c"], ["foo", "bar", "baz"], ["hello"], null])" );
700
+ const auto rhs_int = ScalarFromJSON (int_ty, R"( [1, 2, 3])" );
701
+ const auto rhs_bin = ScalarFromJSON (bin_ty, R"( ["a", "b", "c"])" );
702
+ for (const auto & op : cases) {
703
+ const auto & function = op.first ;
704
+ const auto & expected = op.second ;
705
+
706
+ SCOPED_TRACE (function);
707
+ CheckScalarBinary (function, lhs_int, rhs_int, ArrayFromJSON (boolean (), expected));
708
+ CheckScalarBinary (function, lhs_bin, rhs_bin, ArrayFromJSON (boolean (), expected));
709
+ }
710
+ }
711
+
712
+ TYPED_TEST (TestCompareList, ScalarArray) {
713
+ const auto int_value_typ = std::make_shared<Int32Type>();
714
+ const auto int_ty = std::make_shared<TypeParam>(std::move (int_value_typ));
715
+ const auto bin_value_typ = std::make_shared<StringType>();
716
+ const auto bin_ty = std::make_shared<TypeParam>(std::move (bin_value_typ));
717
+
718
+ const std::vector<std::pair<std::string, std::string>> cases = {
719
+ {" equal" , " [1, 0, 0, null]" },
720
+ {" not_equal" , " [0, 1, 1, null]" },
721
+ };
722
+ const auto lhs_int = ScalarFromJSON (int_ty, R"( [1, 2, 3])" );
723
+ const auto lhs_bin = ScalarFromJSON (bin_ty, R"( ["a", "b", "c"])" );
724
+ const auto rhs_int = ArrayFromJSON (int_ty, R"( [[1, 2, 3], [4, 5, 6], [42], null])" );
725
+ const auto rhs_bin = ArrayFromJSON (
726
+ bin_ty, R"( [["a", "b", "c"], ["foo", "bar"], ["baz", "hello", "world"], null])" );
727
+ for (const auto & op : cases) {
728
+ const auto & function = op.first ;
729
+ const auto & expected = op.second ;
730
+
731
+ SCOPED_TRACE (function);
732
+ CheckScalarBinary (function, lhs_int, rhs_int, ArrayFromJSON (boolean (), expected));
733
+ CheckScalarBinary (function, lhs_bin, rhs_bin, ArrayFromJSON (boolean (), expected));
734
+ }
735
+ }
736
+
737
+ TYPED_TEST (TestCompareList, ArrayArray) {
738
+ const auto int_value_typ = std::make_shared<Int32Type>();
739
+ const auto int_ty = std::make_shared<TypeParam>(std::move (int_value_typ));
740
+ const auto bin_value_typ = std::make_shared<StringType>();
741
+ const auto bin_ty = std::make_shared<TypeParam>(std::move (bin_value_typ));
742
+
743
+ const std::vector<std::pair<std::string, std::string>> cases = {
744
+ {" equal" , " [1, 0, 0, null]" },
745
+ {" not_equal" , " [0, 1, 1, null]" },
746
+ };
747
+ const auto lhs_int = ArrayFromJSON (int_ty, R"( [[1, 2, 3], [4, 5, 6], [7], null])" );
748
+ const auto lhs_bin = ArrayFromJSON (
749
+ bin_ty, R"( [["a", "b", "c"], ["foo", "bar", "baz"], ["hello"], null])" );
750
+ const auto rhs_int = ArrayFromJSON (int_ty, R"( [[1, 2, 3], [4, 5], [6, 7, 8], null])" );
751
+ const auto rhs_bin = ArrayFromJSON (
752
+ bin_ty, R"( [["a", "b", "c"], ["foo", "bar"], ["baz", "hello", "world"], null])" );
753
+ for (const auto & op : cases) {
754
+ const auto & function = op.first ;
755
+ const auto & expected = op.second ;
756
+
757
+ SCOPED_TRACE (function);
758
+ CheckScalarBinary (function, ArrayFromJSON (int_ty, R"( [])" ),
759
+ ArrayFromJSON (int_ty, R"( [])" ), ArrayFromJSON (boolean (), " []" ));
760
+ CheckScalarBinary (function, ArrayFromJSON (int_ty, R"( [null])" ),
761
+ ArrayFromJSON (int_ty, R"( [null])" ),
762
+ ArrayFromJSON (boolean (), " [null]" ));
763
+
764
+ CheckScalarBinary (function, lhs_int, rhs_int, ArrayFromJSON (boolean (), expected));
765
+
766
+ CheckScalarBinary (function, ArrayFromJSON (bin_ty, R"( [])" ),
767
+ ArrayFromJSON (int_ty, R"( [])" ), ArrayFromJSON (boolean (), " []" ));
768
+ CheckScalarBinary (function, ArrayFromJSON (int_ty, R"( [null])" ),
769
+ ArrayFromJSON (bin_ty, R"( [null])" ),
770
+ ArrayFromJSON (boolean (), " [null]" ));
771
+
772
+ CheckScalarBinary (function, lhs_bin, rhs_bin, ArrayFromJSON (boolean (), expected));
773
+ }
774
+ }
775
+
683
776
// Helper to organize tests for fixed size binary comparisons
684
777
struct CompareCase {
685
778
std::shared_ptr<DataType> lhs_type;
0 commit comments