Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[VL] Remove the registry for Velox's prestosql scalar functions #5202

Merged
merged 4 commits into from
Jun 27, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 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,19 @@ 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"});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems some registrations in registerFunctionOverwrite() could be removed, including spark_rand, check_xx. After facebookincubator/velox@372abeb, we need to adapt to the new names checked_xx.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I also noted this. Will create another pr to fix it.


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.
rui-mo marked this conversation as resolved.
Show resolved Hide resolved
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"}};
rui-mo marked this conversation as resolved.
Show resolved Hide resolved
{"get_array_item", "get"}};

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