diff --git a/velox/docs/functions/spark/binary.rst b/velox/docs/functions/spark/binary.rst index 6eeeaf7f736a..18fd5c369647 100644 --- a/velox/docs/functions/spark/binary.rst +++ b/velox/docs/functions/spark/binary.rst @@ -6,16 +6,11 @@ Binary Functions Computes the hash of one or more input values using seed value of 42. For multiple arguments, their types can be different. - Supported types are: BOOLEAN, TINYINT, SMALLINT, INTEGER, BIGINT, VARCHAR, - VARBINARY, REAL, DOUBLE, HUGEINT, TIMESTAMP, ARRAY, MAP and ROW. - .. spark:function:: hash_with_seed(seed, x, ...) -> integer Computes the hash of one or more input values using specified seed. For multiple arguments, their types can be different. - Supported types are: BOOLEAN, TINYINT, SMALLINT, INTEGER, BIGINT, VARCHAR, - VARBINARY, REAL, DOUBLE, HUGEINT, TIMESTAMP, ARRAY, MAP and ROW. .. spark:function:: xxhash64(x, ...) -> bigint diff --git a/velox/functions/sparksql/tests/HashTest.cpp b/velox/functions/sparksql/tests/HashTest.cpp index 1c6569dc15bf..58a9d4565c0d 100644 --- a/velox/functions/sparksql/tests/HashTest.cpp +++ b/velox/functions/sparksql/tests/HashTest.cpp @@ -134,7 +134,7 @@ TEST_F(HashTest, Float) { EXPECT_EQ(hash(-limits::infinity()), 427440766); } -TEST_F(HashTest, Array) { +TEST_F(HashTest, array) { assertEqualVectors( makeFlatVector({2101165938, 42, 1045631400}), hash(makeArrayVector({{1, 2, 3, 4, 5}, {}, {1, 2, 3}}))); @@ -146,19 +146,12 @@ TEST_F(HashTest, Array) { // Nested array. { - using innerArrayType = std::vector>; - using outerArrayType = - std::vector>>>; - - innerArrayType a{1, std::nullopt, 2, 3}; - innerArrayType b{4, 5}; - innerArrayType c{6, 7, 8}; - outerArrayType row1{{a}, {b}}; - outerArrayType row2{{a}, {c}}; - outerArrayType row3{{{}}}; - outerArrayType row4{{{std::nullopt}}}; - auto arrayVector = makeNullableNestedArrayVector( - {{row1}, {row2}, {row3}, {row4}, std::nullopt}); + auto arrayVector = makeNestedArrayVectorFromJson( + {"[[1, null, 2, 3], [4, 5]]", + "[[1, null, 2, 3], [6, 7, 8]]", + "[[]]", + "[[null]]", + "[null]"}); assertEqualVectors( makeFlatVector({2101165938, -992561130, 42, 42, 42}), hash(arrayVector)); @@ -192,7 +185,7 @@ TEST_F(HashTest, Array) { } } -TEST_F(HashTest, Map) { +TEST_F(HashTest, map) { auto mapVector = makeMapVector( {{{1, 17.0}, {2, 36.0}, {3, 8.0}, {4, 28.0}, {5, 24.0}, {6, 32.0}}}); assertEqualVectors( @@ -212,7 +205,7 @@ TEST_F(HashTest, Map) { hash(mapWithNullArrays)); } -TEST_F(HashTest, Row) { +TEST_F(HashTest, row) { auto row = makeRowVector({ makeFlatVector({1, 3}), makeFlatVector({2, 4}), diff --git a/velox/functions/sparksql/tests/XxHash64Test.cpp b/velox/functions/sparksql/tests/XxHash64Test.cpp index d1508f3681fb..6e086ffd918f 100644 --- a/velox/functions/sparksql/tests/XxHash64Test.cpp +++ b/velox/functions/sparksql/tests/XxHash64Test.cpp @@ -156,19 +156,12 @@ TEST_F(XxHash64Test, array) { // Nested array. { - using innerArrayType = std::vector>; - using outerArrayType = - std::vector>>>; - - innerArrayType a{1, std::nullopt, 2, 3}; - innerArrayType b{4, 5}; - innerArrayType c{6, 7, 8}; - outerArrayType row1{{a}, {b}}; - outerArrayType row2{{a}, {c}}; - outerArrayType row3{{{}}}; - outerArrayType row4{{{std::nullopt}}}; - auto arrayVector = makeNullableNestedArrayVector( - {{row1}, {row2}, {row3}, {row4}, std::nullopt}); + auto arrayVector = makeNestedArrayVectorFromJson( + {"[[1, null, 2, 3], [4, 5]]", + "[[1, null, 2, 3], [6, 7, 8]]", + "[[]]", + "[[null]]", + "[null]"}); assertEqualVectors( makeFlatVector( {-6041664978295882827, -1052942565807509112, 42, 42, 42}),