Skip to content

Commit

Permalink
refactor: Move minor map functions in MapFunctions.h (#12513)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #12513

We have simple map functions (map_key_exists, map_remove_null_values), which does not required independent files. Moving into MapFunctions.h.

Reviewed By: Yuhta

Differential Revision: D70495645

fbshipit-source-id: 9dd15ac80129bd555419847aa3d9121c4549bb8b
  • Loading branch information
amitkdutta authored and facebook-github-bot committed Mar 3, 2025
1 parent bbaf9b8 commit 152e624
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 41 deletions.
17 changes: 17 additions & 0 deletions velox/functions/prestosql/MapFunctions.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,21 @@ struct MapKeyExists {
}
};

template <typename TExec>
struct MapRemoveNullValues {
VELOX_DEFINE_FUNCTION_TYPES(TExec);

void call(
out_type<Map<Generic<T1>, Generic<T2>>>& out,
const arg_type<Map<Generic<T1>, Generic<T2>>>& inputMap) {
for (const auto& entry : inputMap) {
if (entry.second.has_value()) {
auto [keyWriter, valueWriter] = out.add_item();
keyWriter.copy_from(entry.first);
valueWriter.copy_from(entry.second.value());
}
}
}
};

} // namespace facebook::velox::functions
40 changes: 0 additions & 40 deletions velox/functions/prestosql/MapRemoveNullValues.h

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
#include "velox/functions/prestosql/MapFunctions.h"
#include "velox/functions/prestosql/MapKeysByTopNValues.h"
#include "velox/functions/prestosql/MapNormalize.h"
#include "velox/functions/prestosql/MapRemoveNullValues.h"
#include "velox/functions/prestosql/MapSubset.h"
#include "velox/functions/prestosql/MapTopN.h"
#include "velox/functions/prestosql/MapTopNKeys.h"
Expand Down

0 comments on commit 152e624

Please sign in to comment.