rtpsw commented on code in PR #13037:
URL: https://github.com/apache/arrow/pull/13037#discussion_r863549760
##########
cpp/src/arrow/compute/kernels/scalar_compare_test.cc:
##########
@@ -502,6 +502,53 @@ TEST(TestCompareTimestamps, DifferentParameters) {
}
}
+TEST(TestCompareTimestamps, ScalarArray) {
+ const char* scalar_json = R"("1970-01-02")";
+ const char* array_json = R"(["1970-01-02","2000-02-01","1900-02-28"])";
+
+ auto CheckArrayCase = [&](std::shared_ptr<DataType> scalar_type,
+ std::shared_ptr<DataType> array_type,
CompareOperator op,
+ const char* expected_json) {
+ auto lhs = ScalarFromJSON(scalar_type, scalar_json);
+ auto rhs = ArrayFromJSON(array_type, array_json);
+ auto expected = ArrayFromJSON(boolean(), expected_json);
+ if (scalar_type->Equals(array_type)) {
+ ASSERT_OK_AND_ASSIGN(Datum result,
+ CallFunction(CompareOperatorToFunctionName(op),
{lhs, rhs}));
+ AssertArraysEqual(*expected, *result.make_array(), /*verbose=*/true);
+ } else {
+ EXPECT_RAISES_WITH_MESSAGE_THAT(
+ Invalid,
+ ::testing::HasSubstr(
+ "Cannot compare timestamp with timezone to timestamp without
timezone"),
+ CallFunction(CompareOperatorToFunctionName(op), {lhs, rhs}));
+ }
+ };
+
+ for (auto unit : {
+ TimeUnit::SECOND,
+ TimeUnit::MILLI,
+ TimeUnit::MICRO,
+ TimeUnit::NANO,
+ }) {
Review Comment:
Included in recent commit.
--
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]