This is an automated email from the ASF dual-hosted git repository.
jackie pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pinot.git
The following commit(s) were added to refs/heads/master by this push:
new 0df481da32 Remove the unnecessary placeholder scaler functions (#11552)
0df481da32 is described below
commit 0df481da32c9363be270ce5a1db794e4437c1f80
Author: Xiaotian (Jackie) Jiang <[email protected]>
AuthorDate: Sun Sep 10 11:18:47 2023 -0700
Remove the unnecessary placeholder scaler functions (#11552)
---
.../pinot/common/function/FunctionRegistry.java | 69 ----------------------
.../common/function/TransformFunctionType.java | 6 +-
.../function/FunctionDefinitionRegistryTest.java | 24 +++++---
.../apache/calcite/sql/fun/PinotOperatorTable.java | 4 +-
4 files changed, 23 insertions(+), 80 deletions(-)
diff --git
a/pinot-common/src/main/java/org/apache/pinot/common/function/FunctionRegistry.java
b/pinot-common/src/main/java/org/apache/pinot/common/function/FunctionRegistry.java
index 023d21ff0d..1fc583bd6a 100644
---
a/pinot-common/src/main/java/org/apache/pinot/common/function/FunctionRegistry.java
+++
b/pinot-common/src/main/java/org/apache/pinot/common/function/FunctionRegistry.java
@@ -159,33 +159,6 @@ public class FunctionRegistry {
*/
private static class PlaceholderScalarFunctions {
- /**
- * Noted that {@code dateTimeConvert} with String as first input is
actually supported.
- *
- * @see
org.apache.pinot.common.function.scalar.DateTimeConvert#dateTimeConvert(String,
String, String, String)
- */
- @ScalarFunction(names = {"dateTimeConvert", "date_time_convert"},
isPlaceholder = true)
- public static String dateTimeConvert(long timeValueNumeric, String
inputFormatStr, String outputFormatStr,
- String outputGranularityStr) {
- throw new UnsupportedOperationException("Placeholder scalar function,
should not reach here");
- }
-
- @ScalarFunction(names = {"jsonExtractScalar", "json_extract_scalar"},
isPlaceholder = true)
- public static Object jsonExtractScalar(String jsonFieldName, String
jsonPath, String resultsType) {
- throw new UnsupportedOperationException("Placeholder scalar function,
should not reach here");
- }
-
- @ScalarFunction(names = {"jsonExtractScalar", "json_extract_scalar"},
isPlaceholder = true)
- public static Object jsonExtractScalar(String jsonFieldName, String
jsonPath, String resultsType,
- Object defaultValue) {
- throw new UnsupportedOperationException("Placeholder scalar function,
should not reach here");
- }
-
- @ScalarFunction(names = {"jsonExtractKey", "json_extract_key"},
isPlaceholder = true)
- public static Object jsonExtractKey(String jsonFieldName, String jsonPath)
{
- throw new UnsupportedOperationException("Placeholder scalar function,
should not reach here");
- }
-
@ScalarFunction(names = {"textContains", "text_contains"}, isPlaceholder =
true)
public static boolean textContains(String text, String pattern) {
throw new UnsupportedOperationException("Placeholder scalar function,
should not reach here");
@@ -200,47 +173,5 @@ public class FunctionRegistry {
public static boolean jsonMatch(String text, String pattern) {
throw new UnsupportedOperationException("Placeholder scalar function,
should not reach here");
}
-
- @ScalarFunction(names = {"clpDecode", "clp_decode"}, isPlaceholder = true)
- public static Object clpDecode(String logtypeFieldName, String
dictVarsFieldName, String encodedVarsFieldName) {
- throw new UnsupportedOperationException("Placeholder scalar function,
should not reach here");
- }
-
- @ScalarFunction(names = {"clpDecode", "clp_decode"}, isPlaceholder = true)
- public static Object clpDecode(String logtypeFieldName, String
dictVarsFieldName, String encodedVarsFieldName,
- String defaultValue) {
- throw new UnsupportedOperationException("Placeholder scalar function,
should not reach here");
- }
-
- @ScalarFunction(names = {"arrayToMV", "array_to_mv"},
- isPlaceholder = true)
- public static String arrayToMV(Object multiValue) {
- throw new UnsupportedOperationException("Placeholder scalar function,
should not reach here");
- }
-
- @ScalarFunction(names = "arrayMin", isPlaceholder = true)
- public static String arrayMin(Object multiValue) {
- throw new UnsupportedOperationException("Placeholder scalar function,
should not reach here");
- }
-
- @ScalarFunction(names = "arrayMax", isPlaceholder = true)
- public static String arrayMax(Object multiValue) {
- throw new UnsupportedOperationException("Placeholder scalar function,
should not reach here");
- }
-
- @ScalarFunction(names = "arrayLength", isPlaceholder = true)
- public static String arrayLength(Object multiValue) {
- throw new UnsupportedOperationException("Placeholder scalar function,
should not reach here");
- }
-
- @ScalarFunction(names = "arrayAverage", isPlaceholder = true)
- public static String arrayAverage(Object multiValue) {
- throw new UnsupportedOperationException("Placeholder scalar function,
should not reach here");
- }
-
- @ScalarFunction(names = "arraySum", isPlaceholder = true)
- public static String arraySum(Object multiValue) {
- throw new UnsupportedOperationException("Placeholder scalar function,
should not reach here");
- }
}
}
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 ab8e53a4e2..0ca0f4f851 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
@@ -183,7 +183,11 @@ public enum TransformFunctionType {
INIDSET("inIdSet"),
LOOKUP("lookUp"),
GROOVY("groovy"),
- CLPDECODE("clpDecode"),
+
+ // CLP functions
+ CLPDECODE("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"),
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 8ce8123fc9..5acf0b3072 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
@@ -35,16 +35,24 @@ import static org.testng.Assert.assertTrue;
public class FunctionDefinitionRegistryTest {
- private static final int MAX_NARG = 10;
- private static final List<Pattern> IGNORED_TRANSFORM_FUNCTION_SIGNATURE =
ImmutableList.of(
- Pattern.compile("array.*"), // array related functions are not supported
at the moment
- Pattern.compile("st_.*")// all ST GEO features are ignored.
+ private static final List<Pattern> IGNORED_FUNCTION_NAME_PATTERNS =
ImmutableList.of(
+ // Geo functions are defined in pinot-core
+ Pattern.compile("st_.*")
);
private static final List<String> IGNORED_FUNCTION_NAMES = ImmutableList.of(
- // functions we are not supporting post transform anyway
- "valuein", "mapvalue", "inidset", "lookup", "groovy", "scalar",
"geotoh3", "not_in", "timeconvert",
+ // Geo functions are defined in pinot-core
+ "geotoh3",
+ // ArrayToMV and ArrayValueConstructor are placeholder functions without
implementation
+ "arraytomv", "arrayvalueconstructor",
+ // 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",
// functions not needed for register b/c they are in std sql table or
they will not be composed directly.
- "in", "and", "or", "range", "extract", "is_true", "is_not_true",
"is_false", "is_not_false"
+ "in", "not_in", "and", "or", "range", "extract", "is_true",
"is_not_true", "is_false", "is_not_false"
);
@Test
@@ -86,7 +94,7 @@ public class FunctionDefinitionRegistryTest {
if (IGNORED_FUNCTION_NAMES.contains(funcName)) {
return true;
}
- for (Pattern signature : IGNORED_TRANSFORM_FUNCTION_SIGNATURE) {
+ for (Pattern signature : IGNORED_FUNCTION_NAME_PATTERNS) {
if (signature.matcher(funcName).find()) {
return true;
}
diff --git
a/pinot-query-planner/src/main/java/org/apache/calcite/sql/fun/PinotOperatorTable.java
b/pinot-query-planner/src/main/java/org/apache/calcite/sql/fun/PinotOperatorTable.java
index 1a63a6eb07..3617a7c062 100644
---
a/pinot-query-planner/src/main/java/org/apache/calcite/sql/fun/PinotOperatorTable.java
+++
b/pinot-query-planner/src/main/java/org/apache/calcite/sql/fun/PinotOperatorTable.java
@@ -119,9 +119,9 @@ public class PinotOperatorTable extends SqlStdOperatorTable
{
// 2. register special handling that differs from calcite standard.
for (TransformFunctionType transformFunctionType :
TransformFunctionType.values()) {
if (transformFunctionType.getSqlKind() != null) {
- // 1. Register the aggregation function with Calcite
+ // 1. Register the transform function with Calcite
registerTransformFunction(transformFunctionType.getName(),
transformFunctionType);
- // 2. Register the aggregation function with Calcite on all
alternative names
+ // 2. Register the transform function with Calcite on all alternative
names
List<String> alternativeFunctionNames =
transformFunctionType.getAlternativeNames();
for (String alternativeFunctionName : alternativeFunctionNames) {
registerTransformFunction(alternativeFunctionName,
transformFunctionType);
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]