You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by ro...@apache.org on 2023/02/16 01:16:11 UTC
[pinot] branch master updated: Add name case for ScalarFunction annotation for casewhen (#10266)
This is an automated email from the ASF dual-hosted git repository.
rongr 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 02cb2d4970 Add name case for ScalarFunction annotation for casewhen (#10266)
02cb2d4970 is described below
commit 02cb2d4970c71a2ea5b4c140a860fbf220e11bd3
Author: andiem-bq <67...@users.noreply.github.com>
AuthorDate: Wed Feb 15 17:16:03 2023 -0800
Add name case for ScalarFunction annotation for casewhen (#10266)
* Add annotation case for casewhen
* Add @Nullable annotations
---
.../common/function/scalar/ObjectFunctions.java | 32 ++++++++++++++--------
.../function/FunctionDefinitionRegistryTest.java | 4 +--
2 files changed, 22 insertions(+), 14 deletions(-)
diff --git a/pinot-common/src/main/java/org/apache/pinot/common/function/scalar/ObjectFunctions.java b/pinot-common/src/main/java/org/apache/pinot/common/function/scalar/ObjectFunctions.java
index 143edd740f..5cdc0b34d2 100644
--- a/pinot-common/src/main/java/org/apache/pinot/common/function/scalar/ObjectFunctions.java
+++ b/pinot-common/src/main/java/org/apache/pinot/common/function/scalar/ObjectFunctions.java
@@ -94,33 +94,41 @@ public class ObjectFunctions {
return null;
}
- @ScalarFunction
- public static Object caseWhen(boolean c1, Object o1, Object oe) {
+ @Nullable
+ @ScalarFunction(nullableParameters = true, names = {"case", "caseWhen", "case_when"})
+ public static Object caseWhen(boolean c1, @Nullable Object o1, @Nullable Object oe) {
return caseWhenVar(c1, o1, oe);
}
- @ScalarFunction
- public static Object caseWhen(boolean c1, Object o1, boolean c2, Object o2, Object oe) {
+ @Nullable
+ @ScalarFunction(nullableParameters = true, names = {"case", "caseWhen", "case_when"})
+ public static Object caseWhen(boolean c1, @Nullable Object o1, boolean c2, @Nullable Object o2, @Nullable Object oe) {
return caseWhenVar(c1, o1, c2, o2, oe);
}
- @ScalarFunction
- public static Object caseWhen(boolean c1, Object o1, boolean c2, Object o2, boolean c3, Object o3, Object oe) {
+ @Nullable
+ @ScalarFunction(nullableParameters = true, names = {"case", "caseWhen", "case_when"})
+ public static Object caseWhen(boolean c1, @Nullable Object o1, boolean c2, @Nullable Object o2, boolean c3,
+ @Nullable Object o3, @Nullable Object oe) {
return caseWhenVar(c1, o1, c2, o2, c3, o3, oe);
}
- @ScalarFunction
- public static Object caseWhen(boolean c1, Object o1, boolean c2, Object o2, boolean c3, Object o3, boolean c4,
- Object o4, Object oe) {
+ @Nullable
+ @ScalarFunction(nullableParameters = true, names = {"case", "caseWhen", "case_when"})
+ public static Object caseWhen(boolean c1, @Nullable Object o1, boolean c2, @Nullable Object o2, boolean c3,
+ @Nullable Object o3, boolean c4, @Nullable Object o4, @Nullable Object oe) {
return caseWhenVar(c1, o1, c2, o2, c3, o3, c4, o4, oe);
}
- @ScalarFunction
- public static Object caseWhen(boolean c1, Object o1, boolean c2, Object o2, boolean c3, Object o3, boolean c4,
- Object o4, boolean c5, Object o5, Object oe) {
+ @Nullable
+ @ScalarFunction(nullableParameters = true, names = {"case", "caseWhen", "case_when"})
+ public static Object caseWhen(boolean c1, @Nullable Object o1, boolean c2, @Nullable Object o2, boolean c3,
+ @Nullable Object o3, boolean c4, @Nullable Object o4, boolean c5, @Nullable Object o5,
+ @Nullable Object oe) {
return caseWhenVar(c1, o1, c2, o2, c3, o3, c4, o4, c5, o5, oe);
}
+ @Nullable
private static Object caseWhenVar(Object... objs) {
for (int i = 0; i < objs.length - 1; i += 2) {
if (BooleanUtils.toBoolean(objs[i])) {
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 f473a01011..1055ff2e38 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
@@ -42,9 +42,9 @@ public class FunctionDefinitionRegistryTest {
);
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", "case", "not_in", "timeconvert",
+ "valuein", "mapvalue", "inidset", "lookup", "groovy", "scalar", "geotoh3", "not_in", "timeconvert",
// functions not needed for register b/c they are in std sql table or they will not be composed directly.
- "in", "and", "or", "not", "range", "extract"
+ "in", "and", "or", "range", "extract"
);
@Test
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org