From 78fc66b27c6b36f19b225a4828f7bd3cb646ddba Mon Sep 17 00:00:00 2001 From: Rong Rong Date: Tue, 3 Oct 2023 15:33:51 -0700 Subject: [PATCH] [multistage] clean up transform function type (#11726) * clean up transform function type, always allow `_` separate and `camelCase` function names. * also do the same for scalar functions * for built-in functions we do not follow this rule b/c they are naturally registered in SqlStdOperatorTable --------- Co-authored-by: Rong Rong --- .../function/TransformFunctionType.java | 99 ++++----- .../function/scalar/DateTimeConvert.java | 2 +- .../function/scalar/DateTimeFunctions.java | 191 +++++++++--------- .../common/function/scalar/JsonFunctions.java | 20 +- .../parsers/rewriter/CLPDecodeRewriter.java | 2 +- .../FunctionDefinitionRegistryTest.java | 6 +- .../transform/function/ScalarFunctions.java | 26 +-- .../function/CLPDecodeTransformFunction.java | 2 +- .../function/InIdSetTransformFunction.java | 2 +- .../function/TransformFunctionFactory.java | 30 +-- .../executor/ServerQueryExecutorV1Impl.java | 2 +- .../CLPDecodeTransformFunctionTest.java | 14 +- 12 files changed, 197 insertions(+), 199 deletions(-) diff --git a/pinot-common/src/main/java/org/apache/pinot/common/function/TransformFunctionType.java b/pinot-common/src/main/java/org/apache/pinot/common/function/TransformFunctionType.java index 0ca0f4f851a..15decc86d12 100644 --- a/pinot-common/src/main/java/org/apache/pinot/common/function/TransformFunctionType.java +++ b/pinot-common/src/main/java/org/apache/pinot/common/function/TransformFunctionType.java @@ -69,6 +69,7 @@ public enum TransformFunctionType { GREATEST("greatest"), // predicate functions + // there's no need to register these functions b/c Calcite parser doesn't allow explicit function parsing EQUALS("equals"), NOT_EQUALS("not_equals"), GREATER_THAN("greater_than"), @@ -78,17 +79,19 @@ public enum TransformFunctionType { IN("in"), NOT_IN("not_in"), + // null handling functions, they never return null + // there's no need for alternative name b/c Calcite parser doesn't allow non-parentese representation IS_TRUE("is_true"), IS_NOT_TRUE("is_not_true"), IS_FALSE("is_false"), IS_NOT_FALSE("is_not_false"), IS_NULL("is_null"), IS_NOT_NULL("is_not_null"), - COALESCE("coalesce"), - IS_DISTINCT_FROM("is_distinct_from"), IS_NOT_DISTINCT_FROM("is_not_distinct_from"), + COALESCE("coalesce"), + AND("and"), OR("or"), NOT("not"), // NOT operator doesn't cover the transform for NOT IN and NOT LIKE @@ -105,57 +108,58 @@ public enum TransformFunctionType { OperandTypes.family(SqlTypeFamily.ARRAY), "array_to_mv"), // string functions - JSONEXTRACTSCALAR("jsonExtractScalar", + JSON_EXTRACT_SCALAR("jsonExtractScalar", ReturnTypes.cascade(opBinding -> positionalReturnTypeInferenceFromStringLiteral(opBinding, 2, SqlTypeName.VARCHAR), SqlTypeTransforms.FORCE_NULLABLE), OperandTypes.family(ImmutableList.of(SqlTypeFamily.ANY, SqlTypeFamily.CHARACTER, SqlTypeFamily.CHARACTER, SqlTypeFamily.CHARACTER), ordinal -> ordinal > 2), "json_extract_scalar"), - JSONEXTRACTKEY("jsonExtractKey", ReturnTypes.TO_ARRAY, + JSON_EXTRACT_KEY("jsonExtractKey", ReturnTypes.TO_ARRAY, OperandTypes.family(ImmutableList.of(SqlTypeFamily.ANY, SqlTypeFamily.CHARACTER)), "json_extract_key"), // date time functions - TIMECONVERT("timeConvert", + TIME_CONVERT("timeConvert", ReturnTypes.BIGINT_FORCE_NULLABLE, OperandTypes.family(ImmutableList.of(SqlTypeFamily.ANY, SqlTypeFamily.CHARACTER, SqlTypeFamily.CHARACTER)), "time_convert"), - DATETIMECONVERT("dateTimeConvert", + DATE_TIME_CONVERT("dateTimeConvert", ReturnTypes.cascade( opBinding -> dateTimeConverterReturnTypeInference(opBinding), SqlTypeTransforms.FORCE_NULLABLE), OperandTypes.family(ImmutableList.of(SqlTypeFamily.ANY, SqlTypeFamily.CHARACTER, SqlTypeFamily.CHARACTER, SqlTypeFamily.CHARACTER)), "date_time_convert"), - DATETRUNC("dateTrunc", + DATE_TRUNC("dateTrunc", ReturnTypes.BIGINT_FORCE_NULLABLE, OperandTypes.family( ImmutableList.of(SqlTypeFamily.CHARACTER, SqlTypeFamily.ANY, SqlTypeFamily.CHARACTER, SqlTypeFamily.CHARACTER, SqlTypeFamily.CHARACTER), - ordinal -> ordinal > 1)), + ordinal -> ordinal > 1), "date_trunc"), - FROMDATETIME("fromDateTime", ReturnTypes.TIMESTAMP_NULLABLE, + FROM_DATE_TIME("fromDateTime", ReturnTypes.TIMESTAMP_NULLABLE, OperandTypes.family(ImmutableList.of(SqlTypeFamily.CHARACTER, SqlTypeFamily.CHARACTER, SqlTypeFamily.CHARACTER), - ordinal -> ordinal > 1)), + ordinal -> ordinal > 1), "from_date_time"), - TODATETIME("toDateTime", ReturnTypes.VARCHAR_2000_NULLABLE, + TO_DATE_TIME("toDateTime", ReturnTypes.VARCHAR_2000_NULLABLE, OperandTypes.family(ImmutableList.of(SqlTypeFamily.ANY, SqlTypeFamily.CHARACTER, SqlTypeFamily.CHARACTER), - ordinal -> ordinal > 1)), + ordinal -> ordinal > 1), "to_date_time"), - TIMESTAMPADD("timestampAdd", ReturnTypes.TIMESTAMP_NULLABLE, + TIMESTAMP_ADD("timestampAdd", ReturnTypes.TIMESTAMP_NULLABLE, OperandTypes.family(ImmutableList.of(SqlTypeFamily.CHARACTER, SqlTypeFamily.NUMERIC, SqlTypeFamily.ANY)), - "dateAdd"), + "timestamp_add", "dateAdd", "date_add"), - TIMESTAMPDIFF("timestampDiff", ReturnTypes.BIGINT_NULLABLE, - OperandTypes.family(ImmutableList.of(SqlTypeFamily.CHARACTER, SqlTypeFamily.ANY, SqlTypeFamily.ANY)), "dateDiff"), + TIMESTAMP_DIFF("timestampDiff", ReturnTypes.BIGINT_NULLABLE, + OperandTypes.family(ImmutableList.of(SqlTypeFamily.CHARACTER, SqlTypeFamily.ANY, SqlTypeFamily.ANY)), + "timestamp_diff", "dateDiff", "date_diff"), YEAR("year"), - YEAR_OF_WEEK("yearOfWeek", "yow"), + YEAR_OF_WEEK("yearOfWeek", "year_of_week", "yow"), QUARTER("quarter"), - MONTH_OF_YEAR("monthOfYear", "month"), - WEEK_OF_YEAR("weekOfYear", "week"), - DAY_OF_YEAR("dayOfYear", "doy"), - DAY_OF_MONTH("dayOfMonth", "day"), - DAY_OF_WEEK("dayOfWeek", "dow"), + MONTH_OF_YEAR("monthOfYear", "month_of_year", "month"), + WEEK_OF_YEAR("weekOfYear", "week_of_year", "week"), + DAY_OF_YEAR("dayOfYear", "day_of_year", "doy"), + DAY_OF_MONTH("dayOfMonth", "day_of_month", "day"), + DAY_OF_WEEK("dayOfWeek", "day_of_week", "dow"), HOUR("hour"), MINUTE("minute"), SECOND("second"), @@ -166,32 +170,33 @@ public enum TransformFunctionType { // array functions // The only column accepted by "cardinality" function is multi-value array, thus putting "cardinality" as alias. // TODO: once we support other types of multiset, we should make CARDINALITY its own function - ARRAYLENGTH("arrayLength", ReturnTypes.INTEGER, OperandTypes.family(SqlTypeFamily.ARRAY), "cardinality"), - ARRAYAVERAGE("arrayAverage", ReturnTypes.DOUBLE, OperandTypes.family(SqlTypeFamily.ARRAY)), - ARRAYMIN("arrayMin", ReturnTypes.cascade(opBinding -> positionalComponentReturnType(opBinding, 0), - SqlTypeTransforms.FORCE_NULLABLE), OperandTypes.family(SqlTypeFamily.ARRAY)), - ARRAYMAX("arrayMax", ReturnTypes.cascade(opBinding -> positionalComponentReturnType(opBinding, 0), - SqlTypeTransforms.FORCE_NULLABLE), OperandTypes.family(SqlTypeFamily.ARRAY)), - ARRAYSUM("arraySum", ReturnTypes.DOUBLE, OperandTypes.family(SqlTypeFamily.ARRAY)), - VALUEIN("valueIn"), - MAPVALUE("mapValue", ReturnTypes.cascade(opBinding -> + ARRAY_LENGTH("arrayLength", ReturnTypes.INTEGER, OperandTypes.family(SqlTypeFamily.ARRAY), "array_length", + "cardinality"), + ARRAY_AVERAGE("arrayAverage", ReturnTypes.DOUBLE, OperandTypes.family(SqlTypeFamily.ARRAY), "array_average"), + ARRAY_MIN("arrayMin", ReturnTypes.cascade(opBinding -> positionalComponentReturnType(opBinding, 0), + SqlTypeTransforms.FORCE_NULLABLE), OperandTypes.family(SqlTypeFamily.ARRAY), "array_min"), + ARRAY_MAX("arrayMax", ReturnTypes.cascade(opBinding -> positionalComponentReturnType(opBinding, 0), + SqlTypeTransforms.FORCE_NULLABLE), OperandTypes.family(SqlTypeFamily.ARRAY), "array_max"), + ARRAY_SUM("arraySum", ReturnTypes.DOUBLE, OperandTypes.family(SqlTypeFamily.ARRAY), "array_sum"), + VALUE_IN("valueIn", "value_in"), + MAP_VALUE("mapValue", ReturnTypes.cascade(opBinding -> opBinding.getOperandType(2).getComponentType(), SqlTypeTransforms.FORCE_NULLABLE), OperandTypes.family(ImmutableList.of(SqlTypeFamily.ANY, SqlTypeFamily.ANY, SqlTypeFamily.ANY)), "map_value"), // special functions - INIDSET("inIdSet"), + IN_ID_SET("inIdSet", "in_id_set"), LOOKUP("lookUp"), GROOVY("groovy"), // CLP functions - CLPDECODE("clpDecode", ReturnTypes.VARCHAR_2000_NULLABLE, OperandTypes.family( + CLP_DECODE("clpDecode", ReturnTypes.VARCHAR_2000_NULLABLE, OperandTypes.family( ImmutableList.of(SqlTypeFamily.ANY, SqlTypeFamily.ANY, SqlTypeFamily.ANY, SqlTypeFamily.CHARACTER), ordinal -> ordinal > 2), "clp_decode"), // Regexp functions REGEXP_EXTRACT("regexpExtract", "regexp_extract"), - REGEXPREPLACE("regexpReplace", + REGEXP_REPLACE("regexpReplace", ReturnTypes.VARCHAR_2000_NULLABLE, OperandTypes.family( ImmutableList.of(SqlTypeFamily.ANY, SqlTypeFamily.CHARACTER, SqlTypeFamily.CHARACTER, SqlTypeFamily.CHARACTER, @@ -209,31 +214,31 @@ public enum TransformFunctionType { ST_GEOM_FROM_WKB("ST_GeomFromWKB", ReturnTypes.explicit(SqlTypeName.VARBINARY), OperandTypes.BINARY), ST_POINT("ST_Point", ReturnTypes.explicit(SqlTypeName.VARBINARY), OperandTypes.family(ImmutableList.of(SqlTypeFamily.NUMERIC, SqlTypeFamily.NUMERIC, SqlTypeFamily.NUMERIC), - ordinal -> ordinal > 1 && ordinal < 4)), - ST_POLYGON("ST_Polygon", ReturnTypes.explicit(SqlTypeName.VARBINARY), OperandTypes.STRING), + ordinal -> ordinal > 1 && ordinal < 4), "stPoint"), + ST_POLYGON("ST_Polygon", ReturnTypes.explicit(SqlTypeName.VARBINARY), OperandTypes.STRING, "stPolygon"), // Geo measurements - ST_AREA("ST_Area", ReturnTypes.DOUBLE_NULLABLE, OperandTypes.BINARY), + ST_AREA("ST_Area", ReturnTypes.DOUBLE_NULLABLE, OperandTypes.BINARY, "stArea"), ST_DISTANCE("ST_Distance", ReturnTypes.DOUBLE_NULLABLE, - OperandTypes.family(ImmutableList.of(SqlTypeFamily.BINARY, SqlTypeFamily.BINARY))), - ST_GEOMETRY_TYPE("ST_GeometryType", ReturnTypes.VARCHAR_2000_NULLABLE, OperandTypes.BINARY), + OperandTypes.family(ImmutableList.of(SqlTypeFamily.BINARY, SqlTypeFamily.BINARY)), "stDistance"), + ST_GEOMETRY_TYPE("ST_GeometryType", ReturnTypes.VARCHAR_2000_NULLABLE, OperandTypes.BINARY, "stGeometryType"), // Geo outputs - ST_AS_BINARY("ST_AsBinary", ReturnTypes.explicit(SqlTypeName.VARBINARY), OperandTypes.BINARY), - ST_AS_TEXT("ST_AsText", ReturnTypes.VARCHAR_2000_NULLABLE, OperandTypes.BINARY), + ST_AS_BINARY("ST_AsBinary", ReturnTypes.explicit(SqlTypeName.VARBINARY), OperandTypes.BINARY, "stAsBinary"), + ST_AS_TEXT("ST_AsText", ReturnTypes.VARCHAR_2000_NULLABLE, OperandTypes.BINARY, "stAsText"), // Geo relationship ST_CONTAINS("ST_Contains", ReturnTypes.INTEGER, - OperandTypes.family(ImmutableList.of(SqlTypeFamily.BINARY, SqlTypeFamily.BINARY))), + OperandTypes.family(ImmutableList.of(SqlTypeFamily.BINARY, SqlTypeFamily.BINARY)), "stContains"), ST_EQUALS("ST_Equals", ReturnTypes.INTEGER, - OperandTypes.family(ImmutableList.of(SqlTypeFamily.BINARY, SqlTypeFamily.BINARY))), + OperandTypes.family(ImmutableList.of(SqlTypeFamily.BINARY, SqlTypeFamily.BINARY)), "stEquals"), ST_WITHIN("ST_Within", ReturnTypes.INTEGER, - OperandTypes.family(ImmutableList.of(SqlTypeFamily.BINARY, SqlTypeFamily.BINARY))), + OperandTypes.family(ImmutableList.of(SqlTypeFamily.BINARY, SqlTypeFamily.BINARY)), "stWithin"), // Geo indexing - GEOTOH3("geoToH3", ReturnTypes.explicit(SqlTypeName.BIGINT), + GEO_TO_H3("geoToH3", ReturnTypes.explicit(SqlTypeName.BIGINT), OperandTypes.family(ImmutableList.of(SqlTypeFamily.ANY, SqlTypeFamily.NUMERIC, SqlTypeFamily.NUMERIC), - ordinal -> ordinal > 1 && ordinal < 4)), + ordinal -> ordinal > 1 && ordinal < 4), "geo_to_h3"), // Vector functions // TODO: Once VECTOR type is defined, we should update here. @@ -251,7 +256,7 @@ public enum TransformFunctionType { VECTOR_NORM("vectorNorm", ReturnTypes.explicit(SqlTypeName.DOUBLE), OperandTypes.family(ImmutableList.of(SqlTypeFamily.ARRAY)), "vector_norm"), - ARRAY_VALUE_CONSTRUCTOR("arrayValueConstructor"), + ARRAY_VALUE_CONSTRUCTOR("arrayValueConstructor", "array_value_constructor"), // Trigonometry SIN("sin"), diff --git a/pinot-common/src/main/java/org/apache/pinot/common/function/scalar/DateTimeConvert.java b/pinot-common/src/main/java/org/apache/pinot/common/function/scalar/DateTimeConvert.java index 024b92030fa..9f2a3382956 100644 --- a/pinot-common/src/main/java/org/apache/pinot/common/function/scalar/DateTimeConvert.java +++ b/pinot-common/src/main/java/org/apache/pinot/common/function/scalar/DateTimeConvert.java @@ -34,7 +34,7 @@ public class DateTimeConvert { private DateTimeFormatSpec _outputFormatSpec; private DateTimeGranularitySpec _granularitySpec; - @ScalarFunction + @ScalarFunction(names = {"dateTimeConvert", "date_time_convert"}) public String dateTimeConvert(String timeValueStr, String inputFormatStr, String outputFormatStr, String outputGranularityStr) { if (_inputFormatSpec == null) { diff --git a/pinot-common/src/main/java/org/apache/pinot/common/function/scalar/DateTimeFunctions.java b/pinot-common/src/main/java/org/apache/pinot/common/function/scalar/DateTimeFunctions.java index 7c28c589a7b..16dfad75c7a 100644 --- a/pinot-common/src/main/java/org/apache/pinot/common/function/scalar/DateTimeFunctions.java +++ b/pinot-common/src/main/java/org/apache/pinot/common/function/scalar/DateTimeFunctions.java @@ -29,6 +29,7 @@ import org.joda.time.DateTimeZone; import org.joda.time.chrono.ISOChronology; + /** * Inbuilt date time related transform functions * @@ -74,12 +75,12 @@ private DateTimeFunctions() { /** * Convert epoch millis to epoch seconds */ - @ScalarFunction + @ScalarFunction(names = {"toEpochSeconds", "to_epoch_seconds"}) public static long toEpochSeconds(long millis) { return TimeUnit.MILLISECONDS.toSeconds(millis); } - @ScalarFunction + @ScalarFunction(names = {"toEpochSecondsMV", "to_epoch_seconds_mv"}) public static long[] toEpochSecondsMV(long[] millis) { long[] results = new long[millis.length]; for (int i = 0; i < millis.length; i++) { @@ -91,12 +92,12 @@ public static long[] toEpochSecondsMV(long[] millis) { /** * Convert epoch millis to epoch minutes */ - @ScalarFunction + @ScalarFunction(names = {"toEpochMinutes", "to_epoch_minutes"}) public static long toEpochMinutes(long millis) { return TimeUnit.MILLISECONDS.toMinutes(millis); } - @ScalarFunction + @ScalarFunction(names = {"toEpochMinutesMV", "to_epoch_minutes_mv"}) public static long[] toEpochMinutesMV(long[] millis) { long[] results = new long[millis.length]; for (int i = 0; i < millis.length; i++) { @@ -108,12 +109,12 @@ public static long[] toEpochMinutesMV(long[] millis) { /** * Convert epoch millis to epoch hours */ - @ScalarFunction + @ScalarFunction(names = {"toEpochHours", "to_epoch_hours"}) public static long toEpochHours(long millis) { return TimeUnit.MILLISECONDS.toHours(millis); } - @ScalarFunction + @ScalarFunction(names = {"toEpochHoursMV", "to_epoch_hours_mv"}) public static long[] toEpochHoursMV(long[] millis) { long[] results = new long[millis.length]; for (int i = 0; i < millis.length; i++) { @@ -125,12 +126,12 @@ public static long[] toEpochHoursMV(long[] millis) { /** * Convert epoch millis to epoch days */ - @ScalarFunction + @ScalarFunction(names = {"toEpochDays", "to_epoch_days"}) public static long toEpochDays(long millis) { return TimeUnit.MILLISECONDS.toDays(millis); } - @ScalarFunction + @ScalarFunction(names = {"toEpochDaysMV", "to_epoch_days_mv"}) public static long[] toEpochDaysMV(long[] millis) { long[] results = new long[millis.length]; for (int i = 0; i < millis.length; i++) { @@ -142,12 +143,12 @@ public static long[] toEpochDaysMV(long[] millis) { /** * Convert epoch millis to epoch seconds, round to nearest rounding bucket */ - @ScalarFunction + @ScalarFunction(names = {"toEpochSecondsRounded", "to_epoch_seconds_rounded"}) public static long toEpochSecondsRounded(long millis, long roundToNearest) { return (TimeUnit.MILLISECONDS.toSeconds(millis) / roundToNearest) * roundToNearest; } - @ScalarFunction + @ScalarFunction(names = {"toEpochSecondsRoundedMV", "to_epoch_seconds_rounded_mv"}) public static long[] toEpochSecondsRoundedMV(long[] millis, long roundToNearest) { long[] results = new long[millis.length]; for (int i = 0; i < millis.length; i++) { @@ -156,16 +157,15 @@ public static long[] toEpochSecondsRoundedMV(long[] millis, long roundToNearest) return results; } - /** * Convert epoch millis to epoch minutes, round to nearest rounding bucket */ - @ScalarFunction + @ScalarFunction(names = {"toEpochMinutesRounded", "to_epoch_minutes_rounded"}) public static long toEpochMinutesRounded(long millis, long roundToNearest) { return (TimeUnit.MILLISECONDS.toMinutes(millis) / roundToNearest) * roundToNearest; } - @ScalarFunction + @ScalarFunction(names = {"toEpochMinutesRoundedMV", "to_epoch_minutes_rounded_mv"}) public static long[] toEpochMinutesRoundedMV(long[] millis, long roundToNearest) { long[] results = new long[millis.length]; for (int i = 0; i < millis.length; i++) { @@ -174,16 +174,15 @@ public static long[] toEpochMinutesRoundedMV(long[] millis, long roundToNearest) return results; } - /** * Convert epoch millis to epoch hours, round to nearest rounding bucket */ - @ScalarFunction + @ScalarFunction(names = {"toEpochHoursRounded", "to_epoch_hours_rounded"}) public static long toEpochHoursRounded(long millis, long roundToNearest) { return (TimeUnit.MILLISECONDS.toHours(millis) / roundToNearest) * roundToNearest; } - @ScalarFunction + @ScalarFunction(names = {"toEpochHoursRoundedMV", "to_epoch_hours_rounded_mv"}) public static long[] toEpochHoursRoundedMV(long[] millis, long roundToNearest) { long[] results = new long[millis.length]; for (int i = 0; i < millis.length; i++) { @@ -192,16 +191,15 @@ public static long[] toEpochHoursRoundedMV(long[] millis, long roundToNearest) { return results; } - /** * Convert epoch millis to epoch days, round to nearest rounding bucket */ - @ScalarFunction + @ScalarFunction(names = {"toEpochDaysRounded", "to_epoch_days_rounded"}) public static long toEpochDaysRounded(long millis, long roundToNearest) { return (TimeUnit.MILLISECONDS.toDays(millis) / roundToNearest) * roundToNearest; } - @ScalarFunction + @ScalarFunction(names = {"toEpochDaysRoundedMV", "to_epoch_days_rounded_mv"}) public static long[] toEpochDaysRoundedMV(long[] millis, long roundToNearest) { long[] results = new long[millis.length]; for (int i = 0; i < millis.length; i++) { @@ -210,16 +208,15 @@ public static long[] toEpochDaysRoundedMV(long[] millis, long roundToNearest) { return results; } - /** * Convert epoch millis to epoch seconds, divided by given bucket, to get nSecondsSinceEpoch */ - @ScalarFunction + @ScalarFunction(names = {"toEpochSecondsBucket", "to_epoch_seconds_bucket"}) public static long toEpochSecondsBucket(long millis, long bucket) { return TimeUnit.MILLISECONDS.toSeconds(millis) / bucket; } - @ScalarFunction + @ScalarFunction(names = {"toEpochSecondsBucketMV", "to_epoch_seconds_bucket_mv"}) public static long[] toEpochSecondsBucketMV(long[] millis, long bucket) { long[] results = new long[millis.length]; for (int i = 0; i < millis.length; i++) { @@ -228,16 +225,15 @@ public static long[] toEpochSecondsBucketMV(long[] millis, long bucket) { return results; } - /** * Convert epoch millis to epoch minutes, divided by given bucket, to get nMinutesSinceEpoch */ - @ScalarFunction + @ScalarFunction(names = {"toEpochMinutesBucket", "to_epoch_minutes_bucket"}) public static long toEpochMinutesBucket(long millis, long bucket) { return TimeUnit.MILLISECONDS.toMinutes(millis) / bucket; } - @ScalarFunction + @ScalarFunction(names = {"toEpochMinutesBucketMV", "to_epoch_minutes_bucket_mv"}) public static long[] toEpochMinutesBucketMV(long[] millis, long bucket) { long[] results = new long[millis.length]; for (int i = 0; i < millis.length; i++) { @@ -246,16 +242,15 @@ public static long[] toEpochMinutesBucketMV(long[] millis, long bucket) { return results; } - /** * Convert epoch millis to epoch hours, divided by given bucket, to get nHoursSinceEpoch */ - @ScalarFunction + @ScalarFunction(names = {"toEpochHoursBucket", "to_epoch_hours_bucket"}) public static long toEpochHoursBucket(long millis, long bucket) { return TimeUnit.MILLISECONDS.toHours(millis) / bucket; } - @ScalarFunction + @ScalarFunction(names = {"toEpochHoursBucketMV", "to_epoch_hours_bucket_mv"}) public static long[] toEpochHoursBucketMV(long[] millis, long bucket) { long[] results = new long[millis.length]; for (int i = 0; i < millis.length; i++) { @@ -264,16 +259,15 @@ public static long[] toEpochHoursBucketMV(long[] millis, long bucket) { return results; } - /** * Convert epoch millis to epoch days, divided by given bucket, to get nDaysSinceEpoch */ - @ScalarFunction + @ScalarFunction(names = {"toEpochDaysBucket", "to_epoch_days_bucket"}) public static long toEpochDaysBucket(long millis, long bucket) { return TimeUnit.MILLISECONDS.toDays(millis) / bucket; } - @ScalarFunction + @ScalarFunction(names = {"toEpochDaysBucketMV", "to_epoch_days_bucket_mv"}) public static long[] toEpochDaysBucketMV(long[] millis, long bucket) { long[] results = new long[millis.length]; for (int i = 0; i < millis.length; i++) { @@ -282,16 +276,15 @@ public static long[] toEpochDaysBucketMV(long[] millis, long bucket) { return results; } - /** * Converts epoch seconds to epoch millis */ - @ScalarFunction + @ScalarFunction(names = {"fromEpochSeconds", "from_epoch_seconds"}) public static long fromEpochSeconds(long seconds) { return TimeUnit.SECONDS.toMillis(seconds); } - @ScalarFunction + @ScalarFunction(names = {"fromEpochSecondsMV", "from_epoch_seconds_mv"}) public static long[] fromEpochSecondsMV(long[] seconds) { long[] results = new long[seconds.length]; for (int i = 0; i < seconds.length; i++) { @@ -303,12 +296,12 @@ public static long[] fromEpochSecondsMV(long[] seconds) { /** * Converts epoch minutes to epoch millis */ - @ScalarFunction + @ScalarFunction(names = {"fromEpochMinutes", "from_epoch_minutes"}) public static long fromEpochMinutes(long minutes) { return TimeUnit.MINUTES.toMillis(minutes); } - @ScalarFunction + @ScalarFunction(names = {"fromEpochMinutesMV", "from_epoch_minutes_mv"}) public static long[] fromEpochMinutesMV(long[] minutes) { long[] results = new long[minutes.length]; for (int i = 0; i < minutes.length; i++) { @@ -320,12 +313,12 @@ public static long[] fromEpochMinutesMV(long[] minutes) { /** * Converts epoch hours to epoch millis */ - @ScalarFunction + @ScalarFunction(names = {"fromEpochHours", "from_epoch_hours"}) public static long fromEpochHours(long hours) { return TimeUnit.HOURS.toMillis(hours); } - @ScalarFunction + @ScalarFunction(names = {"fromEpochHoursMV", "from_epoch_hours_mv"}) public static long[] fromEpochHoursMV(long[] hours) { long[] results = new long[hours.length]; for (int i = 0; i < hours.length; i++) { @@ -337,12 +330,12 @@ public static long[] fromEpochHoursMV(long[] hours) { /** * Converts epoch days to epoch millis */ - @ScalarFunction + @ScalarFunction(names = {"fromEpochDays", "from_epoch_days"}) public static long fromEpochDays(long days) { return TimeUnit.DAYS.toMillis(days); } - @ScalarFunction + @ScalarFunction(names = {"fromEpochDaysMV", "from_epoch_days_mv"}) public static long[] fromEpochDaysMV(long[] days) { long[] results = new long[days.length]; for (int i = 0; i < days.length; i++) { @@ -354,12 +347,12 @@ public static long[] fromEpochDaysMV(long[] days) { /** * Converts nSecondsSinceEpoch (seconds that have been divided by a bucket), to epoch millis */ - @ScalarFunction + @ScalarFunction(names = {"fromEpochSecondsBucket", "from_epoch_seconds_bucket"}) public static long fromEpochSecondsBucket(long seconds, long bucket) { return TimeUnit.SECONDS.toMillis(seconds * bucket); } - @ScalarFunction + @ScalarFunction(names = {"fromEpochSecondsBucketMV", "from_epoch_seconds_bucket_mv"}) public static long[] fromEpochSecondsBucketMV(long[] seconds, long bucket) { long[] results = new long[seconds.length]; for (int i = 0; i < seconds.length; i++) { @@ -371,12 +364,12 @@ public static long[] fromEpochSecondsBucketMV(long[] seconds, long bucket) { /** * Converts nMinutesSinceEpoch (minutes that have been divided by a bucket), to epoch millis */ - @ScalarFunction + @ScalarFunction(names = {"fromEpochMinutesBucket", "from_epoch_minutes_bucket"}) public static long fromEpochMinutesBucket(long minutes, long bucket) { return TimeUnit.MINUTES.toMillis(minutes * bucket); } - @ScalarFunction + @ScalarFunction(names = {"fromEpochMinutesBucketMV", "from_epoch_minutes_bucket_mv"}) public static long[] fromEpochMinutesBucketMV(long[] minutes, long bucket) { long[] results = new long[minutes.length]; for (int i = 0; i < minutes.length; i++) { @@ -388,12 +381,12 @@ public static long[] fromEpochMinutesBucketMV(long[] minutes, long bucket) { /** * Converts nHoursSinceEpoch (hours that have been divided by a bucket), to epoch millis */ - @ScalarFunction + @ScalarFunction(names = {"fromEpochHoursBucket", "from_epoch_hours_bucket"}) public static long fromEpochHoursBucket(long hours, long bucket) { return TimeUnit.HOURS.toMillis(hours * bucket); } - @ScalarFunction + @ScalarFunction(names = {"fromEpochHoursBucketMV", "from_epoch_hours_bucket_mv"}) public static long[] fromEpochHoursBucketMV(long[] hours, long bucket) { long[] results = new long[hours.length]; for (int i = 0; i < hours.length; i++) { @@ -405,12 +398,12 @@ public static long[] fromEpochHoursBucketMV(long[] hours, long bucket) { /** * Converts nDaysSinceEpoch (days that have been divided by a bucket), to epoch millis */ - @ScalarFunction + @ScalarFunction(names = {"fromEpochDaysBucket", "from_epoch_days_bucket"}) public static long fromEpochDaysBucket(long days, long bucket) { return TimeUnit.DAYS.toMillis(days * bucket); } - @ScalarFunction + @ScalarFunction(names = {"fromEpochDaysBucketMV", "from_epoch_days_bucket_mv"}) public static long[] fromEpochDaysBucketMV(long[] days, long bucket) { long[] results = new long[days.length]; for (int i = 0; i < days.length; i++) { @@ -422,12 +415,12 @@ public static long[] fromEpochDaysBucketMV(long[] days, long bucket) { /** * Converts epoch millis to Timestamp */ - @ScalarFunction + @ScalarFunction(names = {"toTimestamp", "to_timestamp"}) public static Timestamp toTimestamp(long millis) { return new Timestamp(millis); } - @ScalarFunction + @ScalarFunction(names = {"toTimestampMV", "to_timestamp_mv"}) public static Timestamp[] toTimestampMV(long[] millis) { Timestamp[] results = new Timestamp[millis.length]; for (int i = 0; i < millis.length; i++) { @@ -439,12 +432,12 @@ public static Timestamp[] toTimestampMV(long[] millis) { /** * Converts Timestamp to epoch millis */ - @ScalarFunction + @ScalarFunction(names = {"fromTimestamp", "from_timestamp"}) public static long fromTimestamp(Timestamp timestamp) { return timestamp.getTime(); } - @ScalarFunction + @ScalarFunction(names = {"fromTimestampMV", "from_timestamp_mv"}) public static long[] fromTimestampMV(Timestamp[] timestamp) { long[] results = new long[timestamp.length]; for (int i = 0; i < timestamp.length; i++) { @@ -456,12 +449,12 @@ public static long[] fromTimestampMV(Timestamp[] timestamp) { /** * Converts epoch millis to DateTime string represented by pattern */ - @ScalarFunction + @ScalarFunction(names = {"toDateTime", "to_date_time"}) public static String toDateTime(long millis, String pattern) { return DateTimePatternHandler.parseEpochMillisToDateTimeString(millis, pattern); } - @ScalarFunction + @ScalarFunction(names = {"toDateTimeMV", "to_date_time_mv"}) public static String[] toDateTimeMV(long[] millis, String pattern) { String[] results = new String[millis.length]; for (int i = 0; i < millis.length; i++) { @@ -473,12 +466,12 @@ public static String[] toDateTimeMV(long[] millis, String pattern) { /** * Converts epoch millis to DateTime string represented by pattern and the time zone id. */ - @ScalarFunction + @ScalarFunction(names = {"toDateTime", "to_date_time"}) public static String toDateTime(long millis, String pattern, String timezoneId) { return DateTimePatternHandler.parseEpochMillisToDateTimeString(millis, pattern, timezoneId); } - @ScalarFunction + @ScalarFunction(names = {"toDateTimeMV", "to_date_time_mv"}) public static String[] toDateTimeMV(long[] millis, String pattern, String timezoneId) { String[] results = new String[millis.length]; for (int i = 0; i < millis.length; i++) { @@ -490,12 +483,12 @@ public static String[] toDateTimeMV(long[] millis, String pattern, String timezo /** * Converts DateTime string represented by pattern to epoch millis */ - @ScalarFunction + @ScalarFunction(names = {"fromDateTime", "from_date_time"}) public static long fromDateTime(String dateTimeString, String pattern) { return DateTimePatternHandler.parseDateTimeStringToEpochMillis(dateTimeString, pattern); } - @ScalarFunction + @ScalarFunction(names = {"fromDateTimeMV", "from_date_time_mv"}) public static long[] fromDateTimeMV(String[] dateTimeString, String pattern) { long[] results = new long[dateTimeString.length]; for (int i = 0; i < dateTimeString.length; i++) { @@ -507,17 +500,17 @@ public static long[] fromDateTimeMV(String[] dateTimeString, String pattern) { /** * Converts DateTime string represented by pattern to epoch millis */ - @ScalarFunction + @ScalarFunction(names = {"fromDateTime", "from_date_time"}) public static long fromDateTime(String dateTimeString, String pattern, String timeZoneId) { return DateTimePatternHandler.parseDateTimeStringToEpochMillis(dateTimeString, pattern, timeZoneId); } - @ScalarFunction + @ScalarFunction(names = {"fromDateTime", "from_date_time"}) public static long fromDateTime(String dateTimeString, String pattern, String timeZoneId, long defaultVal) { return DateTimePatternHandler.parseDateTimeStringToEpochMillis(dateTimeString, pattern, timeZoneId, defaultVal); } - @ScalarFunction + @ScalarFunction(names = {"fromDateTimeMV", "from_date_time_mv"}) public static long[] fromDateTimeMV(String[] dateTimeString, String pattern, String timeZoneId) { long[] results = new long[dateTimeString.length]; for (int i = 0; i < dateTimeString.length; i++) { @@ -535,7 +528,7 @@ public static long round(long timeValue, long roundToNearest) { return (timeValue / roundToNearest) * roundToNearest; } - @ScalarFunction + @ScalarFunction(names = {"roundMV", "round_mv"}) public static long[] roundMV(long[] timeValue, long roundToNearest) { long[] results = new long[timeValue.length]; for (int i = 0; i < timeValue.length; i++) { @@ -571,7 +564,7 @@ public static long ago(String periodString) { return System.currentTimeMillis() - period.toMillis(); } - @ScalarFunction + @ScalarFunction(names = {"agoMV", "ago_mv"}) public static long[] agoMV(String[] periodString) { long[] results = new long[periodString.length]; for (int i = 0; i < periodString.length; i++) { @@ -588,12 +581,12 @@ public static long[] agoMV(String[] periodString) { /** * Returns the hour of the time zone offset. */ - @ScalarFunction + @ScalarFunction(names = {"timezoneHour", "timezone_hour"}) public static int timezoneHour(String timezoneId) { return timezoneHour(timezoneId, 0); } - @ScalarFunction + @ScalarFunction(names = {"timezoneHourMV", "timezone_hour_mv"}) public static int[] timezoneHourMV(String[] timezoneId) { int[] results = new int[timezoneId.length]; for (int i = 0; i < timezoneId.length; i++) { @@ -601,16 +594,17 @@ public static int[] timezoneHourMV(String[] timezoneId) { } return results; } + /** * Returns the hour of the time zone offset, for the UTC timestamp at {@code millis}. This will * properly handle daylight savings time. */ - @ScalarFunction + @ScalarFunction(names = {"timezoneHour", "timezone_hour"}) public static int timezoneHour(String timezoneId, long millis) { return (int) TimeUnit.MILLISECONDS.toHours(DateTimeZone.forID(timezoneId).getOffset(millis)); } - @ScalarFunction + @ScalarFunction(names = {"timezoneHourMV", "timezone_hour_mv"}) public static int[] timezoneHourMV(String timezoneId, long[] millis) { int[] results = new int[millis.length]; for (int i = 0; i < millis.length; i++) { @@ -622,12 +616,12 @@ public static int[] timezoneHourMV(String timezoneId, long[] millis) { /** * Returns the minute of the time zone offset. */ - @ScalarFunction + @ScalarFunction(names = {"timezoneMinute", "timezone_minute"}) public static int timezoneMinute(String timezoneId) { return timezoneMinute(timezoneId, 0); } - @ScalarFunction + @ScalarFunction(names = {"timezoneMinuteMV", "timezone_minute_mv"}) public static int[] timezoneMinuteMV(String[] timezoneId) { int[] results = new int[timezoneId.length]; for (int i = 0; i < timezoneId.length; i++) { @@ -640,12 +634,12 @@ public static int[] timezoneMinuteMV(String[] timezoneId) { * Returns the minute of the time zone offset, for the UTC timestamp at {@code millis}. This will * properly handle daylight savings time */ - @ScalarFunction + @ScalarFunction(names = {"timezoneMinute", "timezone_minute"}) public static int timezoneMinute(String timezoneId, long millis) { return (int) TimeUnit.MILLISECONDS.toMinutes(DateTimeZone.forID(timezoneId).getOffset(millis)) % 60; } - @ScalarFunction + @ScalarFunction(names = {"timezoneMinuteMV", "timezone_minute_mv"}) public static int[] timezoneMinuteMV(String timezoneId, long[] millis) { int[] results = new int[millis.length]; for (int i = 0; i < millis.length; i++) { @@ -662,7 +656,7 @@ public static int year(long millis) { return new DateTime(millis, DateTimeZone.UTC).getYear(); } - @ScalarFunction + @ScalarFunction(names = {"yearMV", "year_mv"}) public static int[] yearMV(long[] millis) { int[] results = new int[millis.length]; for (int i = 0; i < millis.length; i++) { @@ -679,7 +673,7 @@ public static int year(long millis, String timezoneId) { return new DateTime(millis, DateTimeZone.forID(timezoneId)).getYear(); } - @ScalarFunction + @ScalarFunction(names = {"yearMV", "year_mv"}) public static int[] yearMV(long[] millis, String timezoneId) { int[] results = new int[millis.length]; for (int i = 0; i < millis.length; i++) { @@ -730,7 +724,7 @@ public static int quarter(long millis) { return (monthOfYear(millis) - 1) / 3 + 1; } - @ScalarFunction + @ScalarFunction(names = {"quarterMV", "quarter_mv"}) public static int[] quarterMV(long[] millis) { int[] results = new int[millis.length]; for (int i = 0; i < millis.length; i++) { @@ -747,7 +741,7 @@ public static int quarter(long millis, String timezoneId) { return (monthOfYear(millis, timezoneId) - 1) / 3 + 1; } - @ScalarFunction + @ScalarFunction(names = {"quarterMV", "quarter_mv"}) public static int[] quarterMV(long[] millis, String timezoneId) { int[] results = new int[millis.length]; for (int i = 0; i < millis.length; i++) { @@ -936,7 +930,7 @@ public static int hour(long millis) { return new DateTime(millis, DateTimeZone.UTC).getHourOfDay(); } - @ScalarFunction + @ScalarFunction(names = {"hourMV", "hour_mv"}) public static int[] hourMV(long[] millis) { int[] results = new int[millis.length]; for (int i = 0; i < millis.length; i++) { @@ -953,7 +947,7 @@ public static int hour(long millis, String timezoneId) { return new DateTime(millis, DateTimeZone.forID(timezoneId)).getHourOfDay(); } - @ScalarFunction + @ScalarFunction(names = {"hourMV", "hour_mv"}) public static int[] hourMV(long[] millis, String timezoneId) { int[] results = new int[millis.length]; for (int i = 0; i < millis.length; i++) { @@ -970,7 +964,7 @@ public static int minute(long millis) { return new DateTime(millis, DateTimeZone.UTC).getMinuteOfHour(); } - @ScalarFunction + @ScalarFunction(names = {"minuteMV", "minute_mv"}) public static int[] minuteMV(long[] millis) { int[] results = new int[millis.length]; for (int i = 0; i < millis.length; i++) { @@ -987,7 +981,7 @@ public static int minute(long millis, String timezoneId) { return new DateTime(millis, DateTimeZone.forID(timezoneId)).getMinuteOfHour(); } - @ScalarFunction + @ScalarFunction(names = {"minuteMV", "minute_mv"}) public static int[] minuteMV(long[] millis, String timezoneId) { int[] results = new int[millis.length]; for (int i = 0; i < millis.length; i++) { @@ -1004,7 +998,7 @@ public static int second(long millis) { return new DateTime(millis, DateTimeZone.UTC).getSecondOfMinute(); } - @ScalarFunction + @ScalarFunction(names = {"secondMV", "second_mv"}) public static int[] secondMV(long[] millis) { int[] results = new int[millis.length]; for (int i = 0; i < millis.length; i++) { @@ -1021,7 +1015,7 @@ public static int second(long millis, String timezoneId) { return new DateTime(millis, DateTimeZone.forID(timezoneId)).getSecondOfMinute(); } - @ScalarFunction + @ScalarFunction(names = {"secondMV", "second_mv"}) public static int[] secondMV(long[] millis, String timezoneId) { int[] results = new int[millis.length]; for (int i = 0; i < millis.length; i++) { @@ -1038,7 +1032,7 @@ public static int millisecond(long millis) { return new DateTime(millis, DateTimeZone.UTC).getMillisOfSecond(); } - @ScalarFunction + @ScalarFunction(names = {"millisecondMV", "millisecond_mv"}) public static int[] millisecondMV(long[] millis) { int[] results = new int[millis.length]; for (int i = 0; i < millis.length; i++) { @@ -1055,7 +1049,7 @@ public static int millisecond(long millis, String timezoneId) { return new DateTime(millis, DateTimeZone.forID(timezoneId)).getMillisOfSecond(); } - @ScalarFunction + @ScalarFunction(names = {"millisecondMV", "millisecond_mv"}) public static int[] millisecondMV(long[] millis, String timezoneId) { int[] results = new int[millis.length]; for (int i = 0; i < millis.length; i++) { @@ -1071,13 +1065,13 @@ public static int[] millisecondMV(long[] millis, String timezoneId) { * @param timeValue value to truncate * @return truncated timeValue in TimeUnit.MILLISECONDS */ - @ScalarFunction + @ScalarFunction(names = {"dateTrunc", "date_trunc"}) public static long dateTrunc(String unit, long timeValue) { return dateTrunc(unit, timeValue, TimeUnit.MILLISECONDS.name(), ISOChronology.getInstanceUTC(), TimeUnit.MILLISECONDS.name()); } - @ScalarFunction + @ScalarFunction(names = {"dateTruncMV", "date_trunc_mv"}) public static long[] dateTruncMV(String unit, long[] timeValue) { long[] results = new long[timeValue.length]; for (int i = 0; i < timeValue.length; i++) { @@ -1094,12 +1088,12 @@ public static long[] dateTruncMV(String unit, long[] timeValue) { * @param inputTimeUnit TimeUnit of value, expressed in Java's joda TimeUnit * @return truncated timeValue in same TimeUnit as the input */ - @ScalarFunction + @ScalarFunction(names = {"dateTrunc", "date_trunc"}) public static long dateTrunc(String unit, long timeValue, String inputTimeUnit) { return dateTrunc(unit, timeValue, inputTimeUnit, ISOChronology.getInstanceUTC(), inputTimeUnit); } - @ScalarFunction + @ScalarFunction(names = {"dateTruncMV", "date_trunc_mv"}) public static long[] dateTruncMV(String unit, long[] timeValue, String inputTimeUnit) { long[] results = new long[timeValue.length]; for (int i = 0; i < timeValue.length; i++) { @@ -1117,13 +1111,13 @@ public static long[] dateTruncMV(String unit, long[] timeValue, String inputTime * @param timeZone timezone of the input * @return truncated timeValue in same TimeUnit as the input */ - @ScalarFunction + @ScalarFunction(names = {"dateTrunc", "date_trunc"}) public static long dateTrunc(String unit, long timeValue, String inputTimeUnit, String timeZone) { return dateTrunc(unit, timeValue, inputTimeUnit, DateTimeUtils.getChronology(TimeZoneKey.getTimeZoneKey(timeZone)), inputTimeUnit); } - @ScalarFunction + @ScalarFunction(names = {"dateTruncMV", "date_trunc_mv"}) public static long[] dateTruncMV(String unit, long[] timeValue, String inputTimeUnit, String timeZone) { long[] results = new long[timeValue.length]; for (int i = 0; i < timeValue.length; i++) { @@ -1143,14 +1137,14 @@ public static long[] dateTruncMV(String unit, long[] timeValue, String inputTime * @return truncated timeValue * */ - @ScalarFunction + @ScalarFunction(names = {"dateTrunc", "date_trunc"}) public static long dateTrunc(String unit, long timeValue, String inputTimeUnit, String timeZone, String outputTimeUnit) { - return dateTrunc(unit, timeValue, inputTimeUnit, - DateTimeUtils.getChronology(TimeZoneKey.getTimeZoneKey(timeZone)), outputTimeUnit); + return dateTrunc(unit, timeValue, inputTimeUnit, DateTimeUtils.getChronology(TimeZoneKey.getTimeZoneKey(timeZone)), + outputTimeUnit); } - @ScalarFunction + @ScalarFunction(names = {"dateTruncMV", "date_trunc_mv"}) public static long[] dateTruncMV(String unit, long[] timeValue, String inputTimeUnit, String timeZone, String outputTimeUnit) { long[] results = new long[timeValue.length]; @@ -1175,14 +1169,14 @@ private static long dateTrunc(String unit, long timeValue, String inputTimeUnit, * @param timestamp * @return */ - @ScalarFunction(names = {"timestampAdd", "dateAdd"}) + @ScalarFunction(names = {"timestampAdd", "timestamp_add", "dateAdd", "date_add"}) public static long timestampAdd(String unit, long interval, long timestamp) { ISOChronology chronology = ISOChronology.getInstanceUTC(); long millis = DateTimeUtils.getTimestampField(chronology, unit).add(timestamp, interval); return millis; } - @ScalarFunction(names = {"timestampAddMV", "dateAddMV"}) + @ScalarFunction(names = {"timestampAddMV", "timestamp_add_mv", "dateAddMV", "date_add_mv"}) public static long[] timestampAddMV(String unit, long interval, long[] timestamp) { long[] results = new long[timestamp.length]; for (int i = 0; i < timestamp.length; i++) { @@ -1199,13 +1193,13 @@ public static long[] timestampAddMV(String unit, long interval, long[] timestamp * @param timestamp2 * @return */ - @ScalarFunction(names = {"timestampDiff", "dateDiff"}) + @ScalarFunction(names = {"timestampDiff", "timestamp_diff", "dateDiff", "date_diff"}) public static long timestampDiff(String unit, long timestamp1, long timestamp2) { ISOChronology chronology = ISOChronology.getInstanceUTC(); return DateTimeUtils.getTimestampField(chronology, unit).getDifferenceAsLong(timestamp2, timestamp1); } - @ScalarFunction(names = {"timestampDiffMV", "dateDiffMV"}) + @ScalarFunction(names = {"timestampDiffMV", "timestamp_diff_mv", "dateDiffMV", "date_diff_mv"}) public static long[] timestampDiffMV(String unit, long[] timestamp1, long timestamp2) { long[] results = new long[timestamp1.length]; for (int i = 0; i < timestamp1.length; i++) { @@ -1214,7 +1208,8 @@ public static long[] timestampDiffMV(String unit, long[] timestamp1, long timest return results; } - @ScalarFunction(names = {"timestampDiffMVReverse", "dateDiffMVReverse"}) + @ScalarFunction(names = {"timestampDiffMVReverse", "timestamp_diff_mv_reverse", "dateDiffMVReverse", + "date_diff_mv_reverse"}) public static long[] timestampDiffMVReverse(String unit, long timestamp1, long[] timestamp2) { long[] results = new long[timestamp2.length]; for (int i = 0; i < timestamp2.length; i++) { diff --git a/pinot-common/src/main/java/org/apache/pinot/common/function/scalar/JsonFunctions.java b/pinot-common/src/main/java/org/apache/pinot/common/function/scalar/JsonFunctions.java index 5effbe3e544..659f9e717dd 100644 --- a/pinot-common/src/main/java/org/apache/pinot/common/function/scalar/JsonFunctions.java +++ b/pinot-common/src/main/java/org/apache/pinot/common/function/scalar/JsonFunctions.java @@ -76,7 +76,7 @@ public static String toJsonMapStr(@Nullable Map map) /** * Convert object to Json String */ - @ScalarFunction + @ScalarFunction(names = {"jsonFormat", "json_format"}) public static String jsonFormat(Object object) throws JsonProcessingException { return JsonUtils.objectToString(object); @@ -85,7 +85,7 @@ public static String jsonFormat(Object object) /** * Extract object based on Json path */ - @ScalarFunction + @ScalarFunction(names = {"jsonPath", "json_path"}) public static Object jsonPath(Object object, String jsonPath) { if (object instanceof String) { return PARSE_CONTEXT.parse((String) object).read(jsonPath, NO_PREDICATES); @@ -96,7 +96,7 @@ public static Object jsonPath(Object object, String jsonPath) { /** * Extract object array based on Json path */ - @ScalarFunction + @ScalarFunction(names = {"jsonPathArray", "json_path_array"}) public static Object[] jsonPathArray(Object object, String jsonPath) { if (object instanceof String) { return convertObjectToArray(PARSE_CONTEXT.parse((String) object).read(jsonPath, NO_PREDICATES)); @@ -104,7 +104,7 @@ public static Object[] jsonPathArray(Object object, String jsonPath) { return convertObjectToArray(PARSE_CONTEXT.parse(object).read(jsonPath, NO_PREDICATES)); } - @ScalarFunction(nullableParameters = true) + @ScalarFunction(nullableParameters = true, names = {"jsonPathArrayDefaultEmpty", "json_path_array_default_empty"}) public static Object[] jsonPathArrayDefaultEmpty(@Nullable Object object, String jsonPath) { try { Object[] result = object == null ? null : jsonPathArray(object, jsonPath); @@ -129,7 +129,7 @@ private static Object[] convertObjectToArray(Object arrayObject) { * Extract from Json with path to String */ @Nullable - @ScalarFunction + @ScalarFunction(names = {"jsonPathString", "json_path_string"}) public static String jsonPathString(Object object, String jsonPath) throws JsonProcessingException { Object jsonValue = jsonPath(object, jsonPath); @@ -142,7 +142,7 @@ public static String jsonPathString(Object object, String jsonPath) /** * Extract from Json with path to String */ - @ScalarFunction(nullableParameters = true) + @ScalarFunction(nullableParameters = true, names = {"jsonPathString", "json_path_string"}) public static String jsonPathString(@Nullable Object object, String jsonPath, String defaultValue) { try { Object jsonValue = jsonPath(object, jsonPath); @@ -158,7 +158,7 @@ public static String jsonPathString(@Nullable Object object, String jsonPath, St /** * Extract from Json with path to Long */ - @ScalarFunction + @ScalarFunction(names = {"jsonPathLong", "json_path_long"}) public static long jsonPathLong(Object object, String jsonPath) { return jsonPathLong(object, jsonPath, Long.MIN_VALUE); } @@ -166,7 +166,7 @@ public static long jsonPathLong(Object object, String jsonPath) { /** * Extract from Json with path to Long */ - @ScalarFunction(nullableParameters = true) + @ScalarFunction(nullableParameters = true, names = {"jsonPathLong", "json_path_long"}) public static long jsonPathLong(@Nullable Object object, String jsonPath, long defaultValue) { try { Object jsonValue = jsonPath(object, jsonPath); @@ -185,7 +185,7 @@ public static long jsonPathLong(@Nullable Object object, String jsonPath, long d /** * Extract from Json with path to Double */ - @ScalarFunction + @ScalarFunction(names = {"jsonPathDouble", "json_path_double"}) public static double jsonPathDouble(Object object, String jsonPath) { return jsonPathDouble(object, jsonPath, Double.NaN); } @@ -193,7 +193,7 @@ public static double jsonPathDouble(Object object, String jsonPath) { /** * Extract from Json with path to Double */ - @ScalarFunction(nullableParameters = true) + @ScalarFunction(nullableParameters = true, names = {"jsonPathDouble", "json_path_double"}) public static double jsonPathDouble(@Nullable Object object, String jsonPath, double defaultValue) { try { Object jsonValue = jsonPath(object, jsonPath); diff --git a/pinot-common/src/main/java/org/apache/pinot/sql/parsers/rewriter/CLPDecodeRewriter.java b/pinot-common/src/main/java/org/apache/pinot/sql/parsers/rewriter/CLPDecodeRewriter.java index c870f84bb04..aff72661530 100644 --- a/pinot-common/src/main/java/org/apache/pinot/sql/parsers/rewriter/CLPDecodeRewriter.java +++ b/pinot-common/src/main/java/org/apache/pinot/sql/parsers/rewriter/CLPDecodeRewriter.java @@ -60,7 +60,7 @@ public class CLPDecodeRewriter implements QueryRewriter { public static final String ENCODED_VARS_COLUMN_SUFFIX = "_encodedVars"; private static final String _CLPDECODE_LOWERCASE_TRANSFORM_NAME = - TransformFunctionType.CLPDECODE.getName().toLowerCase(); + TransformFunctionType.CLP_DECODE.getName().toLowerCase(); @Override public PinotQuery rewrite(PinotQuery pinotQuery) { diff --git a/pinot-common/src/test/java/org/apache/pinot/common/function/FunctionDefinitionRegistryTest.java b/pinot-common/src/test/java/org/apache/pinot/common/function/FunctionDefinitionRegistryTest.java index 5acf0b3072e..6de89593033 100644 --- a/pinot-common/src/test/java/org/apache/pinot/common/function/FunctionDefinitionRegistryTest.java +++ b/pinot-common/src/test/java/org/apache/pinot/common/function/FunctionDefinitionRegistryTest.java @@ -47,10 +47,8 @@ public class FunctionDefinitionRegistryTest { // Scalar function "scalar", // Functions without scalar function counterpart as of now - // TODO: Revisit this list when we add scalar function for these functions - "arraylength", "arrayaverage", "arraymin", "arraymax", "arraysum", - "valuein", "mapvalue", "inidset", "lookup", "groovy", - "timeconvert", "datetimeconvert", "jsonextractscalar", "jsonextractkey", "clpdecode", + "arraylength", "arrayaverage", "arraymin", "arraymax", "arraysum", "clpdecode", "groovy", + "inidset", "jsonextractscalar", "jsonextractkey", "lookup", "mapvalue", "timeconvert", "valuein", // functions not needed for register b/c they are in std sql table or they will not be composed directly. "in", "not_in", "and", "or", "range", "extract", "is_true", "is_not_true", "is_false", "is_not_false" ); diff --git a/pinot-core/src/main/java/org/apache/pinot/core/geospatial/transform/function/ScalarFunctions.java b/pinot-core/src/main/java/org/apache/pinot/core/geospatial/transform/function/ScalarFunctions.java index 7291ae66109..a97dbbb9a3b 100644 --- a/pinot-core/src/main/java/org/apache/pinot/core/geospatial/transform/function/ScalarFunctions.java +++ b/pinot-core/src/main/java/org/apache/pinot/core/geospatial/transform/function/ScalarFunctions.java @@ -42,7 +42,7 @@ private ScalarFunctions() { * @param y y * @return the created point */ - @ScalarFunction + @ScalarFunction(names = {"stPoint", "ST_point"}) public static byte[] stPoint(double x, double y) { return GeometrySerializer.serialize(GeometryUtils.GEOMETRY_FACTORY.createPoint(new Coordinate(x, y))); } @@ -55,7 +55,7 @@ public static byte[] stPoint(double x, double y) { * @param isGeography if it's geography * @return the created point */ - @ScalarFunction + @ScalarFunction(names = {"stPoint", "ST_point"}) public static byte[] stPoint(double x, double y, boolean isGeography) { Point point = GeometryUtils.GEOMETRY_FACTORY.createPoint(new Coordinate(x, y)); if (isGeography) { @@ -67,7 +67,7 @@ public static byte[] stPoint(double x, double y, boolean isGeography) { /** * Reads a geometry object from the WKT format. */ - @ScalarFunction + @ScalarFunction(names = {"stGeomFromText", "ST_geom_from_text"}) public static byte[] stGeomFromText(String wkt) throws ParseException { return GeometrySerializer.serialize(GeometryUtils.GEOMETRY_WKT_READER.read(wkt)); @@ -76,7 +76,7 @@ public static byte[] stGeomFromText(String wkt) /** * Reads a geography object from the WKT format. */ - @ScalarFunction + @ScalarFunction(names = {"stGeogFromText", "ST_geog_from_text"}) public static byte[] stGeogFromText(String wkt) throws ParseException { return GeometrySerializer.serialize(GeometryUtils.GEOGRAPHY_WKT_READER.read(wkt)); @@ -85,7 +85,7 @@ public static byte[] stGeogFromText(String wkt) /** * Reads a geometry object from the WKB format. */ - @ScalarFunction + @ScalarFunction(names = {"stGeomFromWKB", "ST_geom_from_wkb"}) public static byte[] stGeomFromWKB(byte[] wkb) throws ParseException { return GeometrySerializer.serialize(GeometryUtils.GEOMETRY_WKB_READER.read(wkb)); @@ -94,7 +94,7 @@ public static byte[] stGeomFromWKB(byte[] wkb) /** * Reads a geography object from the WKB format. */ - @ScalarFunction + @ScalarFunction(names = {"stGeogFromWKB", "ST_geog_from_wkb"}) public static byte[] stGeogFromWKB(byte[] wkb) throws ParseException { return GeometrySerializer.serialize(GeometryUtils.GEOGRAPHY_WKB_READER.read(wkb)); @@ -106,7 +106,7 @@ public static byte[] stGeogFromWKB(byte[] wkb) * @param bytes the serialized geometry object * @return the geometry in WKT */ - @ScalarFunction + @ScalarFunction(names = {"stAsText", "ST_as_text"}) public static String stAsText(byte[] bytes) { return GeometryUtils.WKT_WRITER.write(GeometrySerializer.deserialize(bytes)); } @@ -117,7 +117,7 @@ public static String stAsText(byte[] bytes) { * @param bytes the serialized geometry object * @return the geometry in WKB */ - @ScalarFunction + @ScalarFunction(names = {"stAsBinary", "ST_as_binary"}) public static byte[] stAsBinary(byte[] bytes) { return GeometryUtils.WKB_WRITER.write(GeometrySerializer.deserialize(bytes)); } @@ -128,7 +128,7 @@ public static byte[] stAsBinary(byte[] bytes) { * @param bytes the serialized geometry object * @return the geographical object */ - @ScalarFunction + @ScalarFunction(names = {"toSphericalGeography", "to_spherical_geography"}) public static byte[] toSphericalGeography(byte[] bytes) { Geometry geometry = GeometrySerializer.deserialize(bytes); GeometryUtils.setGeography(geometry); @@ -141,7 +141,7 @@ public static byte[] toSphericalGeography(byte[] bytes) { * @param bytes the serialized geographical object * @return the geometry object */ - @ScalarFunction + @ScalarFunction(names = {"toGeometry", "to_geometry"}) public static byte[] toGeometry(byte[] bytes) { Geometry geometry = GeometrySerializer.deserialize(bytes); GeometryUtils.setGeometry(geometry); @@ -155,7 +155,7 @@ public static byte[] toGeometry(byte[] bytes) { * @param resolution H3 index resolution * @return the H3 index address */ - @ScalarFunction + @ScalarFunction(names = {"geoToH3", "geo_to_h3"}) public static long geoToH3(double longitude, double latitude, int resolution) { return H3Utils.H3_CORE.geoToH3(latitude, longitude, resolution); } @@ -166,7 +166,7 @@ public static long geoToH3(double longitude, double latitude, int resolution) { * @param resolution H3 index resolution * @return the H3 index address */ - @ScalarFunction + @ScalarFunction(names = {"geoToH3", "geo_to_h3"}) public static long geoToH3(byte[] geoBytes, int resolution) { Geometry geometry = GeometrySerializer.deserialize(geoBytes); double latitude = geometry.getCoordinate().y; @@ -174,7 +174,7 @@ public static long geoToH3(byte[] geoBytes, int resolution) { return H3Utils.H3_CORE.geoToH3(latitude, longitude, resolution); } - @ScalarFunction + @ScalarFunction(names = {"stDistance", "ST_distance"}) public static double stDistance(byte[] firstPoint, byte[] secondPoint) { Geometry firstGeometry = GeometrySerializer.deserialize(firstPoint); Geometry secondGeometry = GeometrySerializer.deserialize(secondPoint); diff --git a/pinot-core/src/main/java/org/apache/pinot/core/operator/transform/function/CLPDecodeTransformFunction.java b/pinot-core/src/main/java/org/apache/pinot/core/operator/transform/function/CLPDecodeTransformFunction.java index fcebd0b02a8..bf2eb79cd78 100644 --- a/pinot-core/src/main/java/org/apache/pinot/core/operator/transform/function/CLPDecodeTransformFunction.java +++ b/pinot-core/src/main/java/org/apache/pinot/core/operator/transform/function/CLPDecodeTransformFunction.java @@ -71,7 +71,7 @@ public class CLPDecodeTransformFunction extends BaseTransformFunction { @Override public String getName() { - return TransformFunctionType.CLPDECODE.getName(); + return TransformFunctionType.CLP_DECODE.getName(); } @Override diff --git a/pinot-core/src/main/java/org/apache/pinot/core/operator/transform/function/InIdSetTransformFunction.java b/pinot-core/src/main/java/org/apache/pinot/core/operator/transform/function/InIdSetTransformFunction.java index 69bbc9410e6..7752c13742f 100644 --- a/pinot-core/src/main/java/org/apache/pinot/core/operator/transform/function/InIdSetTransformFunction.java +++ b/pinot-core/src/main/java/org/apache/pinot/core/operator/transform/function/InIdSetTransformFunction.java @@ -46,7 +46,7 @@ public class InIdSetTransformFunction extends BaseTransformFunction { @Override public String getName() { - return TransformFunctionType.INIDSET.getName(); + return TransformFunctionType.IN_ID_SET.getName(); } @Override diff --git a/pinot-core/src/main/java/org/apache/pinot/core/operator/transform/function/TransformFunctionFactory.java b/pinot-core/src/main/java/org/apache/pinot/core/operator/transform/function/TransformFunctionFactory.java index 49030f871fa..16f009e6576 100644 --- a/pinot-core/src/main/java/org/apache/pinot/core/operator/transform/function/TransformFunctionFactory.java +++ b/pinot-core/src/main/java/org/apache/pinot/core/operator/transform/function/TransformFunctionFactory.java @@ -119,11 +119,11 @@ private static Map> createRegistry() typeToImplementation.put(TransformFunctionType.TRUNCATE, TruncateDecimalTransformFunction.class); typeToImplementation.put(TransformFunctionType.CAST, CastTransformFunction.class); - typeToImplementation.put(TransformFunctionType.JSONEXTRACTSCALAR, JsonExtractScalarTransformFunction.class); - typeToImplementation.put(TransformFunctionType.JSONEXTRACTKEY, JsonExtractKeyTransformFunction.class); - typeToImplementation.put(TransformFunctionType.TIMECONVERT, TimeConversionTransformFunction.class); - typeToImplementation.put(TransformFunctionType.DATETIMECONVERT, DateTimeConversionTransformFunction.class); - typeToImplementation.put(TransformFunctionType.DATETRUNC, DateTruncTransformFunction.class); + typeToImplementation.put(TransformFunctionType.JSON_EXTRACT_SCALAR, JsonExtractScalarTransformFunction.class); + typeToImplementation.put(TransformFunctionType.JSON_EXTRACT_KEY, JsonExtractKeyTransformFunction.class); + typeToImplementation.put(TransformFunctionType.TIME_CONVERT, TimeConversionTransformFunction.class); + typeToImplementation.put(TransformFunctionType.DATE_TIME_CONVERT, DateTimeConversionTransformFunction.class); + typeToImplementation.put(TransformFunctionType.DATE_TRUNC, DateTruncTransformFunction.class); typeToImplementation.put(TransformFunctionType.YEAR, DateTimeTransformFunction.Year.class); typeToImplementation.put(TransformFunctionType.YEAR_OF_WEEK, DateTimeTransformFunction.YearOfWeek.class); typeToImplementation.put(TransformFunctionType.QUARTER, DateTimeTransformFunction.Quarter.class); @@ -136,12 +136,12 @@ private static Map> createRegistry() typeToImplementation.put(TransformFunctionType.MINUTE, DateTimeTransformFunction.Minute.class); typeToImplementation.put(TransformFunctionType.SECOND, DateTimeTransformFunction.Second.class); typeToImplementation.put(TransformFunctionType.MILLISECOND, DateTimeTransformFunction.Millisecond.class); - typeToImplementation.put(TransformFunctionType.ARRAYLENGTH, ArrayLengthTransformFunction.class); - typeToImplementation.put(TransformFunctionType.VALUEIN, ValueInTransformFunction.class); - typeToImplementation.put(TransformFunctionType.MAPVALUE, MapValueTransformFunction.class); - typeToImplementation.put(TransformFunctionType.INIDSET, InIdSetTransformFunction.class); + typeToImplementation.put(TransformFunctionType.ARRAY_LENGTH, ArrayLengthTransformFunction.class); + typeToImplementation.put(TransformFunctionType.VALUE_IN, ValueInTransformFunction.class); + typeToImplementation.put(TransformFunctionType.MAP_VALUE, MapValueTransformFunction.class); + typeToImplementation.put(TransformFunctionType.IN_ID_SET, InIdSetTransformFunction.class); typeToImplementation.put(TransformFunctionType.LOOKUP, LookupTransformFunction.class); - typeToImplementation.put(TransformFunctionType.CLPDECODE, CLPDecodeTransformFunction.class); + typeToImplementation.put(TransformFunctionType.CLP_DECODE, CLPDecodeTransformFunction.class); typeToImplementation.put(TransformFunctionType.EXTRACT, ExtractTransformFunction.class); @@ -149,10 +149,10 @@ private static Map> createRegistry() typeToImplementation.put(TransformFunctionType.REGEXP_EXTRACT, RegexpExtractTransformFunction.class); // Array functions - typeToImplementation.put(TransformFunctionType.ARRAYAVERAGE, ArrayAverageTransformFunction.class); - typeToImplementation.put(TransformFunctionType.ARRAYMAX, ArrayMaxTransformFunction.class); - typeToImplementation.put(TransformFunctionType.ARRAYMIN, ArrayMinTransformFunction.class); - typeToImplementation.put(TransformFunctionType.ARRAYSUM, ArraySumTransformFunction.class); + typeToImplementation.put(TransformFunctionType.ARRAY_AVERAGE, ArrayAverageTransformFunction.class); + typeToImplementation.put(TransformFunctionType.ARRAY_MAX, ArrayMaxTransformFunction.class); + typeToImplementation.put(TransformFunctionType.ARRAY_MIN, ArrayMinTransformFunction.class); + typeToImplementation.put(TransformFunctionType.ARRAY_SUM, ArraySumTransformFunction.class); typeToImplementation.put(TransformFunctionType.ARRAY_VALUE_CONSTRUCTOR, ArrayLiteralTransformFunction.class); typeToImplementation.put(TransformFunctionType.GROOVY, GroovyTransformFunction.class); @@ -196,7 +196,7 @@ private static Map> createRegistry() typeToImplementation.put(TransformFunctionType.ST_WITHIN, StWithinFunction.class); // geo indexing - typeToImplementation.put(TransformFunctionType.GEOTOH3, GeoToH3Function.class); + typeToImplementation.put(TransformFunctionType.GEO_TO_H3, GeoToH3Function.class); // tuple selection typeToImplementation.put(TransformFunctionType.LEAST, LeastTransformFunction.class); diff --git a/pinot-core/src/main/java/org/apache/pinot/core/query/executor/ServerQueryExecutorV1Impl.java b/pinot-core/src/main/java/org/apache/pinot/core/query/executor/ServerQueryExecutorV1Impl.java index 286078f1f61..4c3248e527e 100644 --- a/pinot-core/src/main/java/org/apache/pinot/core/query/executor/ServerQueryExecutorV1Impl.java +++ b/pinot-core/src/main/java/org/apache/pinot/core/query/executor/ServerQueryExecutorV1Impl.java @@ -578,7 +578,7 @@ private void handleSubquery(ExpressionContext expression, List ind Preconditions.checkState(result instanceof IdSet, "Got unexpected result type: %s, expecting IdSet", result != null ? result.getClass().getSimpleName() : null); // Rewrite the expression - function.setFunctionName(TransformFunctionType.INIDSET.name()); + function.setFunctionName(TransformFunctionType.IN_ID_SET.name()); arguments.set(1, ExpressionContext.forLiteralContext(FieldSpec.DataType.STRING, ((IdSet) result).toBase64String())); } else { diff --git a/pinot-core/src/test/java/org/apache/pinot/core/operator/transform/function/CLPDecodeTransformFunctionTest.java b/pinot-core/src/test/java/org/apache/pinot/core/operator/transform/function/CLPDecodeTransformFunctionTest.java index f2537c0a447..e0d419dca0e 100644 --- a/pinot-core/src/test/java/org/apache/pinot/core/operator/transform/function/CLPDecodeTransformFunctionTest.java +++ b/pinot-core/src/test/java/org/apache/pinot/core/operator/transform/function/CLPDecodeTransformFunctionTest.java @@ -161,7 +161,7 @@ public void deleteOldIndex() { @Test public void testTransform() { ExpressionContext expression = RequestContextUtils.getExpression( - String.format("%s(%s,%s,%s)", TransformFunctionType.CLPDECODE.getName(), LOGTYPE_COLUMN, DICT_VARS_COLUMN, + String.format("%s(%s,%s,%s)", TransformFunctionType.CLP_DECODE.getName(), LOGTYPE_COLUMN, DICT_VARS_COLUMN, ENCODED_VARS_COLUMN)); TransformFunction transformFunction = TransformFunctionFactory.get(expression, _dataSourceMap); Assert.assertTrue(transformFunction instanceof CLPDecodeTransformFunction); @@ -178,7 +178,7 @@ public void testTransform() { public void testTransformWithDefaultValue() { String defaultValue = "default"; ExpressionContext expression = RequestContextUtils.getExpression( - String.format("%s(%s,%s,%s,'%s')", TransformFunctionType.CLPDECODE.getName(), LOGTYPE_COLUMN, DICT_VARS_COLUMN, + String.format("%s(%s,%s,%s,'%s')", TransformFunctionType.CLP_DECODE.getName(), LOGTYPE_COLUMN, DICT_VARS_COLUMN, ENCODED_VARS_COLUMN, defaultValue)); TransformFunction transformFunction = TransformFunctionFactory.get(expression, _dataSourceMap); Assert.assertTrue(transformFunction instanceof CLPDecodeTransformFunction); @@ -198,7 +198,7 @@ public void testInvalidArgs() { // 1st parameter literal assertThrows(BadQueryRequestException.class, () -> { ExpressionContext expression = RequestContextUtils.getExpression( - String.format("%s('%s',%s,%s,'%s')", TransformFunctionType.CLPDECODE.getName(), LOGTYPE_COLUMN, + String.format("%s('%s',%s,%s,'%s')", TransformFunctionType.CLP_DECODE.getName(), LOGTYPE_COLUMN, DICT_VARS_COLUMN, ENCODED_VARS_COLUMN, defaultValue)); TransformFunctionFactory.get(expression, _dataSourceMap); }); @@ -206,7 +206,7 @@ public void testInvalidArgs() { // 2nd parameter literal assertThrows(BadQueryRequestException.class, () -> { ExpressionContext expression = RequestContextUtils.getExpression( - String.format("%s(%s,'%s',%s,'%s')", TransformFunctionType.CLPDECODE.getName(), LOGTYPE_COLUMN, + String.format("%s(%s,'%s',%s,'%s')", TransformFunctionType.CLP_DECODE.getName(), LOGTYPE_COLUMN, DICT_VARS_COLUMN, ENCODED_VARS_COLUMN, defaultValue)); TransformFunctionFactory.get(expression, _dataSourceMap); }); @@ -214,7 +214,7 @@ public void testInvalidArgs() { // 3rd parameter literal assertThrows(BadQueryRequestException.class, () -> { ExpressionContext expression = RequestContextUtils.getExpression( - String.format("%s(%s,%s,'%s','%s')", TransformFunctionType.CLPDECODE.getName(), LOGTYPE_COLUMN, + String.format("%s(%s,%s,'%s','%s')", TransformFunctionType.CLP_DECODE.getName(), LOGTYPE_COLUMN, DICT_VARS_COLUMN, ENCODED_VARS_COLUMN, defaultValue)); TransformFunctionFactory.get(expression, _dataSourceMap); }); @@ -222,7 +222,7 @@ public void testInvalidArgs() { // 4th parameter identifier assertThrows(BadQueryRequestException.class, () -> { ExpressionContext expression = RequestContextUtils.getExpression( - String.format("%s(%s,%s,%s,%s)", TransformFunctionType.CLPDECODE.getName(), LOGTYPE_COLUMN, + String.format("%s(%s,%s,%s,%s)", TransformFunctionType.CLP_DECODE.getName(), LOGTYPE_COLUMN, DICT_VARS_COLUMN, ENCODED_VARS_COLUMN, defaultValue)); TransformFunctionFactory.get(expression, _dataSourceMap); }); @@ -230,7 +230,7 @@ public void testInvalidArgs() { // Missing arg assertThrows(BadQueryRequestException.class, () -> { ExpressionContext expression = RequestContextUtils.getExpression( - String.format("%s(%s,%s)", TransformFunctionType.CLPDECODE.getName(), LOGTYPE_COLUMN, DICT_VARS_COLUMN)); + String.format("%s(%s,%s)", TransformFunctionType.CLP_DECODE.getName(), LOGTYPE_COLUMN, DICT_VARS_COLUMN)); TransformFunctionFactory.get(expression, _dataSourceMap); }); }