You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@druid.apache.org by GitBox <gi...@apache.org> on 2022/03/02 05:48:49 UTC

[GitHub] [druid] FrankChen021 commented on a change in pull request #12177: introduce a "tree" type to the flattenSpec

FrankChen021 commented on a change in pull request #12177:
URL: https://github.com/apache/druid/pull/12177#discussion_r817366947



##########
File path: core/src/main/java/org/apache/druid/java/util/common/parsers/JSONFlattenerMaker.java
##########
@@ -108,6 +108,22 @@ public Object getRootField(final JsonNode obj, final String key)
     }
   }
 
+  @Override
+  public Function<JsonNode, Object> makeJsonTreeExtractor(final List<String> nodes)
+  {
+    String[] keyNames = nodes.toArray(new String[0]);
+    return jsonNode -> {
+      JsonNode targetNode = jsonNode;
+      for (String keyName : keyNames) {
+        targetNode = targetNode.get(keyName);
+        if (targetNode == null) {
+          break;

Review comment:
       We can directly return null here.




-- 
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@druid.apache.org

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



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