richardstartin commented on a change in pull request #8341:
URL: https://github.com/apache/pinot/pull/8341#discussion_r825270669



##########
File path: 
pinot-common/src/main/java/org/apache/pinot/sql/parsers/CalciteSqlParser.java
##########
@@ -757,6 +757,23 @@ private static Expression 
compileFunctionExpression(SqlBasicCall functionNode) {
     }
   }
 
+  private static final Map<String, FilterKind> 
CANONICAL_NAME_TO_FILTER_KIND_MAP = new HashMap<String, FilterKind>() {{
+    for (FilterKind filterKind : FilterKind.values()) {
+      put(StringUtils.remove(filterKind.name(), '_'), filterKind);
+    }
+  }};
+
+  /**
+   * Converts the function name into its canonical form, but keeps 
FilterKind.name() as is if the function name matches
+   * it. We need to keep the FilterKind.name() as is because we might need to 
read the FilterKind via
+   * FilterKind.valueOf().
+   */
+  private static String canonicalize(String functionName) {
+    String canonicalName = StringUtils.remove(functionName, '_').toUpperCase();
+    FilterKind filterKind = 
CANONICAL_NAME_TO_FILTER_KIND_MAP.get(canonicalName);
+    return filterKind != null ? filterKind.name() : canonicalName;

Review comment:
       Basically this lookup could work for more forms if the name - [upper 
case, lower case] x [camel case, snake case, pascal case, none] and unless the 
user writes something like jSoNExTrACTScALaR the resolution wouldn’t need to 
allocate.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to