github-actions[bot] commented on code in PR #37378:
URL: https://github.com/apache/doris/pull/37378#discussion_r1667574451


##########
be/src/vec/exprs/table_function/vexplode_json_object.cpp:
##########
@@ -0,0 +1,160 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#include "vec/exprs/table_function/vexplode_json_object.h"
+
+#include <glog/logging.h>
+
+#include <ostream>
+#include <vector>
+
+#include "common/status.h"
+#include "vec/columns/column.h"
+#include "vec/common/string_ref.h"
+#include "vec/core/block.h"
+#include "vec/core/column_with_type_and_name.h"
+#include "vec/exprs/vexpr.h"
+#include "vec/exprs/vexpr_context.h"
+
+namespace doris::vectorized {
+
+VExplodeJsonObjectTableFunction::VExplodeJsonObjectTableFunction() {

Review Comment:
   warning: use '= default' to define a trivial default constructor 
[modernize-use-equals-default]
   ```cpp
   VExplodeJsonObjectTableFunction::VExplodeJsonObjectTableFunction() {
                                    ^
   ```
   



##########
be/src/vec/exprs/table_function/vexplode_json_object.cpp:
##########
@@ -0,0 +1,160 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#include "vec/exprs/table_function/vexplode_json_object.h"
+
+#include <glog/logging.h>
+
+#include <ostream>
+#include <vector>
+
+#include "common/status.h"
+#include "vec/columns/column.h"
+#include "vec/common/string_ref.h"
+#include "vec/core/block.h"
+#include "vec/core/column_with_type_and_name.h"
+#include "vec/exprs/vexpr.h"
+#include "vec/exprs/vexpr_context.h"
+
+namespace doris::vectorized {
+
+VExplodeJsonObjectTableFunction::VExplodeJsonObjectTableFunction() {
+    _fn_name = "vexplode_json_object";
+}
+
+Status VExplodeJsonObjectTableFunction::process_init(Block* block, 
RuntimeState* state) {
+    CHECK(_expr_context->root()->children().size() == 1)
+            << "VExplodeJsonObjectTableFunction only support 1 child but has "
+            << _expr_context->root()->children().size();
+
+    int text_column_idx = -1;
+    
RETURN_IF_ERROR(_expr_context->root()->children()[0]->execute(_expr_context.get(),
 block,
+                                                                  
&text_column_idx));
+
+    _json_object_column = block->get_by_position(text_column_idx).column;
+    return Status::OK();
+}
+
+void VExplodeJsonObjectTableFunction::process_row(size_t row_idx) {
+    TableFunction::process_row(row_idx);
+
+    StringRef text = _json_object_column->get_data_at(row_idx);
+    if (text.data != nullptr) {
+        JsonbDocument* doc = JsonbDocument::createDocument(text.data, 
text.size);
+        if (UNLIKELY(!doc || !doc->getValue())) {
+            // error jsonb, put null into output, cur_size = 0 , we will 
insert_default
+            return;
+        }
+        // value is NOT necessary to be deleted since JsonbValue will not 
allocate memory
+        JsonbValue* value = doc->getValue();
+        auto writer = std::make_unique<JsonbWriter>();
+        if (value->isObject()) {
+            _cur_size = value->length();
+            ObjectVal* obj = (ObjectVal*)value;

Review Comment:
   warning: use auto when initializing with a cast to avoid duplicating the 
type name [modernize-use-auto]
   
   ```suggestion
               auto* obj = (ObjectVal*)value;
   ```
   



##########
be/src/vec/exprs/table_function/vexplode_json_object.cpp:
##########
@@ -0,0 +1,160 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#include "vec/exprs/table_function/vexplode_json_object.h"
+
+#include <glog/logging.h>
+
+#include <ostream>
+#include <vector>
+
+#include "common/status.h"
+#include "vec/columns/column.h"
+#include "vec/common/string_ref.h"
+#include "vec/core/block.h"
+#include "vec/core/column_with_type_and_name.h"
+#include "vec/exprs/vexpr.h"
+#include "vec/exprs/vexpr_context.h"
+
+namespace doris::vectorized {
+
+VExplodeJsonObjectTableFunction::VExplodeJsonObjectTableFunction() {
+    _fn_name = "vexplode_json_object";
+}
+
+Status VExplodeJsonObjectTableFunction::process_init(Block* block, 
RuntimeState* state) {
+    CHECK(_expr_context->root()->children().size() == 1)
+            << "VExplodeJsonObjectTableFunction only support 1 child but has "
+            << _expr_context->root()->children().size();
+
+    int text_column_idx = -1;
+    
RETURN_IF_ERROR(_expr_context->root()->children()[0]->execute(_expr_context.get(),
 block,
+                                                                  
&text_column_idx));
+
+    _json_object_column = block->get_by_position(text_column_idx).column;
+    return Status::OK();
+}
+
+void VExplodeJsonObjectTableFunction::process_row(size_t row_idx) {
+    TableFunction::process_row(row_idx);
+
+    StringRef text = _json_object_column->get_data_at(row_idx);
+    if (text.data != nullptr) {
+        JsonbDocument* doc = JsonbDocument::createDocument(text.data, 
text.size);
+        if (UNLIKELY(!doc || !doc->getValue())) {

Review Comment:
   warning: boolean expression can be simplified by DeMorgan's theorem 
[readability-simplify-boolean-expr]
   ```cpp
           if (UNLIKELY(!doc || !doc->getValue())) {
               ^
   ```
   <details>
   <summary>Additional context</summary>
   
   **be/src/common/compiler_util.h:35:** expanded from macro 'UNLIKELY'
   ```cpp
   #define UNLIKELY(expr) __builtin_expect(!!(expr), 0)
                                            ^
   ```
   
   </details>
   



##########
be/src/vec/exprs/table_function/vexplode_json_object.h:
##########
@@ -0,0 +1,59 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#pragma once
+
+#include <stddef.h>

Review Comment:
   warning: inclusion of deprecated C++ header 'stddef.h'; consider using 
'cstddef' instead [modernize-deprecated-headers]
   
   ```suggestion
   #include <cstddef>
   ```
   



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

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