diff --git a/velox/common/config/CMakeLists.txt b/velox/common/config/CMakeLists.txt index 7780665a2925..9639a2c8b6f7 100644 --- a/velox/common/config/CMakeLists.txt +++ b/velox/common/config/CMakeLists.txt @@ -12,13 +12,12 @@ # See the License for the specific language governing permissions and # limitations under the License. -if (${VELOX_BUILD_TESTING}) +if(${VELOX_BUILD_TESTING}) add_subdirectory(tests) -endif () +endif() velox_add_library(velox_common_config Config.cpp) velox_link_libraries( velox_common_config - PUBLIC velox_common_base - velox_exception + PUBLIC velox_common_base velox_exception PRIVATE re2::re2) diff --git a/velox/connectors/tpch/TpchConnector.cpp b/velox/connectors/tpch/TpchConnector.cpp index 7b7332f4f621..b2317774fe74 100644 --- a/velox/connectors/tpch/TpchConnector.cpp +++ b/velox/connectors/tpch/TpchConnector.cpp @@ -91,7 +91,7 @@ TpchDataSource::TpchDataSource( handle, "ColumnHandle must be an instance of TpchColumnHandle " "for '{}' on table '{}'", - handle->name(), + it->second->name(), toTableName(tpchTable_)); auto idx = tpchTableSchema->getChildIdxIfExists(handle->name()); diff --git a/velox/dwio/common/compression/Compression.h b/velox/dwio/common/compression/Compression.h index 3d26b3af98a4..3d447f402ce9 100644 --- a/velox/dwio/common/compression/Compression.h +++ b/velox/dwio/common/compression/Compression.h @@ -84,9 +84,9 @@ struct CompressionOptions { struct { bool isHadoopFrameFormat; } lz4_lzo; - } format; + } format{}; - uint32_t compressionThreshold; + uint32_t compressionThreshold{0}; }; /** diff --git a/velox/exec/tests/ContainerRowSerdeTest.cpp b/velox/exec/tests/ContainerRowSerdeTest.cpp index ebf47fc20dec..4bead42aa466 100644 --- a/velox/exec/tests/ContainerRowSerdeTest.cpp +++ b/velox/exec/tests/ContainerRowSerdeTest.cpp @@ -324,7 +324,11 @@ TEST_F(ContainerRowSerdeTest, nested) { testRoundTrip(data); auto nestedArray = makeNullableNestedArrayVector( - {{{{{"1", "2"}}, {{"3", "4"}}}}, {{}}, {{std::nullopt, {}}}}); + {{{{{"1", "2"}}, {{"3", "4"}}}}, + std::make_optional< + std::vector>>>>( + {}), + {{std::nullopt, {}}}}); testRoundTrip(nestedArray); diff --git a/velox/exec/tests/UnnestTest.cpp b/velox/exec/tests/UnnestTest.cpp index 7203fff8b2dd..7c8b88172d5f 100644 --- a/velox/exec/tests/UnnestTest.cpp +++ b/velox/exec/tests/UnnestTest.cpp @@ -70,7 +70,7 @@ TEST_P(UnnestTest, arrayWithOrdinality) { {{{1, 2, std::nullopt, 4}}, std::nullopt, {{5, 6}}, - {{}}, + std::make_optional>>({}), {{{{std::nullopt}}}}, {{7, 8, 9}}}); auto vector = makeRowVector( diff --git a/velox/expression/tests/ArrayWriterTest.cpp b/velox/expression/tests/ArrayWriterTest.cpp index 7398a9d6da53..ca1009ba6f9e 100644 --- a/velox/expression/tests/ArrayWriterTest.cpp +++ b/velox/expression/tests/ArrayWriterTest.cpp @@ -538,7 +538,7 @@ TEST_F(ArrayWriterTest, copyFromNestedArray) { vectorWriter.finish(); using array_type = std::optional>>; - array_type array1 = {{}}; + array_type array1 = std::make_optional({}); array_type array2 = {{1, 2, 3, 4}}; array_type array3 = {{1}}; diff --git a/velox/expression/tests/ExpressionRunner.cpp b/velox/expression/tests/ExpressionRunner.cpp index 7ce0cbefcef3..ae9b572f919e 100644 --- a/velox/expression/tests/ExpressionRunner.cpp +++ b/velox/expression/tests/ExpressionRunner.cpp @@ -227,13 +227,13 @@ void ExpressionRunner::run( std::vector inputSelectivityPaths = split(inputSelectivityVectorPaths); for (int i = 0; i < inputPathsList.size(); i++) { - auto inputVector = - std::dynamic_pointer_cast(restoreVectorFromFile( - inputPathsList[i].c_str(), deserializerPool.get())); + auto vector = restoreVectorFromFile( + inputPathsList[i].c_str(), deserializerPool.get()); + auto inputVector = std::dynamic_pointer_cast(vector); VELOX_CHECK_NOT_NULL( inputVector, "Input vector is not a RowVector: {}", - inputVector->toString()); + vector->toString()); VELOX_CHECK_GT(inputVector->size(), 0, "Input vector must not be empty."); if (inputSelectivityPaths.size() > i) { inputTestCases.push_back( diff --git a/velox/expression/tests/GenericViewTest.cpp b/velox/expression/tests/GenericViewTest.cpp index ffc5993b4b3f..f3de3ee6bc9f 100644 --- a/velox/expression/tests/GenericViewTest.cpp +++ b/velox/expression/tests/GenericViewTest.cpp @@ -38,7 +38,7 @@ class GenericViewTest : public functions::test::FunctionBaseTest { std::vector>>>; array_data_t arrayData1 = { - {{}}, + std::make_optional>>({}), {{{{std::nullopt}}}}, {{std::nullopt, 1}}, {{std::nullopt, std::nullopt, std::nullopt}}, @@ -56,7 +56,7 @@ class GenericViewTest : public functions::test::FunctionBaseTest { }; array_data_t arrayData2 = { - {{}}, + std::make_optional>>({}), {{{{std::nullopt}}}}, {{std::nullopt, 1}}, {{std::nullopt, std::nullopt, std::nullopt}}, diff --git a/velox/functions/lib/tests/Re2FunctionsTest.cpp b/velox/functions/lib/tests/Re2FunctionsTest.cpp index 3b0d6fe3f2cb..656cb742cc6e 100644 --- a/velox/functions/lib/tests/Re2FunctionsTest.cpp +++ b/velox/functions/lib/tests/Re2FunctionsTest.cpp @@ -1223,19 +1223,31 @@ TEST_F(Re2FunctionsTest, regexExtractAllNoMatch) { const std::vector> noGroupId = {}; const std::vector> groupIds0 = {0}; - testRe2ExtractAll({""}, {"[0-9]+"}, noGroupId, {{{}}}); - testRe2ExtractAll({"(╯°□°)╯︵ ┻━┻"}, {"[0-9]+"}, noGroupId, {{{}}}); - testRe2ExtractAll({"abcde"}, {"[0-9]+"}, groupIds0, {{{}}}); + testRe2ExtractAll( + {""}, + {"[0-9]+"}, + noGroupId, + {std::make_optional>({})}); + testRe2ExtractAll( + {"(╯°□°)╯︵ ┻━┻"}, + {"[0-9]+"}, + noGroupId, + {std::make_optional>({})}); + testRe2ExtractAll( + {"abcde"}, + {"[0-9]+"}, + groupIds0, + {std::make_optional>({})}); testRe2ExtractAll( {"rYBKVn6DnfSI2an4is4jbvf4btGpV"}, {"81jnp58n31BtMdlUsP1hiF4QWSYv411"}, noGroupId, - {{{}}}); + {std::make_optional>({})}); testRe2ExtractAll( {"rYBKVn6DnfSI2an4is4jbvf4btGpV"}, {"81jnp58n31BtMdlUsP1hiF4QWSYv411"}, groupIds0, - {{{}}}); + {std::make_optional>({})}); // Test empty pattern. testRe2ExtractAll( diff --git a/velox/functions/lib/tests/RepeatTest.cpp b/velox/functions/lib/tests/RepeatTest.cpp index 8e7b637aba7f..93686c9df30f 100644 --- a/velox/functions/lib/tests/RepeatTest.cpp +++ b/velox/functions/lib/tests/RepeatTest.cpp @@ -67,7 +67,7 @@ TEST_F(RepeatTest, repeat) { {{0.0}}, {{-2.0, -2.0}}, {{3.333333, 3.333333, 3.333333}}, - {{}}, + std::make_optional>>({}), {{std::nullopt, std::nullopt, std::nullopt, std::nullopt}}, std::nullopt, }); diff --git a/velox/functions/prestosql/aggregates/tests/ChecksumAggregateTest.cpp b/velox/functions/prestosql/aggregates/tests/ChecksumAggregateTest.cpp index 65c8a20a34d8..64c1b88d8360 100644 --- a/velox/functions/prestosql/aggregates/tests/ChecksumAggregateTest.cpp +++ b/velox/functions/prestosql/aggregates/tests/ChecksumAggregateTest.cpp @@ -281,8 +281,10 @@ TEST_F(ChecksumAggregateTest, arrays) { arrayVector = makeNullableArrayVector({{{1, 2}}, std::nullopt}); assertChecksum(arrayVector, "Nlzernkj88A="); - arrayVector = - makeNullableArrayVector({{{1, 2}}, std::nullopt, {{}}}); + arrayVector = makeNullableArrayVector( + {{{1, 2}}, + std::nullopt, + std::make_optional>>({})}); assertChecksum(arrayVector, "Nlzernkj88A="); // Array of arrays. diff --git a/velox/functions/prestosql/aggregates/tests/ClassificationAggregationTest.cpp b/velox/functions/prestosql/aggregates/tests/ClassificationAggregationTest.cpp index e28995e2cc4f..a5337044445c 100644 --- a/velox/functions/prestosql/aggregates/tests/ClassificationAggregationTest.cpp +++ b/velox/functions/prestosql/aggregates/tests/ClassificationAggregationTest.cpp @@ -117,7 +117,7 @@ TEST_F(ClassificationAggregationTest, basic) { }); expected = makeRowVector({makeNullableArrayVector( - std::vector>>>{{{}}})}); + {{std::make_optional>>({})}})}); runTest("classification_fall_out(5, c0, c1)", input, expected); runTest("classification_precision(5, c0, c1)", input, expected); runTest("classification_recall(5, c0, c1)", input, expected); diff --git a/velox/functions/prestosql/aggregates/tests/MapUnionAggregationTest.cpp b/velox/functions/prestosql/aggregates/tests/MapUnionAggregationTest.cpp index a1f86d3ffd88..cc376db155bb 100644 --- a/velox/functions/prestosql/aggregates/tests/MapUnionAggregationTest.cpp +++ b/velox/functions/prestosql/aggregates/tests/MapUnionAggregationTest.cpp @@ -255,7 +255,8 @@ TEST_F(MapUnionTest, nulls) { makeNullableMapVector({ {{{1, 10}, {2, 20}, {3, 33}, {4, 44}, {5, 55}}}, std::nullopt, - {{}}, + std::make_optional< + std::vector>>>({}), }), }); diff --git a/velox/functions/prestosql/aggregates/tests/MapUnionSumTest.cpp b/velox/functions/prestosql/aggregates/tests/MapUnionSumTest.cpp index 447438207d50..868be6399508 100644 --- a/velox/functions/prestosql/aggregates/tests/MapUnionSumTest.cpp +++ b/velox/functions/prestosql/aggregates/tests/MapUnionSumTest.cpp @@ -30,7 +30,9 @@ class MapUnionSumTest : public AggregationTestBase {}; TEST_F(MapUnionSumTest, global) { auto data = makeRowVector({ makeNullableMapVector({ - {{}}, // empty map + std::make_optional< + std::vector>>>( + {}), // empty map std::nullopt, // null map {{{1, 10}, {2, 20}}}, {{{1, 11}, {3, 30}, {4, 40}}}, @@ -62,7 +64,9 @@ TEST_F(MapUnionSumTest, globalVarcharKey) { auto data = makeRowVector({ makeNullableMapVector({ - {{}}, // empty map + std::make_optional< + std::vector>>>( + {}), // empty map std::nullopt, // null map {{{keys[0], 10}, {keys[1], 20}}}, {{{keys[0], 11}, {keys[2], 30}, {keys[3], 40}}}, @@ -119,9 +123,11 @@ TEST_F(MapUnionSumTest, nullAndEmptyMaps) { auto emptyAndNullMaps = makeRowVector({ makeNullableMapVector({ std::nullopt, - {{}}, + std::make_optional< + std::vector>>>({}), std::nullopt, - {{}}, + std::make_optional< + std::vector>>>({}), }), }); diff --git a/velox/functions/prestosql/aggregates/tests/PrestoHasherTest.cpp b/velox/functions/prestosql/aggregates/tests/PrestoHasherTest.cpp index 6b1c004b9283..e7b3468d7d37 100644 --- a/velox/functions/prestosql/aggregates/tests/PrestoHasherTest.cpp +++ b/velox/functions/prestosql/aggregates/tests/PrestoHasherTest.cpp @@ -293,7 +293,7 @@ TEST_F(PrestoHasherTest, arrays) { {{10, 11}}, {{12, std::nullopt}}, std::nullopt, - {{}}}); + std::make_optional>>({})}); assertHash( baseArrayVector, @@ -320,7 +320,7 @@ TEST_F(PrestoHasherTest, arrays) { {{std::nullopt}}, {{1, 2, 3}}, {{1024, std::nullopt, -99, -999}}, - {{}}, + std::make_optional>>({}), {{std::nullopt, -1}}, }); diff --git a/velox/functions/prestosql/aggregates/tests/SetAggTest.cpp b/velox/functions/prestosql/aggregates/tests/SetAggTest.cpp index 125d04f681b7..a903eab85daf 100644 --- a/velox/functions/prestosql/aggregates/tests/SetAggTest.cpp +++ b/velox/functions/prestosql/aggregates/tests/SetAggTest.cpp @@ -525,7 +525,7 @@ TEST_F(SetAggTest, arrayNestedNulls) { }); auto expected = makeRowVector({makeNullableNestedArrayVector( - {{{{{}}, + {{{std::make_optional>>({}), {{1, 2}}, {{2, 3}}, {{3, std::nullopt}}, @@ -544,7 +544,8 @@ TEST_F(SetAggTest, arrayNestedNulls) { expected = makeRowVector( {makeFlatVector({1, 2, 3, 4}), makeNullableNestedArrayVector( - {{{{{{}}, {{1, 2}}}}, + {{{{std::make_optional>>({}), + {{1, 2}}}}, {{{{6, 7}}, {{std::nullopt, 7}}}}, {{{{2, 3}}, {{3, std::nullopt}}}}, {{{{8, 9}}, {{std::nullopt, std::nullopt}}}}}})}); diff --git a/velox/functions/prestosql/tests/ArrayCombinationsTest.cpp b/velox/functions/prestosql/tests/ArrayCombinationsTest.cpp index 1e1d408cfab8..17e7a4830270 100644 --- a/velox/functions/prestosql/tests/ArrayCombinationsTest.cpp +++ b/velox/functions/prestosql/tests/ArrayCombinationsTest.cpp @@ -42,7 +42,8 @@ class ArrayCombinationsTest : public FunctionBaseTest { {{{{std::vector>()}}}, {{{{0, 1, 2}}, {{0, 1, 3}}, {{0, 2, 3}}, {{1, 2, 3}}}}, {{{{0, 1, 2, 3}}}}, - {{}}}); + std::make_optional< + std::vector>>>>({})}); testExpr( expected, "combinations(C0, C1)", {arrayVector, comboLengthVector}); } @@ -68,7 +69,8 @@ class ArrayCombinationsTest : public FunctionBaseTest { {{ {{0, 1, std::nullopt, 3}}, }}, - {{}}, + std::make_optional< + std::vector>>>>({}), }); testExpr( expected, "combinations(C0, C1)", {arrayVector, comboLengthVector}); @@ -175,7 +177,8 @@ TEST_F(ArrayCombinationsTest, inlineVarcharArrays) { {{"bb", "aa", "aa", "ddd"}}, {{"bb", "cc", "aa", "ddd"}}, {{"aa", "cc", "aa", "ddd"}}}}, - {{}}}); + std::make_optional< + std::vector>>>>({})}); testExpr(expected, "combinations(C0, C1)", {arrayVector, comboLengthVector}); } @@ -222,7 +225,8 @@ TEST_F(ArrayCombinationsTest, varcharArrays) { "yellow rose flowers", "red shiny car ahead", "purple is an elegant color"}}}}, - {{}}}); + std::make_optional< + std::vector>>>>({})}); testExpr(expected, "combinations(C0, C1)", {arrayVector, comboLengthVector}); } @@ -245,7 +249,8 @@ TEST_F(ArrayCombinationsTest, boolNullableArrays) { {{false, true, true, true}}, {{false, false, true, true}}, {{true, false, true, true}}}}, - {{}}}); + std::make_optional< + std::vector>>>>({})}); testExpr(expected, "combinations(C0, C1)", {arrayVector, comboLengthVector}); } @@ -268,6 +273,7 @@ TEST_F(ArrayCombinationsTest, boolArrays) { {{false, true, true, true}}, {{false, false, true, true}}, {{true, false, true, true}}}}, - {{}}}); + std::make_optional< + std::vector>>>>({})}); testExpr(expected, "combinations(C0, C1)", {arrayVector, comboLengthVector}); } diff --git a/velox/functions/prestosql/tests/ArrayExceptTest.cpp b/velox/functions/prestosql/tests/ArrayExceptTest.cpp index 53010387d39f..9efd241a2ef5 100644 --- a/velox/functions/prestosql/tests/ArrayExceptTest.cpp +++ b/velox/functions/prestosql/tests/ArrayExceptTest.cpp @@ -183,7 +183,8 @@ TEST_F(ArrayExceptTest, boolArrays) { {true, false, true}}); auto expected = makeNullableArrayVector( - {{false}, {}, {}, {}, {false}, {true}, {}, {}}); + std::vector>>{ + {false}, {}, {}, {}, {false}, {true}, {}, {}}); testExpr(expected, "array_except(C0, C1)", {array1, array2}); diff --git a/velox/functions/prestosql/tests/ArrayIntersectTest.cpp b/velox/functions/prestosql/tests/ArrayIntersectTest.cpp index 1e749e98e66b..0fbb5553ef08 100644 --- a/velox/functions/prestosql/tests/ArrayIntersectTest.cpp +++ b/velox/functions/prestosql/tests/ArrayIntersectTest.cpp @@ -59,13 +59,14 @@ class ArrayIntersectTest : public FunctionBaseTest { template void testInt() { + using innerArrayType = std::vector>; auto array1 = makeNullableArrayVector({ {{1, -2, 3, std::nullopt, 4, 5, 6, std::nullopt}}, {{1, 2, -2, 1}}, {{3, 8, std::nullopt}}, std::nullopt, {{1, 1, -2, -2, -2, 4, 8}}, - {{}}, + std::make_optional({}), }); auto array2 = makeNullableArrayVector({ {1, -2, 4}, @@ -78,10 +79,10 @@ class ArrayIntersectTest : public FunctionBaseTest { auto expected = makeNullableArrayVector({ {{1, -2, 4}}, {{1, -2}}, - {{}}, + std::make_optional({}), std::nullopt, {{1, -2, 4}}, - {{}}, + std::make_optional({}), }); testExpr(expected, "array_intersect(C0, C1)", {array1, array2}); testExpr(expected, "array_intersect(C1, C0)", {array1, array2}); @@ -96,12 +97,12 @@ class ArrayIntersectTest : public FunctionBaseTest { {{1, std::nullopt}}, }); expected = makeNullableArrayVector({ - {{}}, + std::make_optional({}), {{2, -2}}, {std::vector>{std::nullopt}}, std::nullopt, {{1, 8}}, - {{}}, + std::make_optional({}), }); testExpr(expected, "array_intersect(C0, C1)", {array1, array2}); } @@ -201,7 +202,7 @@ class ArrayIntersectTest : public FunctionBaseTest { outerArrayType row1{{a1}, {a2}}; outerArrayType row2{{b1}, {b2}}; outerArrayType row3{{c1}, {c2}}; - outerArrayType row4{{a1}, {{}}}; + outerArrayType row4{{a1}, std::make_optional({})}; auto arrayVector = makeNullableNestedArrayVector({{row1}, {row2}, {row3}, {row4}}); auto expected = makeNullableArrayVector( @@ -292,7 +293,7 @@ TEST_F(ArrayIntersectTest, boolNestedArrays) { outerArrayType row1{{a1}, {a2}}; outerArrayType row2{{b1}, {b2}, {b3}}; outerArrayType row3{{c1}, {c2}}; - outerArrayType row4{{a1}, {{}}}; + outerArrayType row4{{a1}, std::make_optional({})}; auto arrayVector = makeNullableNestedArrayVector({{row1}, {row2}, {row3}, {row4}}); auto expected = makeNullableArrayVector( @@ -344,7 +345,7 @@ TEST_F(ArrayIntersectTest, strNestedArrays) { outerArrayType row1{{a1}, {a2}}; outerArrayType row2{{b1}, {b2}, {b3}}; outerArrayType row3{{c1}, {c2}}; - outerArrayType row4{{a1}, {{}}}; + outerArrayType row4{{a1}, std::make_optional({})}; auto arrayVector = makeNullableNestedArrayVector( {{row1}, {row2}, {row3}, {row4}}); auto expected = makeNullableArrayVector( @@ -416,7 +417,7 @@ TEST_F(ArrayIntersectTest, longStrNestedArrays) { outerArrayType row1{{a1}, {a2}}; outerArrayType row2{{b1}, {b2}, {b3}}; outerArrayType row3{{c1}, {c2}}; - outerArrayType row4{{a1}, {{}}}; + outerArrayType row4{{a1}, std::make_optional({})}; auto arrayVector = makeNullableNestedArrayVector( {{row1}, {row2}, {row3}, {row4}}); auto expected = makeNullableArrayVector( diff --git a/velox/functions/prestosql/tests/ArrayNGramsTest.cpp b/velox/functions/prestosql/tests/ArrayNGramsTest.cpp index 2b4fdaa615a4..a0901c756168 100644 --- a/velox/functions/prestosql/tests/ArrayNGramsTest.cpp +++ b/velox/functions/prestosql/tests/ArrayNGramsTest.cpp @@ -48,8 +48,10 @@ TEST_F(ArrayNGramsTest, integers) { testNgram({1, 2, 3, 4}, 5, {{{1, 2, 3, 4}}}); testNgram( {1, 2, 3, 4}, std::numeric_limits::max(), {{{1, 2, 3, 4}}}); - testNgram({}, 1, {{{}}}); - testNgram({}, 10, {{{}}}); + testNgram( + {}, 1, {std::make_optional>>({})}); + testNgram( + {}, 10, {std::make_optional>>({})}); } TEST_F(ArrayNGramsTest, invalidN) { diff --git a/velox/functions/prestosql/tests/ArrayPositionTest.cpp b/velox/functions/prestosql/tests/ArrayPositionTest.cpp index 793a004c9b92..2d85fa4f0305 100644 --- a/velox/functions/prestosql/tests/ArrayPositionTest.cpp +++ b/velox/functions/prestosql/tests/ArrayPositionTest.cpp @@ -536,7 +536,7 @@ TEST_F(ArrayPositionTest, array) { {{{d}, {e}}}, {{{d}, {a}, {b}}}, {{{c}, {e}}}, - {{{{}}}}, + {{{std::vector>{}}}}, {{{std::vector>{std::nullopt}}}}}); auto testPositionOfArray = @@ -844,7 +844,7 @@ TEST_F(ArrayPositionTest, arrayWithInstance) { {{{d}, {e}}}, {{{d}, {a}, {a}}}, {{{c}, {c}}}, - {{{{}}}}, + {{{std::vector>{}}}}, {{{std::vector>{std::nullopt}}}}}); auto testPositionOfArray = diff --git a/velox/functions/prestosql/tests/ArrayShuffleTest.cpp b/velox/functions/prestosql/tests/ArrayShuffleTest.cpp index d1fb7cd08303..f080978a3b8f 100644 --- a/velox/functions/prestosql/tests/ArrayShuffleTest.cpp +++ b/velox/functions/prestosql/tests/ArrayShuffleTest.cpp @@ -226,7 +226,7 @@ TEST_F(ArrayShuffleTest, nestedArrays) { innerArrayType c{6, 7, 8}; outerArrayType row1{{a}, {b}}; outerArrayType row2{std::nullopt, std::nullopt, {a}, {b}, {c}}; - outerArrayType row3{{{}}}; + outerArrayType row3{std::make_optional({})}; outerArrayType row4{{{std::nullopt}}}; auto input = makeNullableNestedArrayVector({{row1}, {row2}, {row3}, {row4}}); diff --git a/velox/functions/prestosql/tests/ArraysOverlapTest.cpp b/velox/functions/prestosql/tests/ArraysOverlapTest.cpp index 9ddd026e52c7..5b1adbbbdda9 100644 --- a/velox/functions/prestosql/tests/ArraysOverlapTest.cpp +++ b/velox/functions/prestosql/tests/ArraysOverlapTest.cpp @@ -261,7 +261,9 @@ TEST_F(ArraysOverlapTest, complexTypeRow) { {{{1, "red"}}, {{2, "blue"}}, {{3, "green"}}}, {{{1, "red"}}, {{2, "blue"}}, std::nullopt}, {{{1, "red"}}, std::nullopt, std::nullopt}, - {{{1, "red"}}, {{}}, {{}}}}; + {{{1, "red"}}, + std::tuple{}, + std::tuple{}}}; std::vector rightData = { {{{2, "blue"}}, {{1, "red"}}}, {{{1, "green"}}}, diff --git a/velox/functions/prestosql/tests/ComparisonsTest.cpp b/velox/functions/prestosql/tests/ComparisonsTest.cpp index 15eb7458e65d..62071bae95c1 100644 --- a/velox/functions/prestosql/tests/ComparisonsTest.cpp +++ b/velox/functions/prestosql/tests/ComparisonsTest.cpp @@ -500,7 +500,10 @@ TEST_F(ComparisonsTest, eqNeqArray) { test(std::nullopt, {{1}}, std::nullopt); test({{1}}, std::nullopt, std::nullopt); - test({{}}, {{}}, true); + test( + std::make_optional>>({}), + std::make_optional>>({}), + true); test({{1, 2, 3}}, {{1, 2, 3}}, true); test({{1, 2, 3}}, {{1, 2, 4}}, false); @@ -512,7 +515,10 @@ TEST_F(ComparisonsTest, eqNeqArray) { test({{1, std::nullopt}}, {{1, 2}}, std::nullopt); // Different size arrays. - test({{}}, {{std::nullopt, std::nullopt}}, false); + test( + std::make_optional>>({}), + {{std::nullopt, std::nullopt}}, + false); test({{1, 2}}, {{1, 2, std::nullopt}}, false); test( {{std::nullopt, std::nullopt}}, @@ -553,7 +559,10 @@ TEST_F(ComparisonsTest, eqNeqMap) { // Elements checked in sorted order. test({{{3, 4}, {1, 2}}}, {{{1, 2}, {3, 4}}}, true); - test({{}}, {{}}, true); + test( + std::make_optional({}), + std::make_optional({}), + true); test({{{1, 2}, {3, 5}}}, {{{1, 2}, {3, 4}}}, false); @@ -777,7 +786,7 @@ TEST_F(ComparisonsTest, eqNestedComplex) { // Compare Row(Array>, int, Map) using array_type = std::optional>>; array_type array1 = {{1, 2}}; - array_type array2 = {{}}; + array_type array2 = std::make_optional({}); array_type array3 = {{1, 100, 2}}; auto vector1 = diff --git a/velox/functions/prestosql/tests/InPredicateTest.cpp b/velox/functions/prestosql/tests/InPredicateTest.cpp index 8444d789df95..049e2038c49c 100644 --- a/velox/functions/prestosql/tests/InPredicateTest.cpp +++ b/velox/functions/prestosql/tests/InPredicateTest.cpp @@ -953,7 +953,7 @@ TEST_F(InPredicateTest, arrays) { auto data = makeRowVector({ makeNullableArrayVector({ {{1, 2, 3}}, - {{}}, + std::make_optional>>({}), {{1, 3}}, std::nullopt, {{2, 4, 5, 6}}, diff --git a/velox/functions/prestosql/tests/JsonCastTest.cpp b/velox/functions/prestosql/tests/JsonCastTest.cpp index b89a14f5a186..3dd12dd1e6a3 100644 --- a/velox/functions/prestosql/tests/JsonCastTest.cpp +++ b/velox/functions/prestosql/tests/JsonCastTest.cpp @@ -825,7 +825,8 @@ TEST_F(JsonCastTest, unsupportedTypes) { "Map keys cannot be null."); // Map keys cannot be complex type. - auto arrayKeyVector = makeNullableArrayVector({{1}, {2}}); + auto arrayKeyVector = makeNullableArrayVector( + std::vector>>{{1}, {2}}); auto arrayKeyMap = std::make_shared( pool(), MAP(ARRAY(BIGINT()), BIGINT()), @@ -837,7 +838,9 @@ TEST_F(JsonCastTest, unsupportedTypes) { valueVector); VELOX_ASSERT_THROW( evaluateCast( - MAP(ARRAY(BIGINT()), BIGINT()), JSON(), makeRowVector({arrayKeyMap})), + MAP(ARRAY(BIGINT()), BIGINT()), + JSON(), + makeRowVector(std::vector{arrayKeyMap})), "Cannot cast MAP,BIGINT> to JSON"); // Map keys of json type must not be null. @@ -1063,7 +1066,7 @@ TEST_F(JsonCastTest, toArray) { auto expected = makeNullableArrayVector( {{{"red"_sv, "blue"_sv}}, {{std::nullopt, std::nullopt, "purple"_sv}}, - {{}}, + std::make_optional>>({}), std::nullopt}); testCast(data, expected); @@ -1092,7 +1095,8 @@ TEST_F(JsonCastTest, toMap) { auto expected = makeNullableMapVector( {{{{"blue"_sv, "2.2"_sv}, {"red"_sv, "1"_sv}}}, {{{"purple"_sv, std::nullopt}, {"yellow"_sv, "4"_sv}}}, - {{}}, + std::make_optional< + std::vector>>>({}), std::nullopt}); testCast(data, expected); @@ -1107,7 +1111,8 @@ TEST_F(JsonCastTest, toMap) { expected = makeNullableMapVector( {{{{101, 1.1}, {102, 2.0}}}, {{{103, std::nullopt}, {104, 4.0}}}, - {{}}, + std::make_optional< + std::vector>>>({}), std::nullopt}); testCast(data, expected); @@ -1265,8 +1270,10 @@ TEST_F(JsonCastTest, toNested) { auto arrayExpected = makeNullableNestedArrayVector( {{{{{"1"_sv, "2"_sv}}, {{"3"_sv}}}}, {{{{std::nullopt, std::nullopt, "4"_sv}}}}, - {{{{}}}}, - {{}}}); + {{std::make_optional>>({})}}, + std::make_optional< + std::vector>>>>( + {})}); testCast(array, arrayExpected); diff --git a/velox/functions/prestosql/tests/JsonFunctionsTest.cpp b/velox/functions/prestosql/tests/JsonFunctionsTest.cpp index 85b92ca11035..8c14c091223f 100644 --- a/velox/functions/prestosql/tests/JsonFunctionsTest.cpp +++ b/velox/functions/prestosql/tests/JsonFunctionsTest.cpp @@ -1046,7 +1046,7 @@ TEST_F(JsonFunctionsTest, jsonStringToArrayCast) { auto expected = makeNullableArrayVector( {{{"red"_sv, "blue"_sv}}, {{std::nullopt, std::nullopt, "purple"_sv}}, - {{}}, + std::make_optional>>({}), std::nullopt}); checkInternalFn( diff --git a/velox/functions/prestosql/tests/MapFilterTest.cpp b/velox/functions/prestosql/tests/MapFilterTest.cpp index f9d1e33fbf9c..81e4ee67bee6 100644 --- a/velox/functions/prestosql/tests/MapFilterTest.cpp +++ b/velox/functions/prestosql/tests/MapFilterTest.cpp @@ -266,7 +266,11 @@ TEST_F(MapFilterTest, try) { auto result = evaluate("try(map_filter(c0, (k, v) -> (v / k > 0)))", data); auto expected = makeNullableMapVector( - {{{{1, 2}, {2, 3}}}, std::nullopt, {{{7, 8}}}, {{}}}); + {{{{1, 2}, {2, 3}}}, + std::nullopt, + {{{7, 8}}}, + std::make_optional< + std::vector>>>({})}); assertEqualVectors(expected, result); } diff --git a/velox/functions/prestosql/tests/MapTopNTest.cpp b/velox/functions/prestosql/tests/MapTopNTest.cpp index 4ec0476798ef..a13b89c3e8e6 100644 --- a/velox/functions/prestosql/tests/MapTopNTest.cpp +++ b/velox/functions/prestosql/tests/MapTopNTest.cpp @@ -72,14 +72,20 @@ TEST_F(MapTopNTest, nestedNullFailure) { /*offsets=*/{0}, /*keyVector=*/makeFlatVector({1, 2, 3}), /*valueVector=*/ - makeNullableArrayVector({{std::nullopt}, {2}, {5}})); + makeNullableArrayVector( + std::vector>>{ + {std::nullopt}, {2}, {5}})); // Nested nulls present inhibit the orderbility of values. Expect an error. VELOX_ASSERT_THROW( - evaluate("map_top_n(c0, 1)", makeRowVector({data})), // n < map size + evaluate( + "map_top_n(c0, 1)", + makeRowVector(std::vector{data})), // n < map size "Ordering nulls is not supported"); VELOX_ASSERT_THROW( - evaluate("map_top_n(c0, 10)", makeRowVector({data})), // n > map size + evaluate( + "map_top_n(c0, 10)", + makeRowVector(std::vector{data})), // n > map size "Ordering nulls is not supported"); } diff --git a/velox/functions/prestosql/tests/ZipTest.cpp b/velox/functions/prestosql/tests/ZipTest.cpp index a74f95120538..8c07f6aababc 100644 --- a/velox/functions/prestosql/tests/ZipTest.cpp +++ b/velox/functions/prestosql/tests/ZipTest.cpp @@ -91,7 +91,7 @@ TEST_F(ZipTest, combineInt) { TEST_F(ZipTest, nullEmptyArray) { auto firstVector = makeNullableArrayVector({ {{1, 1, 1, 1}}, - {{}}, + std::make_optional>>({}), std::nullopt, }); diff --git a/velox/functions/sparksql/tests/ArraySortTestData.h b/velox/functions/sparksql/tests/ArraySortTestData.h index b7e44c0f2e0e..b786bb5ac57e 100644 --- a/velox/functions/sparksql/tests/ArraySortTestData.h +++ b/velox/functions/sparksql/tests/ArraySortTestData.h @@ -239,7 +239,7 @@ arrayInput() { using A = std::vector>; return std::vector>>>{ // Empty. - {{}}, + std::make_optional>>({}), // All nulls. {{std::nullopt, std::nullopt}}, // Same prefix. @@ -256,7 +256,7 @@ inline std::vector>; return std::vector>>>{ - {{}}, + std::make_optional>>({}), {{std::nullopt, std::nullopt}}, {{A({1, 3}), A({1, 3, 5}), A({2, 1})}}, {{std::nullopt, A({1, 3}), A({2, 1})}}, @@ -269,7 +269,7 @@ inline std::vector>; return std::vector>>>{ - {{}}, + std::make_optional>>({}), {{std::nullopt, std::nullopt}}, {{A({1, 3}), A({1, 3, 5}), A({2, 1})}}, {{A({1, 3}), A({2, 1}), std::nullopt}}, diff --git a/velox/functions/sparksql/tests/HashTest.cpp b/velox/functions/sparksql/tests/HashTest.cpp index e9e9558275cc..f6b12b5bdb5c 100644 --- a/velox/functions/sparksql/tests/HashTest.cpp +++ b/velox/functions/sparksql/tests/HashTest.cpp @@ -231,7 +231,9 @@ TEST_F(HashTest, map) { hash(mapOfArrays)); auto mapWithNullArrays = createMapOfArraysVector( - {{{1, std::nullopt}}, {{2, {{4, 5, std::nullopt}}}}, {{3, {{}}}}}); + {{{1, std::nullopt}}, + {{2, {{4, 5, std::nullopt}}}}, + {{3, std::make_optional>>({})}}}); assertEqualVectors( makeFlatVector({-1712319331, 2060637564, 519220707}), hash(mapWithNullArrays)); diff --git a/velox/functions/sparksql/tests/XxHash64Test.cpp b/velox/functions/sparksql/tests/XxHash64Test.cpp index 8926194e898f..19e69c76272b 100644 --- a/velox/functions/sparksql/tests/XxHash64Test.cpp +++ b/velox/functions/sparksql/tests/XxHash64Test.cpp @@ -244,7 +244,9 @@ TEST_F(XxHash64Test, map) { xxhash64(mapOfArrays)); auto mapWithNullArrays = createMapOfArraysVector( - {{{1, std::nullopt}}, {{2, {{4, 5, std::nullopt}}}}, {{3, {{}}}}}); + {{{1, std::nullopt}}, + {{2, {{4, 5, std::nullopt}}}}, + {{3, std::make_optional>>({})}}}); assertEqualVectors( makeFlatVector( {-7001672635703045582, 7217681953522744649, 3188756510806108107}), diff --git a/velox/row/tests/CompactRowTest.cpp b/velox/row/tests/CompactRowTest.cpp index 8bfa4fc3989d..061e1ae90d77 100644 --- a/velox/row/tests/CompactRowTest.cpp +++ b/velox/row/tests/CompactRowTest.cpp @@ -190,7 +190,7 @@ TEST_F(CompactRowTest, rowSizeArrayOfBigint) { makeNullableArrayVector({ {{1, 2, std::nullopt, 3}}, {{4, 5}}, - {{}}, + std::make_optional>>({}), std::nullopt, {{6}}, }), @@ -249,7 +249,7 @@ TEST_F(CompactRowTest, rowSizeArrayOfStrings) { data = makeRowVector({ makeNullableArrayVector({ {{"a", "Abc", std::nullopt}}, - {{}}, + std::make_optional>>({}), std::nullopt, {{"a", std::nullopt, "Longer string", "abc"}}, }), @@ -404,7 +404,7 @@ TEST_F(CompactRowTest, arrayOfBigint) { {{std::nullopt, 6}}, {{std::nullopt}}, std::nullopt, - {{}}, + std::make_optional>>({}), }), }); @@ -430,7 +430,7 @@ TEST_F(CompactRowTest, arrayOfTimestamp) { {{std::nullopt, ts(6)}}, {{std::nullopt}}, std::nullopt, - {{}}, + std::make_optional>>({}), }), }); @@ -439,7 +439,7 @@ TEST_F(CompactRowTest, arrayOfTimestamp) { TEST_F(CompactRowTest, arrayOfString) { auto data = makeRowVector({ - makeArrayVector({ + makeArrayVector(std::vector>{ {"a", "abc", "Longer test string"}, {"b", "Abc 12345 ...test", "foo"}, {}, @@ -457,7 +457,7 @@ TEST_F(CompactRowTest, arrayOfString) { "Abc 12345 ...test", std::nullopt, "foo"}}, - {{}}, + std::make_optional>>({}), {{std::nullopt}}, std::nullopt, }), diff --git a/velox/vector/fuzzer/VectorFuzzer.h b/velox/vector/fuzzer/VectorFuzzer.h index af104f5d948b..8af5f73dfeb2 100644 --- a/velox/vector/fuzzer/VectorFuzzer.h +++ b/velox/vector/fuzzer/VectorFuzzer.h @@ -145,13 +145,24 @@ class VectorFuzzer { fuzzer::DataSpec dataSpec{false, false}; }; + // Suppress spurious warnings in GCC 12.4 and later +#if defined(__GNUC__) && \ + ((__GNUC__ > 12) || (__GNUC__ == 12 && __GNUC_MINOR__ >= 4)) + VELOX_SUPPRESS_STRINGOP_OVERFLOW_WARNING +#endif VectorFuzzer( const VectorFuzzer::Options& options, memory::MemoryPool* pool, size_t seed = 123456) - : opts_(options), pool_(pool), rng_(seed) {} - - void setOptions(const VectorFuzzer::Options& options) { + : opts_(options), + pool_(pool), + rng_(seed){} +#if defined(__GNUC__) && \ + ((__GNUC__ > 12) || (__GNUC__ == 12 && __GNUC_MINOR__ >= 4)) + VELOX_UNSUPPRESS_STRINGOP_OVERFLOW_WARNING +#endif + + void setOptions(const VectorFuzzer::Options& options) { opts_ = options; } diff --git a/velox/vector/tests/VectorCompareTest.cpp b/velox/vector/tests/VectorCompareTest.cpp index 1dc7fb82fa67..771a87fcafc0 100644 --- a/velox/vector/tests/VectorCompareTest.cpp +++ b/velox/vector/tests/VectorCompareTest.cpp @@ -612,7 +612,8 @@ TEST_F(VectorCompareTest, customComparisonDictionary) { TEST_F(VectorCompareTest, customComparisonArray) { auto arrayVector = makeNullableArrayVector( - {{0}, {1}, {std::nullopt}, {256}, {257}}, + std::vector>>{ + {0}, {1}, {std::nullopt}, {256}, {257}}, ARRAY(test::BIGINT_TYPE_WITH_CUSTOM_COMPARISON())); testCustomComparison(std::vector(5, arrayVector), {0, 1, 2, 3, 4}); diff --git a/velox/vector/tests/VectorMakerTest.cpp b/velox/vector/tests/VectorMakerTest.cpp index d464f15ab364..35163d1b8cbd 100644 --- a/velox/vector/tests/VectorMakerTest.cpp +++ b/velox/vector/tests/VectorMakerTest.cpp @@ -479,13 +479,13 @@ TEST_F(VectorMakerTest, nestedArrayVectorFromJson) { {{2, 3, 4}}, {{std::nullopt, 7}}, {{1, 3, 7, 9}}, - {{}}, + std::make_optional>>({}), {{std::nullopt}}, {{1, 2, std::nullopt}}, - {{}}, + std::make_optional>>({}), std::nullopt, {{1, 2, 3}}, - {{}}, + std::make_optional>>({}), {{4, 5}}, }); diff --git a/velox/vector/tests/VectorTest.cpp b/velox/vector/tests/VectorTest.cpp index 8acb55c7a03f..c05ddefe9ada 100644 --- a/velox/vector/tests/VectorTest.cpp +++ b/velox/vector/tests/VectorTest.cpp @@ -3175,7 +3175,7 @@ TEST_F(VectorTest, containsNullAtArrays) { auto data = makeNullableArrayVector({ {{1, 2}}, {{1, 2, std::nullopt, 3}}, - {{}}, + std::make_optional>>({}), std::nullopt, {{1, 2, 3, 4}}, }); @@ -3192,7 +3192,8 @@ TEST_F(VectorTest, containsNullAtMaps) { {{{1, 10}, {2, 20}}}, {{{3, 30}}}, {{{1, 10}, {2, 20}, {3, std::nullopt}, {4, 40}}}, - {{}}, + std::make_optional< + std::vector>>>({}), std::nullopt, {{{1, 10}, {2, 20}, {3, 30}, {4, 40}}}, }); @@ -3228,7 +3229,7 @@ TEST_F(VectorTest, containsNullAtStructs) { makeNullableArrayVector({ {{1, 2}}, {{1, 2, std::nullopt, 3}}, - {{}}, + std::make_optional>>({}), {{1, 2, 3}}, std::nullopt, {{1, 2, 3, 4, 5}}, @@ -3706,7 +3707,8 @@ TEST_F(VectorTest, getLargeStringBuffer) { TEST_F(VectorTest, mapUpdate) { auto base = makeNullableMapVector({ {{{1, 1}, {2, 1}}}, - {{}}, + std::make_optional< + std::vector>>>({}), {{{3, 1}}}, std::nullopt, {{{4, 1}}}, @@ -3714,7 +3716,8 @@ TEST_F(VectorTest, mapUpdate) { auto update = makeNullableMapVector({ {{{2, 2}, {3, 2}}}, {{{4, 2}}}, - {{}}, + std::make_optional< + std::vector>>>({}), {{{5, 2}}}, std::nullopt, }); @@ -3781,7 +3784,8 @@ TEST_F(VectorTest, mapUpdateNullMapValue) { TEST_F(VectorTest, mapUpdateMultipleUpdates) { auto base = makeNullableMapVector({ {{{1, 1}, {2, 1}}}, - {{}}, + std::make_optional< + std::vector>>>({}), {{{3, 1}}}, std::nullopt, {{{4, 1}}}, @@ -3790,16 +3794,20 @@ TEST_F(VectorTest, mapUpdateMultipleUpdates) { makeNullableMapVector({ {{{2, 2}, {3, 2}}}, {{{4, 2}}}, - {{}}, + std::make_optional< + std::vector>>>({}), {{{5, 2}}}, std::nullopt, }), makeNullableMapVector({ {{{3, 3}, {4, 3}}}, std::nullopt, - {{}}, - {{}}, - {{}}, + std::make_optional< + std::vector>>>({}), + std::make_optional< + std::vector>>>({}), + std::make_optional< + std::vector>>>({}), }), }; auto expected = makeNullableMapVector({