AlvinJ15 commented on a change in pull request #11853:
URL: https://github.com/apache/arrow/pull/11853#discussion_r777819999
##########
File path: cpp/src/arrow/compute/kernels/vector_replace_test.cc
##########
@@ -798,5 +828,688 @@ TYPED_TEST(TestReplaceBinary, ReplaceWithMaskRandom) {
}
}
+template <typename T>
+class TestFillNullNumeric : public TestReplaceKernel<T> {
+ protected:
+ std::shared_ptr<DataType> type() override { return
default_type_instance<T>(); }
+};
+template <typename T>
+class TestFillNullDecimal : public TestReplaceKernel<T> {
+ protected:
+ std::shared_ptr<DataType> type() override { return
default_type_instance<T>(); }
+};
+template <typename T>
+class TestFillNullBinary : public TestReplaceKernel<T> {
+ protected:
+ std::shared_ptr<DataType> type() override { return
default_type_instance<T>(); }
+};
+
+TYPED_TEST_SUITE(TestFillNullNumeric, NumericBasedTypes);
+TYPED_TEST_SUITE(TestFillNullDecimal, DecimalArrowTypes);
+TYPED_TEST_SUITE(TestFillNullBinary, BaseBinaryArrowTypes);
+
+TYPED_TEST(TestFillNullNumeric, FillNullValuesForward) {
+ this->AssertFillNullArray(FillForwardNull, this->array("[]"),
this->array("[]"));
+
+ this->AssertFillNullArray(FillForwardNull, this->array("[null, null, null,
null]"),
+ this->array("[null, null, null, null]"));
+ this->AssertFillNullArray(FillForwardNull, this->array("[null, null, null,
4]"),
+ this->array("[null, null, null, 4]"));
+ this->AssertFillNullArray(FillForwardNull, this->array("[null, 4, null]"),
+ this->array("[null, 4, 4]"));
+ this->AssertFillNullArray(FillForwardNull, this->array("[null, null, 4,
null]"),
+ this->array("[null, null, 4, 4]"));
+ this->AssertFillNullArray(FillForwardNull, this->array("[null, null, null,
4, null]"),
+ this->array("[null, null, null, 4, 4]"));
+ this->AssertFillNullArray(FillForwardNull, this->array("[null, null, 4,null,
5, null]"),
+ this->array("[null, null, 4, 4, 5, 5]"));
+
+ this->AssertFillNullArray(FillForwardNull, this->array("[1,4,null]"),
+ this->array("[1,4,4]"));
+ this->AssertFillNullArray(FillForwardNull,
+ this->array("[1, 4, null, null, null, null]"),
+ this->array("[1, 4 ,4, 4, 4, 4]"));
+ this->AssertFillNullArray(FillForwardNull, this->array("[1, 4, null, 5,
null, null]"),
+ this->array("[1, 4 ,4, 5, 5, 5]"));
+ this->AssertFillNullArray(FillForwardNull,
+ this->array("[1, 4, null, 5, null, null, 6]"),
+ this->array("[1, 4 ,4, 5, 5, 5, 6]"));
+ this->AssertFillNullArray(FillForwardNull,
+ this->array("[1, 4, null, 5, null, null, 5]"),
+ this->array("[1, 4 ,4, 5, 5, 5, 5]"));
+ this->AssertFillNullArray(FillForwardNull,
+ this->array("[1, 4, null, 5, null, 6, null]"),
+ this->array("[1, 4 ,4, 5, 5, 6, 6]"));
+ this->AssertFillNullArray(FillForwardNull, this->array("[1, 4, null, 5,
null, 6, 7]"),
+ this->array("[1, 4 ,4, 5, 5, 6, 7]"));
+ this->AssertFillNullArray(FillForwardNull, this->array("[1, 4 ,4, 5, 5, 6,
7]"),
+ this->array("[1, 4 ,4, 5, 5, 6, 7]"));
+}
+
+TYPED_TEST(TestFillNullDecimal, FillNullValuesForward) {
+ this->AssertFillNullArray(FillForwardNull, this->array(R"([])"),
this->array(R"([])"));
+
+ this->AssertFillNullArray(FillForwardNull, this->array(R"([null, null, null,
null])"),
+ this->array(R"([null, null, null, null])"));
+ this->AssertFillNullArray(FillForwardNull,
+ this->array(R"([null, null, null, "30.00"])"),
+ this->array(R"([null, null, null, "30.00"])"));
+ this->AssertFillNullArray(FillForwardNull, this->array(R"([null, "30.00",
null])"),
+ this->array(R"([null, "30.00", "30.00"])"));
+ this->AssertFillNullArray(FillForwardNull,
+ this->array(R"([null, null, "30.00", null])"),
+ this->array(R"([null, null, "30.00", "30.00"])"));
+ this->AssertFillNullArray(FillForwardNull,
+ this->array(R"([null, null, null, "30.00",
null])"),
+ this->array(R"([null, null, null, "30.00",
"30.00"])"));
+ this->AssertFillNullArray(
+ FillForwardNull, this->array(R"([null, null, "30.00",null, "5.00",
null])"),
+ this->array(R"([null, null, "30.00", "30.00", "5.00", "5.00"])"));
+
+ this->AssertFillNullArray(FillForwardNull,
this->array(R"(["10.00","30.00",null])"),
+ this->array(R"(["10.00","30.00","30.00"])"));
+ this->AssertFillNullArray(
+ FillForwardNull, this->array(R"(["10.00", "30.00", null, null, null,
null])"),
+ this->array(R"(["10.00", "30.00" ,"30.00", "30.00", "30.00",
"30.00"])"));
+ this->AssertFillNullArray(
+ FillForwardNull, this->array(R"(["10.00", "30.00", null, "5.00", null,
null])"),
+ this->array(R"(["10.00", "30.00" ,"30.00", "5.00", "5.00", "5.00"])"));
+ this->AssertFillNullArray(
+ FillForwardNull,
+ this->array(R"(["10.00", "30.00", null, "5.00", null, null, "6.00"])"),
+ this->array(R"(["10.00", "30.00" ,"30.00", "5.00", "5.00", "5.00",
"6.00"])"));
+ this->AssertFillNullArray(
+ FillForwardNull,
+ this->array(R"(["10.00", "30.00", null, "5.00", null, null, "5.00"])"),
+ this->array(R"(["10.00", "30.00" ,"30.00", "5.00", "5.00", "5.00",
"5.00"])"));
+ this->AssertFillNullArray(
+ FillForwardNull,
+ this->array(R"(["10.00", "30.00", null, "5.00", null, "6.00", null])"),
+ this->array(R"(["10.00", "30.00" ,"30.00", "5.00", "5.00", "6.00",
"6.00"])"));
+ this->AssertFillNullArray(
+ FillForwardNull,
+ this->array(R"(["10.00", "30.00", null, "5.00", null, "6.00", "7.00"])"),
+ this->array(R"(["10.00", "30.00" ,"30.00", "5.00", "5.00", "6.00",
"7.00"])"));
+ this->AssertFillNullArray(
+ FillForwardNull,
+ this->array(R"(["10.00", "30.00" ,"30.00", "5.00", "5.00", "6.00",
"7.00"])"),
+ this->array(R"(["10.00", "30.00" ,"30.00", "5.00", "5.00", "6.00",
"7.00"])"));
+}
+
+TYPED_TEST(TestFillNullBinary, FillNullValuesForward) {
+ this->AssertFillNullArray(FillForwardNull, this->array(R"([])"),
this->array(R"([])"));
+
+ this->AssertFillNullArray(FillForwardNull, this->array(R"([null, null, null,
null])"),
+ this->array(R"([null, null, null, null])"));
+ this->AssertFillNullArray(FillForwardNull, this->array(R"([null, null, null,
"ccc"])"),
+ this->array(R"([null, null, null, "ccc"])"));
+ this->AssertFillNullArray(FillForwardNull, this->array(R"([null, "ccc",
null])"),
+ this->array(R"([null, "ccc", "ccc"])"));
+ this->AssertFillNullArray(FillForwardNull, this->array(R"([null, null,
"ccc", null])"),
+ this->array(R"([null, null, "ccc", "ccc"])"));
+ this->AssertFillNullArray(FillForwardNull,
+ this->array(R"([null, null, null, "ccc", null])"),
+ this->array(R"([null, null, null, "ccc",
"ccc"])"));
+ this->AssertFillNullArray(FillForwardNull,
+ this->array(R"([null, null, "ccc",null, "xyz",
null])"),
+ this->array(R"([null, null, "ccc", "ccc", "xyz",
"xyz"])"));
+
+ this->AssertFillNullArray(FillForwardNull,
this->array(R"(["aaa","ccc",null])"),
+ this->array(R"(["aaa","ccc","ccc"])"));
+ this->AssertFillNullArray(FillForwardNull,
+ this->array(R"(["aaa", "ccc", null, null, null,
null])"),
+ this->array(R"(["aaa", "ccc" ,"ccc", "ccc", "ccc",
"ccc"])"));
+ this->AssertFillNullArray(FillForwardNull,
+ this->array(R"(["aaa", "ccc", null, "xyz", null,
null])"),
+ this->array(R"(["aaa", "ccc" ,"ccc", "xyz", "xyz",
"xyz"])"));
+ this->AssertFillNullArray(
+ FillForwardNull, this->array(R"(["aaa", "ccc", null, "xyz", null, null,
"qwert"])"),
+ this->array(R"(["aaa", "ccc" ,"ccc", "xyz", "xyz", "xyz", "qwert"])"));
+ this->AssertFillNullArray(
+ FillForwardNull, this->array(R"(["aaa", "ccc", null, "xyz", null, null,
"xyz"])"),
+ this->array(R"(["aaa", "ccc" ,"ccc", "xyz", "xyz", "xyz", "xyz"])"));
+ this->AssertFillNullArray(
+ FillForwardNull, this->array(R"(["aaa", "ccc", null, "xyz", null,
"qwert", null])"),
+ this->array(R"(["aaa", "ccc" ,"ccc", "xyz", "xyz", "qwert", "qwert"])"));
+ this->AssertFillNullArray(
+ FillForwardNull, this->array(R"(["aaa", "ccc", null, "xyz", null,
"qwert", "uy"])"),
+ this->array(R"(["aaa", "ccc" ,"ccc", "xyz", "xyz", "qwert", "uy"])"));
+ this->AssertFillNullArray(
+ FillForwardNull,
+ this->array(R"(["aaa", "ccc" ,"ccc", "xyz", "xyz", "qwert", "uy"])"),
+ this->array(R"(["aaa", "ccc" ,"ccc", "xyz", "xyz", "qwert", "uy"])"));
+}
+
+TYPED_TEST(TestFillNullNumeric, FillNullValuesBackward) {
+ this->AssertFillNullArray(FillBackwardNull, this->array("[]"),
this->array("[]"));
+ this->AssertFillNullArray(FillBackwardNull, this->array("[null, null, null,
null]"),
+ this->array("[null, null, null, null]"));
+ this->AssertFillNullArray(FillBackwardNull, this->array("[null, 4, null,
null, null]"),
+ this->array("[4, 4,null, null, null]"));
+ this->AssertFillNullArray(FillBackwardNull, this->array("[null, null, null,
4]"),
+ this->array("[4, 4, 4, 4]"));
+ this->AssertFillNullArray(FillBackwardNull, this->array("[null, 4, null]"),
+ this->array("[4, 4, null]"));
+ this->AssertFillNullArray(FillBackwardNull, this->array("[null, null, 4,
null]"),
+ this->array("[4, 4, 4, null]"));
+ this->AssertFillNullArray(FillBackwardNull, this->array("[null, null, null,
4, null]"),
+ this->array("[4, 4, 4, 4, null]"));
+ this->AssertFillNullArray(FillBackwardNull,
+ this->array("[null, null, 4,null, 5, null]"),
+ this->array("[4, 4, 4, 5, 5, null]"));
+
+ this->AssertFillNullArray(FillBackwardNull, this->array("[1, 4, null]"),
+ this->array("[1, 4, null]"));
+ this->AssertFillNullArray(FillBackwardNull,
+ this->array("[1, 4, null, null, null, null]"),
+ this->array("[1, 4 ,null, null, null, null]"));
+ this->AssertFillNullArray(FillBackwardNull, this->array("[1, 4, null, 5,
null, null]"),
+ this->array("[1, 4 , 5, 5, null, null]"));
+ this->AssertFillNullArray(FillBackwardNull,
+ this->array("[1, 4, null, 5, null, null, 6]"),
+ this->array("[1, 4 ,5, 5, 6, 6, 6]"));
+ this->AssertFillNullArray(FillBackwardNull,
+ this->array("[1, 4, null, 5, null, null, 5]"),
+ this->array("[1, 4 ,5 , 5, 5, 5, 5]"));
+ this->AssertFillNullArray(FillBackwardNull,
+ this->array("[1, 4, null, 5, null, 6, null]"),
+ this->array("[1, 4 ,5 , 5, 6, 6, null]"));
+ this->AssertFillNullArray(FillBackwardNull, this->array("[1, 4, null, 5,
null, 6, 7]"),
+ this->array("[1, 4 ,5, 5, 6, 6, 7]"));
+ this->AssertFillNullArray(FillBackwardNull, this->array("[1, 4 ,5, 5, 6, 6,
7]"),
+ this->array("[1, 4 ,5, 5, 6, 6, 7]"));
+}
+
+TYPED_TEST(TestFillNullDecimal, FillNullValuesBackward) {
+ this->AssertFillNullArray(FillBackwardNull, this->array(R"([])"),
this->array(R"([])"));
+
+ this->AssertFillNullArray(FillBackwardNull, this->array(R"([null, null,
null, null])"),
+ this->array(R"([null, null, null, null])"));
+ this->AssertFillNullArray(FillBackwardNull,
+ this->array(R"([null, "40.00", null, null,
null])"),
+ this->array(R"(["40.00", "40.00",null, null,
null])"));
+ this->AssertFillNullArray(FillBackwardNull,
+ this->array(R"([null, null, null, "40.00"])"),
+ this->array(R"(["40.00", "40.00", "40.00",
"40.00"])"));
+ this->AssertFillNullArray(FillBackwardNull, this->array(R"([null, "40.00",
null])"),
+ this->array(R"(["40.00", "40.00", null])"));
+ this->AssertFillNullArray(FillBackwardNull,
+ this->array(R"([null, null, "40.00", null])"),
+ this->array(R"(["40.00", "40.00", "40.00",
null])"));
+ this->AssertFillNullArray(FillBackwardNull,
+ this->array(R"([null, null, null, "40.00",
null])"),
+ this->array(R"(["40.00", "40.00", "40.00",
"40.00", null])"));
+ this->AssertFillNullArray(
+ FillBackwardNull, this->array(R"([null, null, "40.00",null, "50.00",
null])"),
+ this->array(R"(["40.00", "40.00", "40.00", "50.00", "50.00", null])"));
+
+ this->AssertFillNullArray(FillBackwardNull, this->array(R"(["10.00",
"40.00", null])"),
+ this->array(R"(["10.00", "40.00", null])"));
+ this->AssertFillNullArray(FillBackwardNull,
+ this->array(R"(["10.00", "40.00", null, null,
null, null])"),
+ this->array(R"(["10.00", "40.00" ,null, null,
null, null])"));
+ this->AssertFillNullArray(
+ FillBackwardNull, this->array(R"(["10.00", "40.00", null, "50.00", null,
null])"),
+ this->array(R"(["10.00", "40.00" , "50.00", "50.00", null, null])"));
+ this->AssertFillNullArray(
+ FillBackwardNull,
+ this->array(R"(["10.00", "40.00", null, "50.00", null, null, "6.00"])"),
+ this->array(R"(["10.00", "40.00" ,"50.00", "50.00", "6.00", "6.00",
"6.00"])"));
+ this->AssertFillNullArray(
+ FillBackwardNull,
+ this->array(R"(["10.00", "40.00", null, "50.00", null, null, "50.00"])"),
+ this->array(R"(["10.00", "40.00" ,"50.00" , "50.00", "50.00", "50.00",
"50.00"])"));
+ this->AssertFillNullArray(
+ FillBackwardNull,
+ this->array(R"(["10.00", "40.00", null, "50.00", null, "6.00", null])"),
+ this->array(R"(["10.00", "40.00" ,"50.00" , "50.00", "6.00", "6.00",
null])"));
+ this->AssertFillNullArray(
+ FillBackwardNull,
+ this->array(R"(["10.00", "40.00", null, "50.00", null, "6.00",
"7.00"])"),
+ this->array(R"(["10.00", "40.00" ,"50.00", "50.00", "6.00", "6.00",
"7.00"])"));
+ this->AssertFillNullArray(
+ FillBackwardNull,
+ this->array(R"(["10.00", "40.00" ,"50.00", "50.00", "6.00", "6.00",
"7.00"])"),
+ this->array(R"(["10.00", "40.00" ,"50.00", "50.00", "6.00", "6.00",
"7.00"])"));
+}
+
+TYPED_TEST(TestFillNullBinary, FillNullValuesBackward) {
+ this->AssertFillNullArray(FillBackwardNull, this->array(R"([])"),
this->array(R"([])"));
+
+ this->AssertFillNullArray(FillBackwardNull, this->array(R"([null, null,
null, null])"),
+ this->array(R"([null, null, null, null])"));
+ this->AssertFillNullArray(FillBackwardNull,
+ this->array(R"([null, "afd", null, null, null])"),
+ this->array(R"(["afd", "afd",null, null, null])"));
+ this->AssertFillNullArray(FillBackwardNull, this->array(R"([null, null,
null, "afd"])"),
+ this->array(R"(["afd", "afd", "afd", "afd"])"));
+ this->AssertFillNullArray(FillBackwardNull, this->array(R"([null, "afd",
null])"),
+ this->array(R"(["afd", "afd", null])"));
+ this->AssertFillNullArray(FillBackwardNull, this->array(R"([null, null,
"afd", null])"),
+ this->array(R"(["afd", "afd", "afd", null])"));
+ this->AssertFillNullArray(FillBackwardNull,
+ this->array(R"([null, null, null, "afd", null])"),
+ this->array(R"(["afd", "afd", "afd", "afd",
null])"));
+ this->AssertFillNullArray(FillBackwardNull,
+ this->array(R"([null, null, "afd",null, "qwe",
null])"),
+ this->array(R"(["afd", "afd", "afd", "qwe", "qwe",
null])"));
+
+ this->AssertFillNullArray(FillBackwardNull, this->array(R"(["tyu", "afd",
null])"),
+ this->array(R"(["tyu", "afd", null])"));
+ this->AssertFillNullArray(FillBackwardNull,
+ this->array(R"(["tyu", "afd", null, null, null,
null])"),
+ this->array(R"(["tyu", "afd" ,null, null, null,
null])"));
+ this->AssertFillNullArray(FillBackwardNull,
+ this->array(R"(["tyu", "afd", null, "qwe", null,
null])"),
+ this->array(R"(["tyu", "afd" , "qwe", "qwe", null,
null])"));
+ this->AssertFillNullArray(
+ FillBackwardNull,
+ this->array(R"(["tyu", "afd", null, "qwe", null, null, "oiutyu"])"),
+ this->array(R"(["tyu", "afd" ,"qwe", "qwe", "oiutyu", "oiutyu",
"oiutyu"])"));
+ this->AssertFillNullArray(
+ FillBackwardNull, this->array(R"(["tyu", "afd", null, "qwe", null, null,
"qwe"])"),
+ this->array(R"(["tyu", "afd" ,"qwe" , "qwe", "qwe", "qwe", "qwe"])"));
+ this->AssertFillNullArray(
+ FillBackwardNull,
+ this->array(R"(["tyu", "afd", null, "qwe", null, "oiutyu", null])"),
+ this->array(R"(["tyu", "afd" ,"qwe" , "qwe", "oiutyu", "oiutyu",
null])"));
+ this->AssertFillNullArray(
+ FillBackwardNull,
+ this->array(R"(["tyu", "afd", null, "qwe", null, "oiutyu",
"aaaagggbbb"])"),
+ this->array(R"(["tyu", "afd" ,"qwe", "qwe", "oiutyu", "oiutyu",
"aaaagggbbb"])"));
+ this->AssertFillNullArray(
+ FillBackwardNull,
+ this->array(R"(["tyu", "afd" ,"qwe", "qwe", "oiutyu", "oiutyu",
"aaaagggbbb"])"),
+ this->array(R"(["tyu", "afd" ,"qwe", "qwe", "oiutyu", "oiutyu",
"aaaagggbbb"])"));
+}
+
+// For Test Blocks
+TYPED_TEST(TestFillNullNumeric, FillNullForwardLargeInput) {
+ using CType = typename TypeTraits<TypeParam>::CType;
+ random::RandomArrayGenerator rand(/*seed=*/1000);
+ int64_t len_null = 500;
+ int64_t len_random = 1000;
+ std::shared_ptr<Array> array_random =
+ rand.Numeric<TypeParam>(len_random, /*min=*/0, /*max=*/200, /*nulls=*/0);
+
+ if (array_random) {
Review comment:
same as the next comment, no support for rand.Numeric( ) for DateType,
even if I use rand.ArrayOf no support for
ConstantArrayGenerator::Numeric(DateTypes).
--
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]