Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
PHILO-HE committed Apr 8, 2024
1 parent 935fed1 commit b3e0f1e
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
16 changes: 16 additions & 0 deletions velox/functions/sparksql/Register.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "velox/functions/lib/RegistrationHelpers.h"
#include "velox/functions/lib/Repeat.h"
#include "velox/functions/prestosql/ArrayFunctions.h"
#include "velox/functions/prestosql/BinaryFunctions.h"
#include "velox/functions/prestosql/DateTimeFunctions.h"
#include "velox/functions/prestosql/StringFunctions.h"
#include "velox/functions/sparksql/ArrayMinMaxFunction.h"
Expand Down Expand Up @@ -95,6 +96,13 @@ static void workAroundRegistrationMacro(const std::string& prefix) {
VELOX_REGISTER_VECTOR_FUNCTION(udf_array_contains, prefix + "array_contains");
VELOX_REGISTER_VECTOR_FUNCTION(
udf_array_intersect, prefix + "array_intersect");
VELOX_REGISTER_VECTOR_FUNCTION(udf_array_distinct, prefix + "array_distinct");
VELOX_REGISTER_VECTOR_FUNCTION(udf_array_except, prefix + "array_except");
VELOX_REGISTER_VECTOR_FUNCTION(udf_array_position, prefix + "array_position");
VELOX_REGISTER_VECTOR_FUNCTION(udf_map_entries, prefix + "map_entries");
VELOX_REGISTER_VECTOR_FUNCTION(udf_map_keys, prefix + "map_keys");
VELOX_REGISTER_VECTOR_FUNCTION(udf_map_values, prefix + "map_values");

// This is the semantics of spark.sql.ansi.enabled = false.
registerElementAtFunction(prefix + "element_at", true);

Expand Down Expand Up @@ -208,6 +216,7 @@ void registerFunctions(const std::string& prefix) {
Varchar,
Varchar,
Varchar>({prefix + "str_to_map"});
VELOX_REGISTER_VECTOR_FUNCTION(udf_reverse, prefix + "reverse");

registerFunction<sparksql::LeftFunction, Varchar, Varchar, int32_t>(
{prefix + "left"});
Expand All @@ -229,11 +238,18 @@ void registerFunctions(const std::string& prefix) {
{prefix + "sha1"});
registerFunction<Sha2HexStringFunction, Varchar, Varbinary, int32_t>(
{prefix + "sha2"});
registerFunction<CRC32Function, int64_t, Varbinary>({prefix + "crc32"});

exec::registerStatefulVectorFunction(
prefix + "regexp_extract", re2ExtractSignatures(), makeRegexExtract);
exec::registerStatefulVectorFunction(
prefix + "regexp_extract_all",
re2ExtractAllSignatures(),
makeRe2ExtractAll);
exec::registerStatefulVectorFunction(
prefix + "rlike", re2SearchSignatures(), makeRLike);
exec::registerStatefulVectorFunction(
prefix + "like", likeSignatures(), makeLike);
VELOX_REGISTER_VECTOR_FUNCTION(udf_regexp_split, prefix + "split");

exec::registerStatefulVectorFunction(
Expand Down
12 changes: 12 additions & 0 deletions velox/functions/sparksql/RegisterArithmetic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,27 @@ void registerArithmeticFunctions(const std::string& prefix) {
registerUnaryNumeric<UnaryMinusFunction>({prefix + "unaryminus"});
// Math functions.
registerUnaryNumeric<AbsFunction>({prefix + "abs"});
registerFunction<
DecimalAbsFunction,
LongDecimal<P1, S1>,
LongDecimal<P1, S1>>({prefix + "abs"});
registerFunction<
DecimalAbsFunction,
ShortDecimal<P1, S1>,
ShortDecimal<P1, S1>>({prefix + "abs"});
registerFunction<AcosFunction, double, double>({prefix + "acos"});
registerFunction<AsinFunction, double, double>({prefix + "asin"});
registerFunction<AcoshFunction, double, double>({prefix + "acosh"});
registerFunction<AsinhFunction, double, double>({prefix + "asinh"});
registerFunction<AtanFunction, double, double>({prefix + "atan"});
registerFunction<AtanhFunction, double, double>({prefix + "atanh"});
registerFunction<SecFunction, double, double>({prefix + "sec"});
registerFunction<CscFunction, double, double>({prefix + "csc"});
registerFunction<SinhFunction, double, double>({prefix + "sinh"});
registerFunction<CosFunction, double, double>({prefix + "cos"});
registerFunction<CoshFunction, double, double>({prefix + "cosh"});
registerFunction<CotFunction, double, double>({prefix + "cot"});
registerFunction<DegreesFunction, double, double>({prefix + "degrees"});
registerFunction<Atan2Function, double, double, double>({prefix + "atan2"});
registerFunction<Log1pFunction, double, double>({prefix + "log1p"});
registerFunction<ToBinaryStringFunction, Varchar, int64_t>({prefix + "bin"});
Expand Down

0 comments on commit b3e0f1e

Please sign in to comment.