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/11/17 20:23:16 UTC
(pinot) branch master updated: canonicalize SqlKind.OTHERS as well as SqlKind.OTHER_FUNCTIONS (#12025)
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 1d8f2b6366 canonicalize SqlKind.OTHERS as well as SqlKind.OTHER_FUNCTIONS (#12025)
1d8f2b6366 is described below
commit 1d8f2b6366f44f183f2fe3c700a2c897f103b4a5
Author: Rong Rong <ro...@apache.org>
AuthorDate: Fri Nov 17 12:23:10 2023 -0800
canonicalize SqlKind.OTHERS as well as SqlKind.OTHER_FUNCTIONS (#12025)
Co-authored-by: Rong Rong <ro...@startree.ai>
---
.../org/apache/pinot/query/parser/CalciteRexExpressionParser.java | 8 ++++++--
.../src/test/resources/queries/StringFunctions.json | 2 ++
2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/pinot-query-planner/src/main/java/org/apache/pinot/query/parser/CalciteRexExpressionParser.java b/pinot-query-planner/src/main/java/org/apache/pinot/query/parser/CalciteRexExpressionParser.java
index cca1f4a71a..e496b06691 100644
--- a/pinot-query-planner/src/main/java/org/apache/pinot/query/parser/CalciteRexExpressionParser.java
+++ b/pinot-query-planner/src/main/java/org/apache/pinot/query/parser/CalciteRexExpressionParser.java
@@ -56,10 +56,13 @@ public class CalciteRexExpressionParser {
static {
CANONICAL_NAME_TO_SPECIAL_KEY_MAP = new HashMap<>();
+ // adding filter kind special handling
for (FilterKind filterKind : FilterKind.values()) {
CANONICAL_NAME_TO_SPECIAL_KEY_MAP.put(RequestUtils.canonicalizeFunctionName(filterKind.name()),
filterKind.name());
}
+ // adding SqlKind.OTHERS and SqlKind.OTHER_FUNCTIONS that have canonical names.
+ CANONICAL_NAME_TO_SPECIAL_KEY_MAP.put("||", "concat");
}
private CalciteRexExpressionParser() {
@@ -223,12 +226,13 @@ public class CalciteRexExpressionParser {
return compileAndExpression(rexCall, pinotQuery);
case OR:
return compileOrExpression(rexCall, pinotQuery);
+ case OTHER:
case OTHER_FUNCTION:
- functionName = rexCall.getFunctionName();
+ functionName = canonicalizeFunctionName(rexCall.getFunctionName());
// Special handle for leaf stage multi-value columns, as the default behavior for filter and group by is not
// sql standard, so need to use `array_to_mv` to convert the array to v1 multi-value column for behavior
// consistency meanwhile not violating the sql standard.
- if (ARRAY_TO_MV_FUNCTION_NAME.equals(canonicalizeFunctionName(functionName))) {
+ if (ARRAY_TO_MV_FUNCTION_NAME.equals(functionName)) {
return toExpression(rexCall.getFunctionOperands().get(0), pinotQuery);
}
break;
diff --git a/pinot-query-runtime/src/test/resources/queries/StringFunctions.json b/pinot-query-runtime/src/test/resources/queries/StringFunctions.json
index 157c70739a..57898e5abc 100644
--- a/pinot-query-runtime/src/test/resources/queries/StringFunctions.json
+++ b/pinot-query-runtime/src/test/resources/queries/StringFunctions.json
@@ -30,6 +30,8 @@
"comment": "standard sql concat is vararg, while we treat the third input as a separator",
"sql": "SELECT concat(strCol, strCol, ',') FROM {stringTbl}"
},
+ { "sql": "SELECT strCol || strCol FROM {stringTbl}" },
+ { "sql": "SELECT strCol || strCol || ',' FROM {stringTbl}"},
{ "sql": "SELECT trim(strCol) FROM {stringTbl}" },
{ "sql": "SELECT lower(strCol), regexp_Replace(strCol, 'e.*o', 'le') FROM {stringTbl}" },
{
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org