MCPcopy Create free account
hub / github.com/4paradigm/OpenMLDB / BatchRequestExecuteSQLWithCommonColumnIndices

Method BatchRequestExecuteSQLWithCommonColumnIndices

src/sdk/sql_sdk_test.h:559–673  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

557 }
558}
559void SQLSDKQueryTest::BatchRequestExecuteSQLWithCommonColumnIndices(hybridse::sqlcase::SqlCase& sql_case, // NOLINT
560 std::shared_ptr<SQLRouter> router,
561 const std::set<size_t>& common_indices,
562 bool is_procedure, bool is_asyn) {
563 std::ostringstream oss;
564 if (common_indices.empty()) {
565 oss << "empty";
566 } else {
567 for (size_t index : common_indices) {
568 oss << index << ",";
569 }
570 }
571
572 LOG(INFO) << "BatchRequestExecuteSQLWithCommonColumnIndices: " << oss.str();
573 hybridse::sdk::Status status;
574 // execute SQL
575 std::string sql = sql_case.sql_str();
576 for (size_t i = 0; i < sql_case.inputs().size(); i++) {
577 std::string placeholder = "{" + std::to_string(i) + "}";
578 boost::replace_all(sql, placeholder, sql_case.inputs()[i].name_);
579 }
580 boost::replace_all(sql, "{auto}", hybridse::sqlcase::SqlCase::GenRand("auto_t"));
581 LOG(INFO) << sql;
582 std::string lower_sql = sql;
583 boost::to_lower(lower_sql);
584 if (!boost::algorithm::starts_with(lower_sql, "select")) {
585 FAIL() << "sql not support in request mode";
586 }
587
588 auto request_row = router->GetRequestRow(sql_case.db(), sql, &status);
589 LOG(INFO) << "sql case success check: required success " << (sql_case.expect().success_ ? "true" : "false");
590 if (!sql_case.expect().success_) {
591 if ((request_row)) {
592 FAIL() << "sql case expect success == false";
593 }
594 LOG(INFO) << "sql case success false check done!";
595 return;
596 }
597 if (!request_row) {
598 FAIL() << "sql case expect success == true";
599 }
600
601 bool has_batch_request = !sql_case.batch_request().columns_.empty();
602 hybridse::type::TableDef batch_request_table;
603 std::vector<::hybridse::codec::Row> request_rows;
604 auto common_column_indices = std::make_shared<ColumnIndicesSet>(request_row->GetSchema());
605 if (has_batch_request) {
606 auto& batch_request = sql_case.batch_request();
607 ASSERT_TRUE(sql_case.ExtractTableDef(batch_request.columns_, batch_request.indexs_, batch_request_table));
608 ASSERT_TRUE(sql_case.ExtractRows(batch_request_table.columns(), batch_request.rows_, request_rows));
609
610 } else {
611 ASSERT_TRUE(sql_case.ExtractInputTableDef(sql_case.inputs_[0], batch_request_table));
612 std::vector<hybridse::codec::Row> rows;
613 ASSERT_TRUE(sql_case.ExtractInputData(sql_case.inputs_[0], rows));
614 request_rows.push_back(rows.back());
615 }
616 CheckSchema(batch_request_table.columns(), *(request_row->GetSchema().get()));

Callers

nothing calls this directly

Calls 14

to_stringFunction · 0.85
GetRequestRowMethod · 0.80
AddCommonColumnIdxMethod · 0.80
AddRowMethod · 0.80
GenRandFunction · 0.70
emptyMethod · 0.45
sizeMethod · 0.45
GetSchemaMethod · 0.45
getMethod · 0.45
ResetMethod · 0.45

Tested by

no test coverage detected