Skip to content

Commit

Permalink
Fix GCC13 build failures.
Browse files Browse the repository at this point in the history
  • Loading branch information
xin-zhang2 committed Mar 4, 2025
1 parent 55257c2 commit cbc2221
Show file tree
Hide file tree
Showing 37 changed files with 177 additions and 109 deletions.
7 changes: 1 addition & 6 deletions velox/connectors/tpch/TpchConnector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,7 @@ TpchDataSource::TpchDataSource(
toTableName(tpchTable_));

auto handle = std::dynamic_pointer_cast<TpchColumnHandle>(it->second);
VELOX_CHECK_NOT_NULL(
handle,
"ColumnHandle must be an instance of TpchColumnHandle "
"for '{}' on table '{}'",
handle->name(),
toTableName(tpchTable_));
VELOX_CHECK_NOT_NULL(handle, "ColumnHandle can't be null.");

auto idx = tpchTableSchema->getChildIdxIfExists(handle->name());
VELOX_CHECK(
Expand Down
2 changes: 1 addition & 1 deletion velox/dwio/dwrf/common/Compression.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ inline std::unique_ptr<dwio::common::BufferedOutputStream> createCompressor(

inline CompressionOptions getDwrfOrcDecompressionOptions(
common::CompressionKind kind) {
CompressionOptions options;
CompressionOptions options{};
if (kind == common::CompressionKind_ZLIB ||
kind == common::CompressionKind_GZIP) {
options.format.zlib.windowBits = Compressor::DWRF_ORC_ZLIB_WINDOW_BITS;
Expand Down
4 changes: 3 additions & 1 deletion velox/exec/tests/ContainerRowSerdeTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,9 @@ TEST_F(ContainerRowSerdeTest, nested) {
testRoundTrip(data);

auto nestedArray = makeNullableNestedArrayVector<std::string>(
{{{{{"1", "2"}}, {{"3", "4"}}}}, {{}}, {{std::nullopt, {}}}});
{{{{{"1", "2"}}, {{"3", "4"}}}},
std::make_optional<std::vector<std::optional<std::vector<std::optional<std::string>>>>>({}),
{{std::nullopt, {}}}});

testRoundTrip(nestedArray);

Expand Down
2 changes: 1 addition & 1 deletion velox/exec/tests/UnnestTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ TEST_P(UnnestTest, arrayWithOrdinality) {
{{{1, 2, std::nullopt, 4}},
std::nullopt,
{{5, 6}},
{{}},
std::make_optional<std::vector<std::optional<int32_t>>>({}),
{{{{std::nullopt}}}},
{{7, 8, 9}}});
auto vector = makeRowVector(
Expand Down
2 changes: 1 addition & 1 deletion velox/expression/tests/ArrayWriterTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,7 @@ TEST_F(ArrayWriterTest, copyFromNestedArray) {
vectorWriter.finish();

using array_type = std::optional<std::vector<std::optional<int64_t>>>;
array_type array1 = {{}};
array_type array1 = std::make_optional<array_type::value_type>({});
array_type array2 = {{1, 2, 3, 4}};
array_type array3 = {{1}};

Expand Down
5 changes: 1 addition & 4 deletions velox/expression/tests/ExpressionRunner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -230,10 +230,7 @@ void ExpressionRunner::run(
auto inputVector =
std::dynamic_pointer_cast<RowVector>(restoreVectorFromFile(
inputPathsList[i].c_str(), deserializerPool.get()));
VELOX_CHECK_NOT_NULL(
inputVector,
"Input vector is not a RowVector: {}",
inputVector->toString());
VELOX_CHECK_NOT_NULL(inputVector, "Input vector can't be null.");
VELOX_CHECK_GT(inputVector->size(), 0, "Input vector must not be empty.");
if (inputSelectivityPaths.size() > i) {
inputTestCases.push_back(
Expand Down
4 changes: 2 additions & 2 deletions velox/expression/tests/GenericViewTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class GenericViewTest : public functions::test::FunctionBaseTest {
std::vector<std::optional<std::vector<std::optional<int64_t>>>>;

array_data_t arrayData1 = {
{{}},
std::make_optional<std::vector<std::optional<int64_t>>>({}),
{{{{std::nullopt}}}},
{{std::nullopt, 1}},
{{std::nullopt, std::nullopt, std::nullopt}},
Expand All @@ -56,7 +56,7 @@ class GenericViewTest : public functions::test::FunctionBaseTest {
};

array_data_t arrayData2 = {
{{}},
std::make_optional<std::vector<std::optional<int64_t>>>({}),
{{{{std::nullopt}}}},
{{std::nullopt, 1}},
{{std::nullopt, std::nullopt, std::nullopt}},
Expand Down
22 changes: 17 additions & 5 deletions velox/functions/lib/tests/Re2FunctionsTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1223,19 +1223,31 @@ TEST_F(Re2FunctionsTest, regexExtractAllNoMatch) {
const std::vector<std::optional<int32_t>> noGroupId = {};
const std::vector<std::optional<int32_t>> groupIds0 = {0};

testRe2ExtractAll({""}, {"[0-9]+"}, noGroupId, {{{}}});
testRe2ExtractAll({"(╯°□°)╯︵ ┻━┻"}, {"[0-9]+"}, noGroupId, {{{}}});
testRe2ExtractAll({"abcde"}, {"[0-9]+"}, groupIds0, {{{}}});
testRe2ExtractAll(
{""},
{"[0-9]+"},
noGroupId,
{std::make_optional<std::vector<std::string>>({})});
testRe2ExtractAll(
{"(╯°□°)╯︵ ┻━┻"},
{"[0-9]+"},
noGroupId,
{std::make_optional<std::vector<std::string>>({})});
testRe2ExtractAll(
{"abcde"},
{"[0-9]+"},
groupIds0,
{std::make_optional<std::vector<std::string>>({})});
testRe2ExtractAll(
{"rYBKVn6DnfSI2an4is4jbvf4btGpV"},
{"81jnp58n31BtMdlUsP1hiF4QWSYv411"},
noGroupId,
{{{}}});
{std::make_optional<std::vector<std::string>>({})});
testRe2ExtractAll(
{"rYBKVn6DnfSI2an4is4jbvf4btGpV"},
{"81jnp58n31BtMdlUsP1hiF4QWSYv411"},
groupIds0,
{{{}}});
{std::make_optional<std::vector<std::string>>({})});

// Test empty pattern.
testRe2ExtractAll<int32_t>(
Expand Down
2 changes: 1 addition & 1 deletion velox/functions/lib/tests/RepeatTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ TEST_F(RepeatTest, repeat) {
{{0.0}},
{{-2.0, -2.0}},
{{3.333333, 3.333333, 3.333333}},
{{}},
std::make_optional<std::vector<std::optional<float>>>({}),
{{std::nullopt, std::nullopt, std::nullopt, std::nullopt}},
std::nullopt,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -281,8 +281,10 @@ TEST_F(ChecksumAggregateTest, arrays) {
arrayVector = makeNullableArrayVector<int64_t>({{{1, 2}}, std::nullopt});
assertChecksum(arrayVector, "Nlzernkj88A=");

arrayVector =
makeNullableArrayVector<int64_t>({{{1, 2}}, std::nullopt, {{}}});
arrayVector = makeNullableArrayVector<int64_t>(
{{{1, 2}},
std::nullopt,
std::make_optional<std::vector<std::optional<int64_t>>>({})});
assertChecksum(arrayVector, "Nlzernkj88A=");

// Array of arrays.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ TEST_F(ClassificationAggregationTest, basic) {
});

expected = makeRowVector({makeNullableArrayVector<double>(
std::vector<std::optional<std::vector<std::optional<double>>>>{{{}}})});
{{std::make_optional<std::vector<std::optional<double>>>({})}})});
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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,8 @@ TEST_F(MapUnionTest, nulls) {
makeNullableMapVector<int64_t, int64_t>({
{{{1, 10}, {2, 20}, {3, 33}, {4, 44}, {5, 55}}},
std::nullopt,
{{}},
std::make_optional<
std::vector<std::pair<int64_t, std::optional<int64_t>>>>({}),
}),
});

Expand Down
14 changes: 10 additions & 4 deletions velox/functions/prestosql/aggregates/tests/MapUnionSumTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ class MapUnionSumTest : public AggregationTestBase {};
TEST_F(MapUnionSumTest, global) {
auto data = makeRowVector({
makeNullableMapVector<int64_t, int64_t>({
{{}}, // empty map
std::make_optional<
std::vector<std::pair<int64_t, std::optional<int64_t>>>>(
{}), // empty map
std::nullopt, // null map
{{{1, 10}, {2, 20}}},
{{{1, 11}, {3, 30}, {4, 40}}},
Expand Down Expand Up @@ -62,7 +64,9 @@ TEST_F(MapUnionSumTest, globalVarcharKey) {

auto data = makeRowVector({
makeNullableMapVector<StringView, int64_t>({
{{}}, // empty map
std::make_optional<
std::vector<std::pair<StringView, std::optional<int64_t>>>>(
{}), // empty map
std::nullopt, // null map
{{{keys[0], 10}, {keys[1], 20}}},
{{{keys[0], 11}, {keys[2], 30}, {keys[3], 40}}},
Expand Down Expand Up @@ -119,9 +123,11 @@ TEST_F(MapUnionSumTest, nullAndEmptyMaps) {
auto emptyAndNullMaps = makeRowVector({
makeNullableMapVector<int64_t, int64_t>({
std::nullopt,
{{}},
std::make_optional<
std::vector<std::pair<int64_t, std::optional<int64_t>>>>({}),
std::nullopt,
{{}},
std::make_optional<
std::vector<std::pair<int64_t, std::optional<int64_t>>>>({}),
}),
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ TEST_F(PrestoHasherTest, arrays) {
{{10, 11}},
{{12, std::nullopt}},
std::nullopt,
{{}}});
std::make_optional<std::vector<std::optional<int64_t>>>({})});

assertHash(
baseArrayVector,
Expand All @@ -320,7 +320,7 @@ TEST_F(PrestoHasherTest, arrays) {
{{std::nullopt}},
{{1, 2, 3}},
{{1024, std::nullopt, -99, -999}},
{{}},
std::make_optional<std::vector<std::optional<int64_t>>>({}),
{{std::nullopt, -1}},
});

Expand Down
5 changes: 3 additions & 2 deletions velox/functions/prestosql/aggregates/tests/SetAggTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,7 @@ TEST_F(SetAggTest, arrayNestedNulls) {
});

auto expected = makeRowVector({makeNullableNestedArrayVector<int32_t>(
{{{{{}},
{{{std::make_optional<std::vector<std::optional<int32_t>>>({}),
{{1, 2}},
{{2, 3}},
{{3, std::nullopt}},
Expand All @@ -544,7 +544,8 @@ TEST_F(SetAggTest, arrayNestedNulls) {
expected = makeRowVector(
{makeFlatVector<int32_t>({1, 2, 3, 4}),
makeNullableNestedArrayVector<int32_t>(
{{{{{{}}, {{1, 2}}}},
{{{{std::make_optional<std::vector<std::optional<int32_t>>>({}),
{{1, 2}}}},
{{{{6, 7}}, {{std::nullopt, 7}}}},
{{{{2, 3}}, {{3, std::nullopt}}}},
{{{{8, 9}}, {{std::nullopt, std::nullopt}}}}}})});
Expand Down
18 changes: 11 additions & 7 deletions velox/functions/prestosql/tests/ArrayCombinationsTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ class ArrayCombinationsTest : public FunctionBaseTest {
auto arrayVector = makeArrayVector<T>(
{{0, 1, 2, 3}, {0, 1, 2, 3}, {0, 1, 2, 3}, {0, 1, 2, 3}});
auto comboLengthVector = makeFlatVector<int32_t>({0, 3, 4, 5});
auto expected = makeNullableNestedArrayVector<T>(
{{{{std::vector<std::optional<T>>()}}},
auto expected = makeNullableNestedArrayVector<T>({
{{{std::vector<std::optional<T>>()}}},
{{{{0, 1, 2}}, {{0, 1, 3}}, {{0, 2, 3}}, {{1, 2, 3}}}},
{{{{0, 1, 2, 3}}}},
{{}}});
std::make_optional<std::vector<std::optional<std::vector<std::optional<T>>>>>({})});
testExpr(
expected, "combinations(C0, C1)", {arrayVector, comboLengthVector});
}
Expand Down Expand Up @@ -175,7 +175,8 @@ TEST_F(ArrayCombinationsTest, inlineVarcharArrays) {
{{"bb", "aa", "aa", "ddd"}},
{{"bb", "cc", "aa", "ddd"}},
{{"aa", "cc", "aa", "ddd"}}}},
{{}}});
std::make_optional<
std::vector<std::optional<std::vector<std::optional<S>>>>>({})});
testExpr(expected, "combinations(C0, C1)", {arrayVector, comboLengthVector});
}

Expand Down Expand Up @@ -222,7 +223,8 @@ TEST_F(ArrayCombinationsTest, varcharArrays) {
"yellow rose flowers",
"red shiny car ahead",
"purple is an elegant color"}}}},
{{}}});
std::make_optional<
std::vector<std::optional<std::vector<std::optional<S>>>>>({})});
testExpr(expected, "combinations(C0, C1)", {arrayVector, comboLengthVector});
}

Expand All @@ -245,7 +247,8 @@ TEST_F(ArrayCombinationsTest, boolNullableArrays) {
{{false, true, true, true}},
{{false, false, true, true}},
{{true, false, true, true}}}},
{{}}});
std::make_optional<
std::vector<std::optional<std::vector<std::optional<bool>>>>>({})});
testExpr(expected, "combinations(C0, C1)", {arrayVector, comboLengthVector});
}

Expand All @@ -268,6 +271,7 @@ TEST_F(ArrayCombinationsTest, boolArrays) {
{{false, true, true, true}},
{{false, false, true, true}},
{{true, false, true, true}}}},
{{}}});
std::make_optional<
std::vector<std::optional<std::vector<std::optional<bool>>>>>({})});
testExpr(expected, "combinations(C0, C1)", {arrayVector, comboLengthVector});
}
3 changes: 2 additions & 1 deletion velox/functions/prestosql/tests/ArrayExceptTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,8 @@ TEST_F(ArrayExceptTest, boolArrays) {
{true, false, true}});

auto expected = makeNullableArrayVector<bool>(
{{false}, {}, {}, {}, {false}, {true}, {}, {}});
std::vector<std::vector<std::optional<bool>>>{
{false}, {}, {}, {}, {false}, {true}, {}, {}});

testExpr(expected, "array_except(C0, C1)", {array1, array2});

Expand Down
19 changes: 10 additions & 9 deletions velox/functions/prestosql/tests/ArrayIntersectTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,14 @@ class ArrayIntersectTest : public FunctionBaseTest {

template <typename T>
void testInt() {
using innerArrayType = std::vector<std::optional<T>>;
auto array1 = makeNullableArrayVector<T>({
{{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<innerArrayType>({}),
});
auto array2 = makeNullableArrayVector<T>({
{1, -2, 4},
Expand All @@ -78,10 +79,10 @@ class ArrayIntersectTest : public FunctionBaseTest {
auto expected = makeNullableArrayVector<T>({
{{1, -2, 4}},
{{1, -2}},
{{}},
std::make_optional<innerArrayType>({}),
std::nullopt,
{{1, -2, 4}},
{{}},
std::make_optional<innerArrayType>({}),
});
testExpr(expected, "array_intersect(C0, C1)", {array1, array2});
testExpr(expected, "array_intersect(C1, C0)", {array1, array2});
Expand All @@ -96,12 +97,12 @@ class ArrayIntersectTest : public FunctionBaseTest {
{{1, std::nullopt}},
});
expected = makeNullableArrayVector<T>({
{{}},
std::make_optional<innerArrayType>({}),
{{2, -2}},
{std::vector<std::optional<T>>{std::nullopt}},
std::nullopt,
{{1, 8}},
{{}},
std::make_optional<innerArrayType>({}),
});
testExpr(expected, "array_intersect(C0, C1)", {array1, array2});
}
Expand Down Expand Up @@ -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<innerArrayType>({})};
auto arrayVector =
makeNullableNestedArrayVector<T>({{row1}, {row2}, {row3}, {row4}});
auto expected = makeNullableArrayVector<T>(
Expand Down Expand Up @@ -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<innerArrayType>({})};
auto arrayVector =
makeNullableNestedArrayVector<bool>({{row1}, {row2}, {row3}, {row4}});
auto expected = makeNullableArrayVector<bool>(
Expand Down Expand Up @@ -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<innerArrayType>({})};
auto arrayVector = makeNullableNestedArrayVector<std::string>(
{{row1}, {row2}, {row3}, {row4}});
auto expected = makeNullableArrayVector<std::string>(
Expand Down Expand Up @@ -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<innerArrayType>({})};
auto arrayVector = makeNullableNestedArrayVector<std::string>(
{{row1}, {row2}, {row3}, {row4}});
auto expected = makeNullableArrayVector<std::string>(
Expand Down
6 changes: 4 additions & 2 deletions velox/functions/prestosql/tests/ArrayNGramsTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,10 @@ TEST_F(ArrayNGramsTest, integers) {
testNgram<int64_t>({1, 2, 3, 4}, 5, {{{1, 2, 3, 4}}});
testNgram<int64_t>(
{1, 2, 3, 4}, std::numeric_limits<int32_t>::max(), {{{1, 2, 3, 4}}});
testNgram<int64_t>({}, 1, {{{}}});
testNgram<int64_t>({}, 10, {{{}}});
testNgram<int64_t>(
{}, 1, {std::make_optional<std::vector<std::optional<int64_t>>>({})});
testNgram<int64_t>(
{}, 10, {std::make_optional<std::vector<std::optional<int64_t>>>({})});
}

TEST_F(ArrayNGramsTest, invalidN) {
Expand Down
Loading

0 comments on commit cbc2221

Please sign in to comment.