Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: display deployment options #3682

Merged
merged 3 commits into from
Jan 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion hybridse/src/case/sql_case.cc
Original file line number Diff line number Diff line change
Expand Up @@ -751,7 +751,7 @@ const std::string SqlCase::case_name() const {
}
bool SqlCase::ExtractInputTableDef(type::TableDef& table,
int32_t input_idx) const {
if (inputs_.size() <= input_idx) {
if (inputs_.size() <= static_cast<size_t>(input_idx)) {
return false;
}
return ExtractInputTableDef(inputs_[input_idx], table);
Expand Down
15 changes: 15 additions & 0 deletions src/cmd/display.h
Original file line number Diff line number Diff line change
Expand Up @@ -586,6 +586,21 @@
sql = boost::regex_replace(sql, boost::regex(pattern_sp), "DEPLOY");
std::string pattern_blank = "(.*)(\\(.*\\) )(BEGIN )(.*)( END;)";
sql = boost::regex_replace(sql, boost::regex(pattern_blank), "$1$4");
if (!sp_info.GetOption()->empty()) {
std::stringstream ss;
ss << " OPTIONS(";
for (auto iter = sp_info.GetOption()->begin(); iter != sp_info.GetOption()->end(); iter++) {
if (iter != sp_info.GetOption()->begin()) {
ss << ", ";

Check warning on line 594 in src/cmd/display.h

View check run for this annotation

Codecov / codecov/patch

src/cmd/display.h#L589-L594

Added lines #L589 - L594 were not covered by tests
}
ss << absl::AsciiStrToUpper(iter->first) << "=\"" << iter->second << "\"";

Check warning on line 596 in src/cmd/display.h

View check run for this annotation

Codecov / codecov/patch

src/cmd/display.h#L596

Added line #L596 was not covered by tests
}
ss << ")";
std::string prefix = absl::StrCat("DEPLOY ", sp_info.GetSpName());
absl::string_view old_sql = sql;
old_sql.remove_prefix(prefix.size());
sql = absl::StrCat(prefix, ss.str(), old_sql);

Check warning on line 602 in src/cmd/display.h

View check run for this annotation

Codecov / codecov/patch

src/cmd/display.h#L598-L602

Added lines #L598 - L602 were not covered by tests
}
}

PrintItemTable({"DB", type_name}, {vec}, stream);
Expand Down
12 changes: 9 additions & 3 deletions src/sdk/sql_cluster_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -121,13 +121,19 @@ TEST_F(SQLClusterDDLTest, TestShowAndDropDeployment) {

router->ExecuteSQL(db, "deploy " + deploy_name + " select col1 from " + table_name + ";", &status);
ASSERT_TRUE(status.IsOK());
router->ExecuteSQL(db2, "deploy " + deploy_name + " select col1 from " + db + "." + table_name + ";", &status);
std::string sql = absl::StrCat("deploy ", deploy_name,
" OPTIONS(RANGE_BIAS=\"inf\", ROWS_BIAS=\"inf\") select col1 from ", db, ".", table_name, ";");
router->ExecuteSQL(db2, sql, &status);
ASSERT_TRUE(status.IsOK());

router->ExecuteSQL(db, "show deployment " + deploy_name + ";", &status);
auto rs = router->ExecuteSQL(db, "show deployment " + deploy_name + ";", &status);
ASSERT_TRUE(status.IsOK());
router->ExecuteSQL(db, "show deployment " + db2 + "." + deploy_name + ";", &status);
ASSERT_TRUE(rs->Next());
ASSERT_TRUE(rs->GetStringUnsafe(0).find("OPTIONS") == std::string::npos);
rs = router->ExecuteSQL(db, "show deployment " + db2 + "." + deploy_name + ";", &status);
ASSERT_TRUE(status.IsOK());
ASSERT_TRUE(rs->Next());
ASSERT_TRUE(rs->GetStringUnsafe(0).find("OPTIONS(RANGE_BIAS=\"inf\", ROWS_BIAS=\"inf\")") != std::string::npos);

router->ExecuteSQL(db, "drop deployment " + deploy_name + ";", &status);
ASSERT_TRUE(status.IsOK());
Expand Down
Loading