You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by GitBox <gi...@apache.org> on 2021/10/04 20:40:14 UTC

[GitHub] [pinot] Jackie-Jiang commented on a change in pull request #7511: Support JSON queries with top-level array path expression.

Jackie-Jiang commented on a change in pull request #7511:
URL: https://github.com/apache/pinot/pull/7511#discussion_r721701425



##########
File path: pinot-core/src/main/java/org/apache/pinot/core/query/optimizer/statement/JsonStatementOptimizer.java
##########
@@ -387,10 +387,27 @@ private static void optimizeJsonPredicate(Expression expression, @Nullable Table
    *  @return A string array containing all the parts of an identifier. An identifier may have one or more parts that
    *  are joined together using <DOT>. For example the identifier "testTable.jsonColumn.name.first" consists up of
    *  "testTable" (name of table), "jsonColumn" (name of column), "name" (json path), and "first" (json path). The last
-   *  two parts when joined together (name.first) represent a JSON path expression.
+   *  two parts when joined together (name.first) represent a JSON path expression. If an identifier refers to a top-
+   *  level JSON array element (as in column_name[1]), then there is do <DOT> in the identifier.
    */
   private static String[] getIdentifierParts(Identifier identifier) {
-    return StringUtils.split(identifier.getName(), '.');
+    String name = identifier.getName();
+
+    // If identifier represents a top level json object then there must be a '.' in the identifier name.
+    if (name.indexOf('.') != -1) {

Review comment:
       I think we need to check the index of `.` and `[` and pick the one show up the first in order to handle the following cases:
   - `json[0].a` = 1
   - `json.a[0]` = 1
   
   The output should be:
   - `JSON_MATCH(json, '"$[0].a" = 1')`
   - `JSON_MATCH(json, '"$.a[0]" = 1')`
   
   We can always split the identifier into 2 parts, and prefix the second part with `$`




-- 
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: commits-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org