github-actions[bot] commented on code in PR #38746:
URL: https://github.com/apache/doris/pull/38746#discussion_r1708600444
##########
be/src/exec/schema_scanner/schema_table_options_scanner.cpp:
##########
@@ -127,7 +164,9 @@
RETURN_IF_ERROR(mblock.add_rows(_tableoptions_block.get(), _row_idx,
current_batch_rows));
_row_idx += current_batch_rows;
- *eos = _row_idx == _total_rows;
+ if (checkAndMarkEos(eos) == false) {
Review Comment:
warning: redundant boolean literal supplied to boolean operator
[readability-simplify-boolean-expr]
```suggestion
if (!checkAndMarkEos(eos)) {
```
##########
be/src/exec/schema_scanner/schema_table_properties_scanner.cpp:
##########
@@ -0,0 +1,171 @@
+// 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 "exec/schema_scanner/schema_table_properties_scanner.h"
+
+#include "exec/schema_scanner/schema_helper.h"
+#include "runtime/client_cache.h"
+#include "runtime/exec_env.h"
+#include "runtime/runtime_state.h"
+#include "util/thrift_rpc_helper.h"
+#include "vec/common/string_ref.h"
+#include "vec/core/block.h"
+#include "vec/data_types/data_type_factory.hpp"
+
+namespace doris {
+std::vector<SchemaScanner::ColumnDesc>
SchemaTablePropertiesScanner::_s_tbls_columns = {
+ {"TABLE_CATALOG", TYPE_VARCHAR, sizeof(StringRef), true},
+ {"TABLE_SCHEMA", TYPE_VARCHAR, sizeof(StringRef), true},
+ {"TABLE_NAME", TYPE_VARCHAR, sizeof(StringRef), true},
+ {"PROPERTY_NAME", TYPE_STRING, sizeof(StringRef), true},
+ {"PROPERTY_VALUE", TYPE_STRING, sizeof(StringRef), true},
+};
+
+SchemaTablePropertiesScanner::SchemaTablePropertiesScanner()
Review Comment:
warning: use '= default' to define a trivial default constructor
[modernize-use-equals-default]
be/src/exec/schema_scanner/schema_table_properties_scanner.cpp:38:
```diff
- : SchemaScanner(_s_tbls_columns,
TSchemaTableType::SCH_TABLE_PROPERTIES) {}
+ : SchemaScanner(_s_tbls_columns,
TSchemaTableType::SCH_TABLE_PROPERTIES) = default;
```
##########
be/src/exec/schema_scanner/schema_table_options_scanner.h:
##########
@@ -16,6 +16,7 @@
// under the License.
#pragma once
+#include <gen_cpp/FrontendService_types.h>
Review Comment:
warning: 'gen_cpp/FrontendService_types.h' file not found
[clang-diagnostic-error]
```cpp
#include <gen_cpp/FrontendService_types.h>
^
```
##########
be/src/exec/schema_scanner/schema_table_options_scanner.cpp:
##########
@@ -103,6 +126,17 @@ Status SchemaTableOptionsScanner::get_block_from_fe() {
return Status::OK();
}
+bool SchemaTableOptionsScanner::checkAndMarkEos(bool* eos) {
Review Comment:
warning: method 'checkAndMarkEos' can be made const
[readability-make-member-function-const]
```suggestion
bool SchemaTableOptionsScanner::checkAndMarkEos(bool* eos) const {
```
be/src/exec/schema_scanner/schema_table_options_scanner.h:45:
```diff
- bool checkAndMarkEos(bool* eos);
+ bool checkAndMarkEos(bool* eos) const;
```
##########
be/src/exec/schema_scanner/schema_table_properties_scanner.cpp:
##########
@@ -0,0 +1,171 @@
+// 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 "exec/schema_scanner/schema_table_properties_scanner.h"
+
+#include "exec/schema_scanner/schema_helper.h"
+#include "runtime/client_cache.h"
+#include "runtime/exec_env.h"
+#include "runtime/runtime_state.h"
+#include "util/thrift_rpc_helper.h"
+#include "vec/common/string_ref.h"
+#include "vec/core/block.h"
+#include "vec/data_types/data_type_factory.hpp"
+
+namespace doris {
+std::vector<SchemaScanner::ColumnDesc>
SchemaTablePropertiesScanner::_s_tbls_columns = {
+ {"TABLE_CATALOG", TYPE_VARCHAR, sizeof(StringRef), true},
+ {"TABLE_SCHEMA", TYPE_VARCHAR, sizeof(StringRef), true},
+ {"TABLE_NAME", TYPE_VARCHAR, sizeof(StringRef), true},
+ {"PROPERTY_NAME", TYPE_STRING, sizeof(StringRef), true},
+ {"PROPERTY_VALUE", TYPE_STRING, sizeof(StringRef), true},
+};
+
+SchemaTablePropertiesScanner::SchemaTablePropertiesScanner()
+ : SchemaScanner(_s_tbls_columns,
TSchemaTableType::SCH_TABLE_PROPERTIES) {}
+
+Status SchemaTablePropertiesScanner::start(RuntimeState* state) {
+ if (!_is_init) {
+ return Status::InternalError("used before initialized.");
+ }
+
+ // first get the all the database specific to current catalog
+ SCOPED_TIMER(_get_db_timer);
+ TGetDbsParams db_params;
+
+ if (_param->common_param->catalog) {
+ db_params.__set_catalog(*(_param->common_param->catalog));
+ }
+ if (_param->common_param->current_user_ident) {
+
db_params.__set_current_user_ident(*(_param->common_param->current_user_ident));
+ }
+
+ if (_param->common_param->ip && 0 != _param->common_param->port) {
+ RETURN_IF_ERROR(SchemaHelper::get_db_names(
+ *(_param->common_param->ip), _param->common_param->port,
db_params, &_db_result));
+ } else {
+ return Status::InternalError("IP or port doesn't exists");
+ }
+ _block_rows_limit = state->batch_size();
+ _rpc_timeout_ms = state->execution_timeout() * 1000;
+
+ return Status::OK();
+}
+
+Status SchemaTablePropertiesScanner::get_onedb_info_from_fe(int64_t dbId) {
+ TNetworkAddress master_addr =
ExecEnv::GetInstance()->master_info()->network_address;
+
+ TSchemaTableRequestParams schema_table_request_params;
+ for (int i = 0; i < _s_tbls_columns.size(); i++) {
+ schema_table_request_params.__isset.columns_name = true;
+
schema_table_request_params.columns_name.emplace_back(_s_tbls_columns[i].name);
+ }
+
+
schema_table_request_params.__set_current_user_ident(*_param->common_param->current_user_ident);
+ schema_table_request_params.__set_catalog(*_param->common_param->catalog);
+ schema_table_request_params.__set_dbId(dbId);
+
+ TFetchSchemaTableDataRequest request;
+ request.__set_schema_table_name(TSchemaTableName::TABLE_PROPERTIES);
+ request.__set_schema_table_params(schema_table_request_params);
+
+ TFetchSchemaTableDataResult result;
+
+ RETURN_IF_ERROR(ThriftRpcHelper::rpc<FrontendServiceClient>(
+ master_addr.hostname, master_addr.port,
+ [&request, &result](FrontendServiceConnection& client) {
+ client->fetchSchemaTableData(result, request);
+ },
+ _rpc_timeout_ms));
+
+ Status status(Status::create(result.status));
+ if (!status.ok()) {
+ LOG(WARNING) << "fetch table options from FE failed, errmsg=" <<
status;
+ return status;
+ }
+ std::vector<TRow> result_data = result.data_batch;
+
+ _tableproperties_block = vectorized::Block::create_unique();
+ for (int i = 0; i < _s_tbls_columns.size(); ++i) {
+ TypeDescriptor descriptor(_s_tbls_columns[i].type);
+ auto data_type =
vectorized::DataTypeFactory::instance().create_data_type(descriptor, true);
+ _tableproperties_block->insert(vectorized::ColumnWithTypeAndName(
+ data_type->create_column(), data_type,
_s_tbls_columns[i].name));
+ }
+ _tableproperties_block->reserve(_block_rows_limit);
+ if (result_data.size() > 0) {
+ int col_size = result_data[0].column_value.size();
+ if (col_size != _s_tbls_columns.size()) {
+ return Status::InternalError<false>("table options schema is not
match for FE and BE");
+ }
+ }
+
+ for (int i = 0; i < result_data.size(); i++) {
+ TRow row = result_data[i];
+ for (int j = 0; j < _s_tbls_columns.size(); j++) {
+ RETURN_IF_ERROR(insert_block_column(
+ row.column_value[j], j, _tableproperties_block.get(),
_s_tbls_columns[j].type));
+ }
+ }
+ return Status::OK();
+}
+
+bool SchemaTablePropertiesScanner::checkAndMarkEos(bool* eos) {
Review Comment:
warning: method 'checkAndMarkEos' can be made const
[readability-make-member-function-const]
```suggestion
bool SchemaTablePropertiesScanner::checkAndMarkEos(bool* eos) const {
```
be/src/exec/schema_scanner/schema_table_properties_scanner.h:45:
```diff
- bool checkAndMarkEos(bool* eos);
+ bool checkAndMarkEos(bool* eos) const;
```
##########
be/src/exec/schema_scanner/schema_table_properties_scanner.h:
##########
@@ -0,0 +1,55 @@
+// 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 <gen_cpp/FrontendService_types.h>
Review Comment:
warning: 'gen_cpp/FrontendService_types.h' file not found
[clang-diagnostic-error]
```cpp
#include <gen_cpp/FrontendService_types.h>
^
```
##########
be/src/exec/schema_scanner/schema_table_properties_scanner.cpp:
##########
@@ -0,0 +1,171 @@
+// 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 "exec/schema_scanner/schema_table_properties_scanner.h"
+
+#include "exec/schema_scanner/schema_helper.h"
+#include "runtime/client_cache.h"
+#include "runtime/exec_env.h"
+#include "runtime/runtime_state.h"
+#include "util/thrift_rpc_helper.h"
+#include "vec/common/string_ref.h"
+#include "vec/core/block.h"
+#include "vec/data_types/data_type_factory.hpp"
+
+namespace doris {
+std::vector<SchemaScanner::ColumnDesc>
SchemaTablePropertiesScanner::_s_tbls_columns = {
+ {"TABLE_CATALOG", TYPE_VARCHAR, sizeof(StringRef), true},
+ {"TABLE_SCHEMA", TYPE_VARCHAR, sizeof(StringRef), true},
+ {"TABLE_NAME", TYPE_VARCHAR, sizeof(StringRef), true},
+ {"PROPERTY_NAME", TYPE_STRING, sizeof(StringRef), true},
+ {"PROPERTY_VALUE", TYPE_STRING, sizeof(StringRef), true},
+};
+
+SchemaTablePropertiesScanner::SchemaTablePropertiesScanner()
+ : SchemaScanner(_s_tbls_columns,
TSchemaTableType::SCH_TABLE_PROPERTIES) {}
+
+Status SchemaTablePropertiesScanner::start(RuntimeState* state) {
+ if (!_is_init) {
+ return Status::InternalError("used before initialized.");
+ }
+
+ // first get the all the database specific to current catalog
+ SCOPED_TIMER(_get_db_timer);
+ TGetDbsParams db_params;
+
+ if (_param->common_param->catalog) {
+ db_params.__set_catalog(*(_param->common_param->catalog));
+ }
+ if (_param->common_param->current_user_ident) {
+
db_params.__set_current_user_ident(*(_param->common_param->current_user_ident));
+ }
+
+ if (_param->common_param->ip && 0 != _param->common_param->port) {
+ RETURN_IF_ERROR(SchemaHelper::get_db_names(
+ *(_param->common_param->ip), _param->common_param->port,
db_params, &_db_result));
+ } else {
+ return Status::InternalError("IP or port doesn't exists");
+ }
+ _block_rows_limit = state->batch_size();
+ _rpc_timeout_ms = state->execution_timeout() * 1000;
+
+ return Status::OK();
+}
+
+Status SchemaTablePropertiesScanner::get_onedb_info_from_fe(int64_t dbId) {
+ TNetworkAddress master_addr =
ExecEnv::GetInstance()->master_info()->network_address;
+
+ TSchemaTableRequestParams schema_table_request_params;
+ for (int i = 0; i < _s_tbls_columns.size(); i++) {
+ schema_table_request_params.__isset.columns_name = true;
+
schema_table_request_params.columns_name.emplace_back(_s_tbls_columns[i].name);
+ }
+
+
schema_table_request_params.__set_current_user_ident(*_param->common_param->current_user_ident);
+ schema_table_request_params.__set_catalog(*_param->common_param->catalog);
+ schema_table_request_params.__set_dbId(dbId);
+
+ TFetchSchemaTableDataRequest request;
+ request.__set_schema_table_name(TSchemaTableName::TABLE_PROPERTIES);
+ request.__set_schema_table_params(schema_table_request_params);
+
+ TFetchSchemaTableDataResult result;
+
+ RETURN_IF_ERROR(ThriftRpcHelper::rpc<FrontendServiceClient>(
+ master_addr.hostname, master_addr.port,
+ [&request, &result](FrontendServiceConnection& client) {
+ client->fetchSchemaTableData(result, request);
+ },
+ _rpc_timeout_ms));
+
+ Status status(Status::create(result.status));
+ if (!status.ok()) {
+ LOG(WARNING) << "fetch table options from FE failed, errmsg=" <<
status;
+ return status;
+ }
+ std::vector<TRow> result_data = result.data_batch;
+
+ _tableproperties_block = vectorized::Block::create_unique();
+ for (int i = 0; i < _s_tbls_columns.size(); ++i) {
+ TypeDescriptor descriptor(_s_tbls_columns[i].type);
+ auto data_type =
vectorized::DataTypeFactory::instance().create_data_type(descriptor, true);
+ _tableproperties_block->insert(vectorized::ColumnWithTypeAndName(
+ data_type->create_column(), data_type,
_s_tbls_columns[i].name));
+ }
+ _tableproperties_block->reserve(_block_rows_limit);
+ if (result_data.size() > 0) {
+ int col_size = result_data[0].column_value.size();
+ if (col_size != _s_tbls_columns.size()) {
+ return Status::InternalError<false>("table options schema is not
match for FE and BE");
+ }
+ }
+
+ for (int i = 0; i < result_data.size(); i++) {
+ TRow row = result_data[i];
+ for (int j = 0; j < _s_tbls_columns.size(); j++) {
+ RETURN_IF_ERROR(insert_block_column(
+ row.column_value[j], j, _tableproperties_block.get(),
_s_tbls_columns[j].type));
+ }
+ }
+ return Status::OK();
+}
+
+bool SchemaTablePropertiesScanner::checkAndMarkEos(bool* eos) {
+ if (_row_idx == _total_rows) {
+ *eos = true;
+ if (_db_index < _db_result.db_ids.size()) {
+ *eos = false;
+ }
+ return true;
+ }
+ return false;
+}
+
+Status
SchemaTablePropertiesScanner::get_next_block_internal(vectorized::Block* block,
bool* eos) {
+ if (!_is_init) {
+ return Status::InternalError("Used before initialized.");
+ }
+
+ if (nullptr == block || nullptr == eos) {
+ return Status::InternalError("input pointer is nullptr.");
+ }
+
+ if ((_tableproperties_block == nullptr) || (_row_idx == _total_rows)) {
+ if (_db_index < _db_result.db_ids.size()) {
+
RETURN_IF_ERROR(get_onedb_info_from_fe(_db_result.db_ids[_db_index]));
+ _row_idx = 0; // reset row index so that it start filling for next
block.
+ _total_rows = _tableproperties_block->rows();
+ _db_index++;
+ }
+ }
+
+ if (checkAndMarkEos(eos)) {
+ return Status::OK();
+ }
+
+ int current_batch_rows = std::min(_block_rows_limit, _total_rows -
_row_idx);
+ vectorized::MutableBlock mblock =
vectorized::MutableBlock::build_mutable_block(block);
+ RETURN_IF_ERROR(mblock.add_rows(_tableproperties_block.get(), _row_idx,
current_batch_rows));
+ _row_idx += current_batch_rows;
+
+ if (checkAndMarkEos(eos) == false) {
Review Comment:
warning: redundant boolean literal supplied to boolean operator
[readability-simplify-boolean-expr]
```suggestion
if (!checkAndMarkEos(eos)) {
```
--
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]