edponce commented on a change in pull request #11023:
URL: https://github.com/apache/arrow/pull/11023#discussion_r732325339
##########
File path: cpp/src/arrow/compute/kernels/scalar_string_test.cc
##########
@@ -751,6 +746,108 @@ TYPED_TEST(TestStringKernels, Utf8Title) {
R"([null, "", "B", "Aaaz;Zææ&", "Ɑɽɽow", "Ii", "Ⱥ.Ⱥ.Ⱥ..Ⱥ", "Hello,
World!", "Foo Bar;Héhé0Zop", "!%$^.,;"])");
}
+TYPED_TEST(TestStringKernels, StringRepeat) {
+ auto values = ArrayFromJSON(
+ this->type(),
+ R"(["aAazZæÆ&", null, "", "b", "ɑɽⱤoW", "ıI", "ⱥⱥⱥȺ", "hEllO, WoRld!",
"$. A3", "!ɑⱤⱤow"])");
+ {
+ std::vector<std::pair<int, std::string>> nrepeats_and_expected{{
+ {0, R"(["", null, "", "", "", "", "", "", "", ""])"},
+ {1,
+ R"(["aAazZæÆ&", null, "", "b", "ɑɽⱤoW", "ıI", "ⱥⱥⱥȺ", "hEllO,
WoRld!", "$. A3", "!ɑⱤⱤow"])"},
+ {4,
+ R"(["aAazZæÆ&aAazZæÆ&aAazZæÆ&aAazZæÆ&", null, "", "bbbb",
"ɑɽⱤoWɑɽⱤoWɑɽⱤoWɑɽⱤoW", "ıIıIıIıI", "ⱥⱥⱥȺⱥⱥⱥȺⱥⱥⱥȺⱥⱥⱥȺ", "hEllO, WoRld!hEllO,
WoRld!hEllO, WoRld!hEllO, WoRld!", "$. A3$. A3$. A3$. A3",
"!ɑⱤⱤow!ɑⱤⱤow!ɑⱤⱤow!ɑⱤⱤow"])"},
+ }};
+
+ for (const auto& pair : nrepeats_and_expected) {
+ auto num_repeat = pair.first;
+ auto expected = pair.second;
+ for (const auto& ty : NumericTypes()) {
+ this->CheckVarArgs("string_repeat",
+ {values, Datum(*arrow::MakeScalar(ty, num_repeat))},
+ this->type(), expected);
+ }
+ }
+ }
+ {
+ // Negative repeat count
+ std::vector<std::pair<int, std::string>> nrepeats_and_expected{{
+ {-1, R"(["", null, "", "", "", "", "", "", "", ""])"},
+ {-4, R"(["", null, "", "", "", "", "", "", "", ""])"},
+ }};
+
+ for (const auto& pair : nrepeats_and_expected) {
+ auto num_repeat = pair.first;
+ auto expected = pair.second;
+ for (const auto& ty : SignedIntTypes()) {
+ this->CheckVarArgs("string_repeat",
+ {values, Datum(*arrow::MakeScalar(ty, num_repeat))},
+ this->type(), expected);
+ }
+ }
+ }
+ // {
+ // // Truncated floating point repeat count
+ // std::vector<std::pair<double, std::string>> nrepeats_and_expected{{
+ // {0.9, R"(["", null, "", "", "", "", "", "", "", ""])"},
+ // {1.8,
+ // R"(["aAazZæÆ&", null, "", "b", "ɑɽⱤoW", "ıI", "ⱥⱥⱥȺ", "hEllO,
WoRld!", "$.
+ // A3", "!ɑⱤⱤow"])"},
+ // {4.4,
+ // R"(["aAazZæÆ&aAazZæÆ&aAazZæÆ&aAazZæÆ&", null, "", "bbbb",
+ // "ɑɽⱤoWɑɽⱤoWɑɽⱤoWɑɽⱤoW", "ıIıIıIıI", "ⱥⱥⱥȺⱥⱥⱥȺⱥⱥⱥȺⱥⱥⱥȺ", "hEllO,
WoRld!hEllO,
+ // WoRld!hEllO, WoRld!hEllO, WoRld!", "$. A3$. A3$. A3$. A3",
+ // "!ɑⱤⱤow!ɑⱤⱤow!ɑⱤⱤow!ɑⱤⱤow"])"},
+ // }};
+ //
+ // for (const auto& pair : nrepeats_and_expected) {
+ // auto num_repeat = pair.first;
+ // auto expected = pair.second;
+ // for (const auto& ty : FloatingPointTypes()) {
+ // this->CheckVarArgs("string_repeat",
+ // {values, Datum(*arrow::MakeScalar(ty,
num_repeat))},
+ // this->type(), expected);
+ // }
+ // }
+ // }
Review comment:
These are tests for using floating-point values for repeat count (such
functionality is not yet supported). Nonetheless, now we are not going to
support such implicit casts so I removed this code block in current local
version.
--
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]