Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
yma11 committed May 17, 2024
1 parent a0771c9 commit 5f395a6
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 8 deletions.
2 changes: 2 additions & 0 deletions velox/docs/functions/spark/map.rst
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ Map Functions

SELECT map_from_entries(array(struct(1, 'a'), struct(2, 'null'))); -- {1 -> 'a', 2 -> 'null'}
SELECT map_from_entries(array(struct(1, 'a'), null)); -- {null}
SELECT map_from_entries(array(struct(null, 'a'))); -- "map key cannot be null"
SELECT map_from_entries(array(struct(1, 'a'), struct(1, 'b'))); -- "Duplicate map keys (1) are not allowed"

.. spark::function:: map_keys(x(K,V)) -> array(K)
Expand Down
6 changes: 2 additions & 4 deletions velox/functions/lib/MapFromEntries.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -250,13 +250,11 @@ class MapFromEntriesFunction : public exec::VectorFunction {
return mapVector;
}

bool throwOnNull_;
const bool throwOnNull_;
};
} // namespace

void registerMapFromEntriesFunction(
const std::string& name,
const bool throwOnNull) {
void registerMapFromEntriesFunction(const std::string& name, bool throwOnNull) {
exec::registerVectorFunction(
name,
MapFromEntriesFunction::signatures(),
Expand Down
5 changes: 2 additions & 3 deletions velox/functions/lib/MapFromEntries.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@

namespace facebook::velox::functions {

void registerMapFromEntriesFunction(
const std::string& name,
const bool throwForNull);
// Use throwForNull to distinguish different null handling in presto and spark
void registerMapFromEntriesFunction(const std::string& name, bool throwForNull);

} // namespace facebook::velox::functions
2 changes: 1 addition & 1 deletion velox/functions/sparksql/tests/MapFromEntriesTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class MapFromEntriesTest : public SparkFunctionBaseTest {
void verifyMapFromEntries(
const std::vector<VectorPtr>& input,
const VectorPtr& expected,
const std::string& funcArg = "c0") {
const std::string& funcArg) {
const std::string expr = fmt::format("map_from_entries({})", funcArg);
auto result = evaluate<MapVector>(expr, makeRowVector(input));
assertEqualVectors(expected, result);
Expand Down

0 comments on commit 5f395a6

Please sign in to comment.