imay commented on a change in pull request #4136:
URL: https://github.com/apache/incubator-doris/pull/4136#discussion_r462260814



##########
File path: docs/en/sql-reference/sql-statements/Data Manipulation/ROUTINE 
LOAD.md
##########
@@ -178,6 +178,9 @@ FROM data_source
     8. `strip_outer_array`
         Boolean type, true to indicate that json data starts with an array 
object and flattens objects in the array object, default value is false.
 
+    9. `json_root`
+        User specifies the JSON root node as the valid JSONPath string.

Review comment:
       What is the json_root default value? Please let others know

##########
File path: be/src/exec/json_scanner.cpp
##########
@@ -197,30 +201,50 @@ JsonReader::~JsonReader() {
     _close();
 }
 
-Status JsonReader::init() {
+Status JsonReader::init(const std::string& jsonpath, const std::string& 
json_root) {
     // parse jsonpath
+    if (!jsonpath.empty()) {
+        Status st = _generate_json_paths(jsonpath, _parsed_jsonpaths);
+        RETURN_IF_ERROR(st);
+    }
+    if (!json_root.empty()) {
+        JsonFunctions::parse_json_paths(json_root, &_parsed_json_root);
+    }
+
+    //improve performance
+    if (_parsed_jsonpaths.empty()) { // input is a simple json-string
+        _handle_json_callback = &JsonReader::_handle_simple_json;
+    } else { // input is a complex json-string and a json-path
+        if (_strip_outer_array) {
+            _handle_json_callback = 
&JsonReader::_handle_flat_array_complex_json;
+        } else {
+            _handle_json_callback = &JsonReader::_handle_nested_complex_json;
+        }
+    }
+    return Status::OK();
+}
+
+Status JsonReader::_generate_json_paths(const std::string& jsonpath, 
std::vector<std::vector<JsonPath>>& vect) {

Review comment:
       ```suggestion
   Status JsonReader::_generate_json_paths(const std::string& jsonpath, 
std::vector<std::vector<JsonPath>>* vect) {
   ```




----------------------------------------------------------------
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.

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



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to