bkmgit commented on a change in pull request #11882:
URL: https://github.com/apache/arrow/pull/11882#discussion_r775512462



##########
File path: cpp/src/arrow/compute/kernels/scalar_compare_test.cc
##########
@@ -1850,5 +1846,439 @@ TEST(TestMaxElementWiseMinElementWise, CommonTemporal) {
               ResultWith(ScalarFromJSON(date64(), "86400000")));
 }
 
+template <typename ArrowType>
+static void ValidateBetween(BetweenOptions options, const Datum& val, const 
Datum& lhs,
+                            const Datum& rhs, const Datum& expected) {
+  ASSERT_OK_AND_ASSIGN(
+      Datum result,
+      CallFunction(BetweenOperatorToFunctionName(options.op), {val, lhs, 
rhs}));
+  AssertArraysEqual(*expected.make_array(), *result.make_array(),
+                    /*verbose=*/true);
+}
+
+template <typename ArrowType>
+static void ValidateBetween(BetweenOptions options, const Datum& val, const 
Datum& lhs,
+                            const Datum& rhs, const char* expected_str) {
+  auto expected = ArrayFromJSON(TypeTraits<BooleanType>::type_singleton(), 
expected_str);
+  ValidateBetween<ArrowType>(options, val, lhs, rhs, expected);
+}
+
+template <typename ArrowType>
+static void ValidateBetween(BetweenOptions options, const Datum& val, const 
Datum& lhs,
+                            const char* rhs_str, const Datum& expected) {
+  auto rhs = ArrayFromJSON(TypeTraits<ArrowType>::type_singleton(), rhs_str);
+  ValidateBetween<ArrowType>(options, val, lhs, rhs, expected);
+}
+
+template <typename ArrowType>
+static void ValidateBetween(BetweenOptions options, const Datum& val, const 
char* lhs_str,
+                            const Datum& rhs, const Datum& expected) {
+  auto lhs = ArrayFromJSON(TypeTraits<ArrowType>::type_singleton(), lhs_str);
+  ValidateBetween<ArrowType>(options, val, lhs, rhs, expected);
+}
+
+template <typename ArrowType>
+static void ValidateBetween(BetweenOptions options, const char* val_str, const 
Datum& lhs,
+                            const Datum& rhs, const Datum& expected) {
+  auto val = ArrayFromJSON(TypeTraits<ArrowType>::type_singleton(), val_str);
+  ValidateBetween<ArrowType>(options, val, lhs, rhs, expected);
+}
+
+template <typename ArrowType>
+static void ValidateBetween(BetweenOptions options, const Datum& val, const 
Datum& lhs,
+                            const char* rhs_str, const char* expected_str) {
+  auto rhs = ArrayFromJSON(TypeTraits<ArrowType>::type_singleton(), rhs_str);
+  auto expected = ArrayFromJSON(TypeTraits<BooleanType>::type_singleton(), 
expected_str);
+  ValidateBetween<ArrowType>(options, val, lhs, rhs, expected);
+}
+
+template <typename ArrowType>
+static void ValidateBetween(BetweenOptions options, const Datum& val, const 
char* lhs_str,
+                            const Datum& rhs, const char* expected_str) {
+  auto lhs = ArrayFromJSON(TypeTraits<ArrowType>::type_singleton(), lhs_str);
+  auto expected = ArrayFromJSON(TypeTraits<BooleanType>::type_singleton(), 
expected_str);
+  ValidateBetween<ArrowType>(options, val, lhs, rhs, expected);
+}
+
+template <typename ArrowType>
+static void ValidateBetween(BetweenOptions options, const Datum& val, const 
char* lhs_str,
+                            const char* rhs_str, const Datum& expected) {
+  auto lhs = ArrayFromJSON(TypeTraits<ArrowType>::type_singleton(), lhs_str);
+  auto rhs = ArrayFromJSON(TypeTraits<ArrowType>::type_singleton(), rhs_str);
+  ValidateBetween<ArrowType>(options, val, lhs, rhs, expected);
+}
+
+template <typename ArrowType>
+static void ValidateBetween(BetweenOptions options, const char* val_str, const 
Datum& lhs,
+                            const Datum& rhs, const char* expected_str) {
+  auto val = ArrayFromJSON(TypeTraits<ArrowType>::type_singleton(), val_str);
+  auto expected = ArrayFromJSON(TypeTraits<BooleanType>::type_singleton(), 
expected_str);
+  ValidateBetween<ArrowType>(options, val, lhs, rhs, expected);
+}
+
+template <typename ArrowType>
+static void ValidateBetween(BetweenOptions options, const char* val_str,
+                            const char* lhs_str, const Datum& rhs,
+                            const Datum& expected) {
+  auto val = ArrayFromJSON(TypeTraits<ArrowType>::type_singleton(), val_str);
+  auto lhs = ArrayFromJSON(TypeTraits<ArrowType>::type_singleton(), lhs_str);
+  ValidateBetween<ArrowType>(options, val, lhs, rhs, expected);
+}
+
+template <typename ArrowType>
+static void ValidateBetween(BetweenOptions options, const char* val_str, const 
Datum& lhs,
+                            const char* rhs_str, const Datum& expected) {
+  auto val = ArrayFromJSON(TypeTraits<ArrowType>::type_singleton(), val_str);
+  auto rhs = ArrayFromJSON(TypeTraits<ArrowType>::type_singleton(), rhs_str);
+  ValidateBetween<ArrowType>(options, val, lhs, rhs, expected);
+}
+
+template <typename ArrowType>
+static void ValidateBetween(BetweenOptions options, const Datum& val, const 
char* lhs_str,
+                            const char* rhs_str, const char* expected_str) {
+  auto lhs = ArrayFromJSON(TypeTraits<ArrowType>::type_singleton(), lhs_str);
+  auto rhs = ArrayFromJSON(TypeTraits<ArrowType>::type_singleton(), rhs_str);
+  auto expected = ArrayFromJSON(TypeTraits<BooleanType>::type_singleton(), 
expected_str);
+  ValidateBetween<ArrowType>(options, val, lhs, rhs, expected);
+}
+
+template <typename ArrowType>
+static void ValidateBetween(BetweenOptions options, const char* val_str, const 
Datum& lhs,
+                            const char* rhs_str, const char* expected_str) {
+  auto val = ArrayFromJSON(TypeTraits<ArrowType>::type_singleton(), val_str);
+  auto rhs = ArrayFromJSON(TypeTraits<ArrowType>::type_singleton(), rhs_str);
+  auto expected = ArrayFromJSON(TypeTraits<BooleanType>::type_singleton(), 
expected_str);
+  ValidateBetween<ArrowType>(options, val, lhs, rhs, expected);
+}
+
+template <typename ArrowType>
+static void ValidateBetween(BetweenOptions options, const char* val_str,
+                            const char* lhs_str, const Datum& rhs,
+                            const char* expected_str) {
+  auto val = ArrayFromJSON(TypeTraits<ArrowType>::type_singleton(), val_str);
+  auto lhs = ArrayFromJSON(TypeTraits<ArrowType>::type_singleton(), lhs_str);
+  auto expected = ArrayFromJSON(TypeTraits<BooleanType>::type_singleton(), 
expected_str);
+  ValidateBetween<ArrowType>(options, val, lhs, rhs, expected);
+}
+
+template <typename ArrowType>
+static void ValidateBetween(BetweenOptions options, const char* val_str,
+                            const char* lhs_str, const char* rhs_str,
+                            const Datum& expected) {
+  auto val = ArrayFromJSON(TypeTraits<ArrowType>::type_singleton(), val_str);
+  auto lhs = ArrayFromJSON(TypeTraits<ArrowType>::type_singleton(), lhs_str);
+  auto rhs = ArrayFromJSON(TypeTraits<ArrowType>::type_singleton(), rhs_str);
+  ValidateBetween<ArrowType>(options, val, lhs, rhs, expected);
+}

Review comment:
       Ok. Done.




-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to