Skip to content

Commit

Permalink
[VL] Remove the registry for Velox's prestosql scalar functions (#5202)
Browse files Browse the repository at this point in the history
  • Loading branch information
PHILO-HE authored Jun 27, 2024
1 parent dc6abe5 commit ac227de
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 17 deletions.
16 changes: 10 additions & 6 deletions cpp/velox/operators/functions/RegistrationAllFunctions.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
#include "velox/functions/prestosql/aggregates/RegisterAggregateFunctions.h"
#include "velox/functions/prestosql/registration/RegistrationFunctions.h"
#include "velox/functions/prestosql/window/WindowFunctionsRegistration.h"
#include "velox/functions/sparksql/Bitwise.h"
#include "velox/functions/sparksql/Hash.h"
#include "velox/functions/sparksql/Rand.h"
#include "velox/functions/sparksql/Register.h"
Expand All @@ -35,6 +34,14 @@

using namespace facebook;

namespace facebook::velox::functions {
void registerPrestoVectorFunctions() {
// Presto function. To be removed.
VELOX_REGISTER_VECTOR_FUNCTION(udf_arrays_overlap, "arrays_overlap");
VELOX_REGISTER_VECTOR_FUNCTION(udf_transform_keys, "transform_keys");
VELOX_REGISTER_VECTOR_FUNCTION(udf_transform_values, "transform_values");
}
} // namespace facebook::velox::functions
namespace gluten {
namespace {
void registerFunctionOverwrite() {
Expand Down Expand Up @@ -67,19 +74,16 @@ void registerFunctionOverwrite() {
velox::exec::registerFunctionCallToSpecialForm(
kRowConstructorWithAllNull,
std::make_unique<RowConstructorWithNullCallToSpecialForm>(kRowConstructorWithAllNull));
velox::functions::sparksql::registerBitwiseFunctions("spark_");
velox::functions::registerBinaryIntegral<velox::functions::CheckedPlusFunction>({"check_add"});
velox::functions::registerBinaryIntegral<velox::functions::CheckedMinusFunction>({"check_subtract"});
velox::functions::registerBinaryIntegral<velox::functions::CheckedMultiplyFunction>({"check_multiply"});
velox::functions::registerBinaryIntegral<velox::functions::CheckedDivideFunction>({"check_divide"});

velox::functions::registerPrestoVectorFunctions();
}
} // namespace

void registerAllFunctions() {
// The registration order matters. Spark sql functions are registered after
// presto sql functions to overwrite the registration for same named
// functions.
velox::functions::prestosql::registerAllScalarFunctions();
velox::functions::sparksql::registerFunctions("");
velox::aggregate::prestosql::registerAllAggregateFunctions(
"", true /*registerCompanionFunctions*/, false /*onlyPrestoSignatures*/, true /*overwrite*/);
Expand Down
12 changes: 1 addition & 11 deletions cpp/velox/substrait/SubstraitParser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -391,23 +391,13 @@ std::unordered_map<std::string, std::string> SubstraitParser::substraitVeloxFunc
{"named_struct", "row_constructor"},
{"bit_or", "bitwise_or_agg"},
{"bit_and", "bitwise_and_agg"},
{"bitwise_and", "spark_bitwise_and"},
{"bitwise_not", "spark_bitwise_not"},
{"bitwise_or", "spark_bitwise_or"},
{"bitwise_xor", "spark_bitwise_xor"},
// TODO: the below registry for rand functions can be removed
// after presto function registry is removed.
{"rand", "spark_rand"},
{"murmur3hash", "hash_with_seed"},
{"xxhash64", "xxhash64_with_seed"},
{"modulus", "remainder"},
{"date_format", "format_datetime"},
{"collect_set", "set_agg"},
{"forall", "all_match"},
{"exists", "any_match"},
{"negative", "unaryminus"},
{"get_array_item", "get"},
{"arrays_zip", "zip"}};
{"get_array_item", "get"}};

const std::unordered_map<std::string, std::string> SubstraitParser::typeMap_ = {
{"bool", "BOOLEAN"},
Expand Down

0 comments on commit ac227de

Please sign in to comment.