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 10, 2024
1 parent 54a7fe8 commit b3f2909
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
22 changes: 22 additions & 0 deletions velox/functions/sparksql/Register.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@
#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/JsonFunctions.h"
#include "velox/functions/prestosql/StringFunctions.h"
#include "velox/functions/prestosql/URLFunctions.h"
#include "velox/functions/sparksql/ArrayMinMaxFunction.h"
#include "velox/functions/sparksql/ArraySort.h"
#include "velox/functions/sparksql/Bitwise.h"
Expand Down Expand Up @@ -94,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 All @@ -105,6 +114,7 @@ static void workAroundRegistrationMacro(const std::string& prefix) {
VELOX_REGISTER_VECTOR_FUNCTION(udf_concat, prefix + "concat");
VELOX_REGISTER_VECTOR_FUNCTION(udf_lower, prefix + "lower");
VELOX_REGISTER_VECTOR_FUNCTION(udf_upper, prefix + "upper");
VELOX_REGISTER_VECTOR_FUNCTION(udf_reverse, prefix + "reverse");
// Logical.
VELOX_REGISTER_VECTOR_FUNCTION(udf_not, prefix + "not");
registerIsNullFunction(prefix + "isnull");
Expand Down Expand Up @@ -222,11 +232,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 Expand Up @@ -300,6 +317,11 @@ void registerFunctions(const std::string& prefix) {
registerFunction<FindInSetFunction, int32_t, Varchar, Varchar>(
{prefix + "find_in_set"});

registerFunction<UrlEncodeFunction, Varchar, Varchar>(
{prefix + "url_encode"});
registerFunction<UrlDecodeFunction, Varchar, Varchar>(
{prefix + "url_decode"});

// Register array sort functions.
exec::registerStatefulVectorFunction(
prefix + "array_sort", arraySortSignatures(), makeArraySort);
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 b3f2909

Please sign in to comment.