diff --git a/hybridse/src/case/sql_case.cc b/hybridse/src/case/sql_case.cc index c98defb679b..be0633dc703 100644 --- a/hybridse/src/case/sql_case.cc +++ b/hybridse/src/case/sql_case.cc @@ -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(input_idx)) { return false; } return ExtractInputTableDef(inputs_[input_idx], table); diff --git a/src/cmd/display.h b/src/cmd/display.h index 714a9ca6a73..34e1f851e39 100644 --- a/src/cmd/display.h +++ b/src/cmd/display.h @@ -586,6 +586,21 @@ __attribute__((unused)) static void PrintProcedureInfo( 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 << ", "; + } + ss << absl::AsciiStrToUpper(iter->first) << "=\"" << iter->second << "\""; + } + 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); + } } PrintItemTable({"DB", type_name}, {vec}, stream); diff --git a/src/sdk/sql_cluster_test.cc b/src/sdk/sql_cluster_test.cc index 9374841d71e..c3bb0f08e9d 100644 --- a/src/sdk/sql_cluster_test.cc +++ b/src/sdk/sql_cluster_test.cc @@ -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());