21 #include <boost/algorithm/string/predicate.hpp>
22 #include <boost/uuid/uuid_generators.hpp>
23 #include <boost/uuid/uuid_io.hpp>
25 #include "rapidjson/document.h"
62 LOG(
INFO) <<
"Vacuum time (alter column data type): " << total_time_ms <<
"ms";
72 throw std::runtime_error(
"Altering column " + colname +
73 " type not allowed. Column type must be TEXT.");
86 for (
const auto& [key, metadata] : column_metadata) {
87 if (is_not_null && metadata->chunkStats.has_nulls) {
88 throw std::runtime_error(
"Alter column type: Column " + cd.
columnName +
89 ": NULL value not allowed in NOT NULL column");
94 throw std::runtime_error(
"Alter column type: Column " + cd.
columnName +
95 ": altering a sharded table is unsupported");
100 std::list<std::pair<const ColumnDescriptor*, std::list<const ColumnDescriptor*>>>
103 const std::list<std::list<ColumnDescriptor>>& phys_cds) {
104 std::list<std::pair<const ColumnDescriptor*, std::list<const ColumnDescriptor*>>>
105 geo_src_dst_column_pairs;
107 auto phys_cds_it = phys_cds.begin();
108 for (
auto& [src_cd, dst_cd] : src_dst_cds) {
109 if (dst_cd->columnType.is_geometry()) {
110 geo_src_dst_column_pairs.emplace_back();
111 auto& pair = geo_src_dst_column_pairs.back();
114 std::list<const ColumnDescriptor*> geo_dst_cds;
115 CHECK(phys_cds_it != phys_cds.end());
116 auto& phy_geo_columns = *phys_cds_it;
117 geo_dst_cds.push_back(dst_cd);
118 for (
const auto& cd : phy_geo_columns) {
119 geo_dst_cds.push_back(&cd);
121 pair.second = geo_dst_cds;
127 return geo_src_dst_column_pairs;
131 std::list<ColumnDescriptor>& src_cds,
132 std::list<ColumnDescriptor>& dst_cds) {
133 CHECK_EQ(src_cds.size(), dst_cds.size());
135 auto src_cd_it = src_cds.begin();
136 auto dst_cd_it = dst_cds.begin();
137 for (; src_cd_it != src_cds.end(); ++src_cd_it, ++dst_cd_it) {
138 src_dst_column_pairs.emplace_back(&(*src_cd_it), &(*dst_cd_it));
140 return src_dst_column_pairs;
143 std::pair<std::list<ColumnDescriptor>, std::list<ColumnDescriptor>>
147 std::list<ColumnDescriptor> src_cds;
148 std::list<ColumnDescriptor> dst_cds;
149 for (
const auto& coldef : columns) {
150 dst_cds.emplace_back();
179 dst_cd.
columnId = catalog_cd->columnId;
180 dst_cd.
tableId = catalog_cd->tableId;
182 dst_cd.
chunks = catalog_cd->chunks;
183 dst_cd.
db_id = catalog_cd->db_id;
188 if (catalog_cd->columnType.is_dict_encoded_type() &&
198 throw std::runtime_error(
"Altering column " + dst_cd.
columnName +
199 " results in no change to column, please review command.");
207 src_cds.emplace_back();
208 src_cds.back() = *catalog_cd;
210 return {src_cds, dst_cds};
213 template <
class LockType>
215 std::unique_ptr<lockmgr::TableSchemaLockContainer<LockType>>>
217 const std::string& table_name,
218 const bool populate_fragmenter) {
219 const TableDescriptor* td{
nullptr};
220 std::unique_ptr<lockmgr::TableSchemaLockContainer<LockType>> td_with_lock =
221 std::make_unique<lockmgr::TableSchemaLockContainer<LockType>>(
223 cat, table_name, populate_fragmenter));
225 td = (*td_with_lock)();
227 return std::make_tuple(td, std::move(td_with_lock));
234 template <
class Func>
238 for (
const auto& table_name : table_names) {
240 auto [td, td_with_lock] =
241 get_table_descriptor_with_lock<lockmgr::ReadLock>(*cat_ptr, table_name,
false);
242 func(td, table_name);
256 : File_Namespace::StorageStats(storage_stats)
257 , min_epoch(storage_stats.epoch)
258 , max_epoch(storage_stats.epoch)
259 , min_epoch_floor(storage_stats.epoch_floor)
260 , max_epoch_floor(storage_stats.epoch_floor) {}
267 if (total_free_metadata_page_count) {
268 total_free_metadata_page_count.value() +=
278 if (total_free_data_page_count) {
279 total_free_data_page_count.value() +=
285 min_epoch = std::min(min_epoch, storage_stats.
epoch);
286 max_epoch = std::max(max_epoch, storage_stats.
epoch);
287 min_epoch_floor = std::min(min_epoch_floor, storage_stats.
epoch_floor);
288 max_epoch_floor = std::max(max_epoch_floor, storage_stats.
epoch_floor);
295 std::optional<AggregratedStorageStats> agg_storage_stats;
300 for (
const auto physical_table : physical_tables) {
301 auto storage_stats = global_file_mgr->getStorageStats(catalog->
getDatabaseId(),
302 physical_table->tableId);
303 if (agg_storage_stats) {
304 agg_storage_stats.value().aggregate(storage_stats);
306 agg_storage_stats = storage_stats;
313 CHECK(agg_storage_stats.has_value());
314 return agg_storage_stats.value();
318 return std::unique_ptr<RexLiteral>(
323 return std::unique_ptr<RexLiteral>(
new RexLiteral(
328 return std::unique_ptr<RexLiteral>(
333 return std::unique_ptr<RexLiteral>(
338 return std::unique_ptr<RexLiteral>(
new RexLiteral(
343 std::vector<TargetMetaInfo>& label_infos,
344 const std::vector<std::tuple<std::string, SQLTypes, bool>>& headers) {
345 for (
const auto&
header : headers) {
346 auto [_val, _type, _notnull] =
header;
348 label_infos.emplace_back(_val,
SQLTypeInfo(_type, _notnull));
350 UNREACHABLE() <<
"Unsupported type provided for header. SQL type: "
357 const TableDescriptor* logical_table,
359 bool is_sharded_table = (logical_table->
nShards > 0);
373 logical_values.back().emplace_back(
375 logical_values.back().emplace_back(
377 logical_values.back().emplace_back(
381 logical_values.back().emplace_back(
388 logical_values.back().emplace_back(
390 logical_values.back().emplace_back(
394 logical_values.back().emplace_back(
410 : ddl_utils::SqlType(getSqlType(data_type),
411 getParam1(data_type),
412 getParam2(data_type),
414 getArraySize(data_type)) {}
417 static SQLTypes getSqlType(
const rapidjson::Value& data_type);
419 static int getParam1(
const rapidjson::Value& data_type);
420 static int getParam2(
const rapidjson::Value& data_type);
421 static bool isArray(
const rapidjson::Value& data_type);
422 static int getArraySize(
const rapidjson::Value& data_type);
428 : ddl_utils::Encoding(getEncodingName(data_type), getEncodingParam(data_type)) {}
431 static std::string* getEncodingName(
const rapidjson::Value& data_type);
432 static int getEncodingParam(
const rapidjson::Value& data_type);
448 const rapidjson::Value& query()
const;
451 const rapidjson::Value& payload()
const;
454 std::string commandStr()
override;
459 DdlCommandDataImpl::DdlCommandDataImpl(
const std::string& ddl_statement)
480 if (
payload.HasMember(
"command") &&
payload[
"command"].IsString()) {
481 return payload[
"command"].GetString();
494 const rapidjson::Value* filters =
nullptr;
495 if (payload.HasMember(
"filters") && payload[
"filters"].IsArray()) {
496 filters = &payload[
"filters"];
503 const std::string& ddl_statement,
504 std::shared_ptr<Catalog_Namespace::SessionInfo const> session_ptr)
505 : session_ptr_(session_ptr) {
506 CHECK(!ddl_statement.empty());
512 DdlCommandDataImpl* ddl_query_data =
new DdlCommandDataImpl(ddl_statement);
513 ddl_data_ = std::unique_ptr<DdlCommandData>(ddl_query_data);
515 VLOG(2) <<
"Parsing JSON DDL from Calcite: " << ddl_statement;
516 auto& ddl_query = ddl_query_data->query();
517 CHECK(ddl_query.IsObject()) << ddl_statement;
518 CHECK(ddl_query.HasMember(
"payload"));
519 CHECK(ddl_query[
"payload"].IsObject());
520 const auto& payload = ddl_query[
"payload"].GetObject();
521 CHECK(payload.HasMember(
"command"));
522 CHECK(payload[
"command"].IsString());
532 create_table_stmt.execute(*
session_ptr_, read_only_mode);
536 create_view_stmt.execute(*
session_ptr_, read_only_mode);
548 rename_table_stmt.execute(*
session_ptr_, read_only_mode);
556 truncate_table_stmt.execute(*
session_ptr_, read_only_mode);
564 restore_table_stmt.execute(*
session_ptr_, read_only_mode);
568 optimize_table_stmt.execute(*
session_ptr_, read_only_mode);
576 export_query_stmt.execute(*
session_ptr_, read_only_mode);
588 create_user_stmt.execute(*
session_ptr_, read_only_mode);
600 rename_user_stmt.execute(*
session_ptr_, read_only_mode);
604 create_role_stmt.execute(*
session_ptr_, read_only_mode);
616 revoke_role_stmt.execute(*
session_ptr_, read_only_mode);
620 grant_privilege_stmt.execute(*
session_ptr_, read_only_mode);
623 auto revoke_privileges_stmt =
625 revoke_privileges_stmt.execute(*
session_ptr_, read_only_mode);
629 create_dataframe_stmt.execute(*
session_ptr_, read_only_mode);
633 create_model_stmt.execute(*
session_ptr_, read_only_mode);
675 }
else if (
ddl_command_ ==
"SHOW_RUNTIME_TABLE_FUNCTIONS") {
682 }
else if (
ddl_command_ ==
"SHOW_MODEL_FEATURE_DETAILS") {
700 throw std::runtime_error(
"Unsupported DDL command");
727 enum SetParameterType { String_t, Numeric_t };
728 static const std::unordered_map<std::string, SetParameterType>
729 session_set_parameters_map = {{
"EXECUTOR_DEVICE", SetParameterType::String_t},
730 {
"CURRENT_DATABASE", SetParameterType::String_t}};
733 CHECK(ddl_payload.HasMember(
"sessionParameter"));
734 CHECK(ddl_payload[
"sessionParameter"].IsString());
735 CHECK(ddl_payload.HasMember(
"parameterValue"));
736 CHECK(ddl_payload[
"parameterValue"].IsString());
737 std::string parameter_name =
to_upper(ddl_payload[
"sessionParameter"].GetString());
738 std::string parameter_value = ddl_payload[
"parameterValue"].GetString();
740 const auto param_it = session_set_parameters_map.find(parameter_name);
741 if (param_it == session_set_parameters_map.end()) {
742 throw std::runtime_error(parameter_name +
" is not a settable session parameter.");
744 if (param_it->second == SetParameterType::Numeric_t) {
745 if (!std::regex_match(parameter_value, std::regex(
"[(-|+)|][0-9]+"))) {
746 throw std::runtime_error(
"The value of session parameter " + param_it->first +
747 " should be a numeric.");
750 return {parameter_name, parameter_value};
756 CHECK(ddl_payload.HasMember(
"cacheType"));
757 CHECK(ddl_payload[
"cacheType"].IsString());
758 return ddl_payload[
"cacheType"].GetString();
762 return (
ddl_command_ ==
"ALTER_SYSTEM_CONTROL_EXECUTOR_QUEUE");
768 CHECK(ddl_payload.HasMember(
"queueAction"));
769 CHECK(ddl_payload[
"queueAction"].IsString());
770 return ddl_payload[
"queueAction"].GetString();
798 CHECK(ddl_payload.HasMember(
"type"));
799 const std::string& targetType = ddl_payload[
"type"].GetString();
800 if (targetType ==
"DASHBOARD") {
818 return execution_details;
826 CHECK(ddl_payload.HasMember(
"querySession"));
827 const std::string& query_session = ddl_payload[
"querySession"].GetString();
829 boost::regex session_id_regex{R
"([0-9]{3}-[a-zA-Z0-9]{4})",
830 boost::regex::extended | boost::regex::icase};
831 if (!boost::regex_match(query_session, session_id_regex)) {
832 throw std::runtime_error(
833 "Please provide the correct session ID of the query that you want to interrupt.");
835 return query_session;
848 [&server_name](
const std::string& reserved_prefix) {
849 return boost::istarts_with(server_name, reserved_prefix);
854 std::string error_message{
"Foreign server names cannot start with "};
857 error_message +=
", ";
860 error_message +=
"or ";
864 error_message +=
".";
865 throw std::runtime_error{error_message};
871 std::shared_ptr<Catalog_Namespace::SessionInfo const> session_ptr)
874 throw std::runtime_error(
"Unsupported command: CREATE FOREIGN SERVER");
877 CHECK(ddl_payload.HasMember(
"serverName"));
878 CHECK(ddl_payload[
"serverName"].IsString());
879 CHECK(ddl_payload.HasMember(
"dataWrapper"));
880 CHECK(ddl_payload[
"dataWrapper"].IsString());
881 if (ddl_payload.HasMember(
"options")) {
882 CHECK(ddl_payload[
"options"].IsObject());
884 CHECK(ddl_payload.HasMember(
"ifNotExists"));
885 CHECK(ddl_payload[
"ifNotExists"].IsBool());
893 if (read_only_mode) {
894 throw std::runtime_error(
"CREATE FOREIGN SERVER invalid in read only mode.");
898 std::string server_name = ddl_payload[
"serverName"].GetString();
902 bool if_not_exists = ddl_payload[
"ifNotExists"].GetBool();
903 if (
session_ptr_->getCatalog().getForeignServer(server_name)) {
907 throw std::runtime_error{
"A foreign server with name \"" + server_name +
908 "\" already exists."};
914 throw std::runtime_error(
"Server " + std::string(server_name) +
915 " will not be created. User has no create privileges.");
919 auto foreign_server = std::make_unique<foreign_storage::ForeignServer>();
920 foreign_server->data_wrapper_type =
to_upper(ddl_payload[
"dataWrapper"].GetString());
921 foreign_server->name = server_name;
922 foreign_server->user_id = current_user.userId;
923 if (ddl_payload.HasMember(
"options")) {
924 foreign_server->populateOptionsMap(ddl_payload[
"options"]);
926 foreign_server->validate();
929 catalog.createForeignServer(std::move(foreign_server),
930 ddl_payload[
"ifNotExists"].GetBool());
939 std::shared_ptr<const Catalog_Namespace::SessionInfo> session_ptr)
942 CHECK(ddl_payload.HasMember(
"databaseName"));
943 CHECK(ddl_payload[
"databaseName"].IsString());
944 CHECK(ddl_payload.HasMember(
"alterType"));
945 CHECK(ddl_payload[
"alterType"].IsString());
946 if (ddl_payload[
"alterType"] ==
"RENAME_DATABASE") {
947 CHECK(ddl_payload.HasMember(
"newDatabaseName"));
948 CHECK(ddl_payload[
"newDatabaseName"].IsString());
949 }
else if (ddl_payload[
"alterType"] ==
"CHANGE_OWNER") {
950 CHECK(ddl_payload.HasMember(
"newOwner"));
951 CHECK(ddl_payload[
"newOwner"].IsString());
960 if (read_only_mode) {
961 throw std::runtime_error(
"ALTER DATABASE invalid in read only mode.");
964 std::string databaseName = ddl_payload[
"databaseName"].GetString();
968 if (!sys_cat.getMetadataForDB(databaseName, db)) {
969 throw std::runtime_error(
"Database " + databaseName +
" does not exists.");
972 std::string alter_type = ddl_payload[
"alterType"].GetString();
973 if (alter_type ==
"CHANGE_OWNER") {
975 }
else if (alter_type ==
"RENAME_DATABASE") {
984 std::string database_name = ddl_payload[
"databaseName"].GetString();
985 std::string new_database_name = ddl_payload[
"newDatabaseName"].GetString();
992 throw std::runtime_error(
"Only a super user or the owner can rename the database.");
1001 std::string database_name = ddl_payload[
"databaseName"].GetString();
1002 std::string new_owner = ddl_payload[
"newOwner"].GetString();
1005 throw std::runtime_error(
1006 "Only a super user can change a database's owner. "
1007 "Current user is not a super-user. "
1008 "Database with name \"" +
1009 database_name +
"\" will not have owner changed.");
1012 sys_cat.changeDatabaseOwner(database_name, new_owner);
1017 std::shared_ptr<const Catalog_Namespace::SessionInfo> session_ptr)
1020 throw std::runtime_error(
"Unsupported command: ALTER FOREIGN SERVER");
1023 CHECK(ddl_payload.HasMember(
"serverName"));
1024 CHECK(ddl_payload[
"serverName"].IsString());
1025 CHECK(ddl_payload.HasMember(
"alterType"));
1026 CHECK(ddl_payload[
"alterType"].IsString());
1027 if (ddl_payload[
"alterType"] ==
"SET_OPTIONS") {
1028 CHECK(ddl_payload.HasMember(
"options"));
1029 CHECK(ddl_payload[
"options"].IsObject());
1030 }
else if (ddl_payload[
"alterType"] ==
"SET_DATA_WRAPPER") {
1031 CHECK(ddl_payload.HasMember(
"dataWrapper"));
1032 CHECK(ddl_payload[
"dataWrapper"].IsString());
1033 }
else if (ddl_payload[
"alterType"] ==
"RENAME_SERVER") {
1034 CHECK(ddl_payload.HasMember(
"newServerName"));
1035 CHECK(ddl_payload[
"newServerName"].IsString());
1036 }
else if (ddl_payload[
"alterType"] ==
"CHANGE_OWNER") {
1037 CHECK(ddl_payload.HasMember(
"newOwner"));
1038 CHECK(ddl_payload[
"newOwner"].IsString());
1047 if (read_only_mode) {
1048 throw std::runtime_error(
"ALTER FOREIGN SERVER invalid in read only mode.");
1051 std::string server_name = ddl_payload[
"serverName"].GetString();
1053 throw std::runtime_error{
"Default servers cannot be altered."};
1055 if (!
session_ptr_->getCatalog().getForeignServer(server_name)) {
1056 throw std::runtime_error{
"Foreign server with name \"" + server_name +
1057 "\" does not exist and can not be altered."};
1060 throw std::runtime_error(
"Server " + server_name +
1061 " can not be altered. User has no ALTER SERVER privileges.");
1063 std::string alter_type = ddl_payload[
"alterType"].GetString();
1064 if (alter_type ==
"CHANGE_OWNER") {
1066 }
else if (alter_type ==
"SET_DATA_WRAPPER") {
1068 }
else if (alter_type ==
"SET_OPTIONS") {
1070 }
else if (alter_type ==
"RENAME_SERVER") {
1079 std::string server_name = ddl_payload[
"serverName"].GetString();
1080 std::string new_owner = ddl_payload[
"newOwner"].GetString();
1083 throw std::runtime_error(
1084 "Only a super user can change a foreign server's owner. "
1085 "Current user is not a super-user. "
1086 "Foreign server with name \"" +
1087 server_name +
"\" will not have owner changed.");
1090 if (!sys_cat.getMetadataForUser(new_owner, user)) {
1091 throw std::runtime_error(
"User with username \"" + new_owner +
"\" does not exist. " +
1092 "Foreign server with name \"" + server_name +
1093 "\" can not have owner changed.");
1097 bool original_owner_exists = sys_cat.getMetadataForUserById(
1098 cat.getForeignServer(server_name)->user_id, original_owner);
1100 cat.changeForeignServerOwner(server_name, user.
userId);
1104 sys_cat.changeDBObjectOwnership(
1105 user, original_owner, db_object,
cat, original_owner_exists);
1106 }
catch (
const std::runtime_error& e) {
1108 cat.changeForeignServerOwner(server_name, original_owner.
userId);
1115 std::string server_name = ddl_payload[
"serverName"].GetString();
1116 std::string new_server_name = ddl_payload[
"newServerName"].GetString();
1122 if (
cat.getForeignServer(new_server_name)) {
1123 throw std::runtime_error(
"Foreign server with name \"" + server_name +
1124 "\" can not be renamed to \"" + new_server_name +
"\"." +
1125 "Foreign server with name \"" + new_server_name +
1129 cat.renameForeignServer(server_name, new_server_name);
1133 sys_cat.renameDBObject(server_name,
1136 cat.getForeignServer(new_server_name)->id,
1138 }
catch (
const std::runtime_error& e) {
1140 cat.renameForeignServer(new_server_name, server_name);
1147 std::string server_name = ddl_payload[
"serverName"].GetString();
1150 const auto foreign_server =
cat.getForeignServer(server_name);
1159 std::string server_name = ddl_payload[
"serverName"].GetString();
1160 std::string data_wrapper = ddl_payload[
"dataWrapper"].GetString();
1163 cat.setForeignServerDataWrapper(server_name, data_wrapper);
1169 std::string server_name = ddl_payload[
"serverName"].GetString();
1176 std::shared_ptr<Catalog_Namespace::SessionInfo const> session_ptr)
1179 throw std::runtime_error(
"Unsupported command: DROP FOREIGN SERVER");
1182 CHECK(ddl_payload.HasMember(
"serverName"));
1183 CHECK(ddl_payload[
"serverName"].IsString());
1184 CHECK(ddl_payload.HasMember(
"ifExists"));
1185 CHECK(ddl_payload[
"ifExists"].IsBool());
1191 if (read_only_mode) {
1192 throw std::runtime_error(
"DROP FOREIGN SERVER invalid in read only mode.");
1196 std::string server_name = ddl_payload[
"serverName"].GetString();
1198 throw std::runtime_error{
"Default servers cannot be dropped."};
1200 bool if_exists = ddl_payload[
"ifExists"].GetBool();
1201 if (!
session_ptr_->getCatalog().getForeignServer(server_name)) {
1205 throw std::runtime_error{
"Foreign server with name \"" + server_name +
1206 "\" can not be dropped. Server does not exist."};
1212 throw std::runtime_error(
"Server " + server_name +
1213 " will not be dropped. User has no DROP SERVER privileges.");
1217 session_ptr_->getCatalog().dropForeignServer(ddl_payload[
"serverName"].GetString());
1222 SQLTypes JsonColumnSqlType::getSqlType(
const rapidjson::Value& data_type) {
1223 CHECK(data_type.IsObject());
1224 CHECK(data_type.HasMember(
"type"));
1225 CHECK(data_type[
"type"].IsString());
1227 std::string
type = data_type[
"type"].GetString();
1228 if (boost::iequals(type,
"ARRAY")) {
1229 CHECK(data_type.HasMember(
"array"));
1230 CHECK(data_type[
"array"].IsObject());
1232 const auto& array = data_type[
"array"].GetObject();
1233 CHECK(array.HasMember(
"elementType"));
1234 CHECK(array[
"elementType"].IsString());
1235 type = array[
"elementType"].GetString();
1237 return getSqlType(type);
1241 if (boost::iequals(type,
"BIGINT")) {
1244 if (boost::iequals(type,
"BOOLEAN")) {
1247 if (boost::iequals(type,
"DATE")) {
1250 if (boost::iequals(type,
"DECIMAL")) {
1253 if (boost::iequals(type,
"DOUBLE")) {
1256 if (boost::iequals(type,
"FLOAT")) {
1259 if (boost::iequals(type,
"INTEGER")) {
1262 if (boost::iequals(type,
"LINESTRING")) {
1265 if (boost::iequals(type,
"MULTILINESTRING")) {
1268 if (boost::iequals(type,
"MULTIPOLYGON")) {
1271 if (boost::iequals(type,
"POINT")) {
1274 if (boost::iequals(type,
"MULTIPOINT")) {
1277 if (boost::iequals(type,
"POLYGON")) {
1280 if (boost::iequals(type,
"SMALLINT")) {
1283 if (boost::iequals(type,
"TEXT")) {
1286 if (boost::iequals(type,
"TIME")) {
1289 if (boost::iequals(type,
"TIMESTAMP")) {
1292 if (boost::iequals(type,
"TINYINT")) {
1296 throw std::runtime_error{
"Unsupported type \"" + type +
"\" specified."};
1299 int JsonColumnSqlType::getParam1(
const rapidjson::Value& data_type) {
1301 CHECK(data_type.IsObject());
1302 if (data_type.HasMember(
"precision") && !data_type[
"precision"].IsNull()) {
1303 CHECK(data_type[
"precision"].IsInt());
1304 param1 = data_type[
"precision"].GetInt();
1311 int JsonColumnSqlType::getParam2(
const rapidjson::Value& data_type) {
1313 CHECK(data_type.IsObject());
1314 if (data_type.HasMember(
"scale") && !data_type[
"scale"].IsNull()) {
1315 CHECK(data_type[
"scale"].IsInt());
1316 param2 = data_type[
"scale"].GetInt();
1318 data_type.HasMember(
"coordinateSystem") &&
1319 !data_type[
"coordinateSystem"].IsNull()) {
1320 CHECK(data_type[
"coordinateSystem"].IsInt());
1321 param2 = data_type[
"coordinateSystem"].GetInt();
1326 bool JsonColumnSqlType::isArray(
const rapidjson::Value& data_type) {
1327 CHECK(data_type.IsObject());
1328 CHECK(data_type.HasMember(
"type"));
1329 CHECK(data_type[
"type"].IsString());
1330 return boost::iequals(data_type[
"type"].GetString(),
"ARRAY");
1333 int JsonColumnSqlType::getArraySize(
const rapidjson::Value& data_type) {
1335 if (isArray(data_type)) {
1336 CHECK(data_type.HasMember(
"array"));
1337 CHECK(data_type[
"array"].IsObject());
1339 const auto& array = data_type[
"array"].GetObject();
1340 if (array.HasMember(
"size") && !array[
"size"].IsNull()) {
1341 CHECK(array[
"size"].IsInt());
1342 size = array[
"size"].GetInt();
1348 std::string* JsonColumnEncoding::getEncodingName(
const rapidjson::Value& data_type) {
1349 CHECK(data_type.IsObject());
1350 CHECK(data_type.HasMember(
"encoding"));
1351 CHECK(data_type[
"encoding"].IsObject());
1353 const auto& encoding = data_type[
"encoding"].GetObject();
1354 CHECK(encoding.HasMember(
"type"));
1355 CHECK(encoding[
"type"].IsString());
1356 return new std::string(encoding[
"type"].GetString());
1359 int JsonColumnEncoding::getEncodingParam(
const rapidjson::Value& data_type) {
1360 CHECK(data_type.IsObject());
1361 CHECK(data_type.HasMember(
"encoding"));
1362 CHECK(data_type[
"encoding"].IsObject());
1364 int encoding_size = 0;
1365 const auto& encoding = data_type[
"encoding"].GetObject();
1366 if (encoding.HasMember(
"size") && !encoding[
"size"].IsNull()) {
1367 CHECK(encoding[
"size"].IsInt());
1368 encoding_size = encoding[
"size"].GetInt();
1370 return encoding_size;
1375 std::shared_ptr<Catalog_Namespace::SessionInfo const> session_ptr)
1378 throw std::runtime_error(
"Unsupported command: CREATE FOREIGN TABLE");
1381 CHECK(ddl_payload.HasMember(
"serverName"));
1382 CHECK(ddl_payload[
"serverName"].IsString());
1383 CHECK(ddl_payload.HasMember(
"tableName"));
1384 CHECK(ddl_payload[
"tableName"].IsString());
1385 CHECK(ddl_payload.HasMember(
"ifNotExists"));
1386 CHECK(ddl_payload[
"ifNotExists"].IsBool());
1387 CHECK(ddl_payload.HasMember(
"columns"));
1388 CHECK(ddl_payload[
"columns"].IsArray());
1397 if (read_only_mode) {
1398 throw std::runtime_error(
"CREATE FOREIGN TABLE invalid in read only mode.");
1401 const std::string& table_name = ddl_payload[
"tableName"].GetString();
1404 throw std::runtime_error(
1405 "Foreign table \"" + table_name +
1406 "\" will not be created. User has no CREATE TABLE privileges.");
1409 bool if_not_exists = ddl_payload[
"ifNotExists"].GetBool();
1410 if (!catalog.validateNonExistentTableOrView(table_name, if_not_exists)) {
1415 std::list<ColumnDescriptor> columns{};
1418 catalog.createTable(foreign_table, columns, {},
true);
1424 foreign_table.tableName,
1432 const std::string& table_name,
1434 const std::list<ColumnDescriptor>& columns) {
1445 const std::string server_name = ddl_payload[
"serverName"].GetString();
1447 if (!foreign_table.foreign_server) {
1448 throw std::runtime_error{
1449 "Foreign Table with name \"" + table_name +
1450 "\" can not be created. Associated foreign server with name \"" + server_name +
1451 "\" does not exist."};
1459 throw std::runtime_error(
1460 "Current user does not have USAGE privilege on foreign server: " + server_name);
1463 if (ddl_payload.HasMember(
"options") && !ddl_payload[
"options"].IsNull()) {
1464 CHECK(ddl_payload[
"options"].IsObject());
1465 foreign_table.initializeOptions(ddl_payload[
"options"]);
1470 foreign_table.initializeOptions();
1472 foreign_table.validateSchema(columns);
1474 if (
const auto it = foreign_table.options.find(
"FRAGMENT_SIZE");
1475 it != foreign_table.options.end()) {
1479 if (
const auto it = foreign_table.options.find(
"MAX_CHUNK_SIZE");
1480 it != foreign_table.options.end()) {
1481 foreign_table.maxChunkSize = std::stol(it->second);
1484 if (
const auto it = foreign_table.options.find(
"PARTITIONS");
1485 it != foreign_table.options.end()) {
1486 foreign_table.partitions = it->second;
1492 std::unordered_set<std::string> column_names{};
1493 for (
auto& column_def : ddl_payload[
"columns"].GetArray()) {
1494 CHECK(column_def.IsObject());
1495 CHECK(column_def.HasMember(
"name"));
1496 CHECK(column_def[
"name"].IsString());
1497 const std::string& column_name = column_def[
"name"].GetString();
1499 CHECK(column_def.HasMember(
"dataType"));
1500 CHECK(column_def[
"dataType"].IsObject());
1502 JsonColumnSqlType sql_type{column_def[
"dataType"]};
1503 const auto& data_type = column_def[
"dataType"].GetObject();
1504 CHECK(data_type.HasMember(
"notNull"));
1505 CHECK(data_type[
"notNull"].IsBool());
1507 std::unique_ptr<JsonColumnEncoding> encoding;
1508 if (data_type.HasMember(
"encoding") && !data_type[
"encoding"].IsNull()) {
1509 CHECK(data_type[
"encoding"].IsObject());
1510 encoding = std::make_unique<JsonColumnEncoding>(column_def[
"dataType"]);
1519 data_type[
"notNull"].GetBool(),
1522 columns.emplace_back(cd);
1528 std::shared_ptr<Catalog_Namespace::SessionInfo const> session_ptr)
1531 throw std::runtime_error(
"Unsupported command: DROP FOREIGN TABLE");
1534 CHECK(ddl_payload.HasMember(
"tableName"));
1535 CHECK(ddl_payload[
"tableName"].IsString());
1536 CHECK(ddl_payload.HasMember(
"ifExists"));
1537 CHECK(ddl_payload[
"ifExists"].IsBool());
1546 if (read_only_mode) {
1547 throw std::runtime_error(
"DROP FOREIGN TABLE invalid in read only mode.");
1549 const std::string& table_name = ddl_payload[
"tableName"].GetString();
1551 std::unique_ptr<lockmgr::TableSchemaLockContainer<lockmgr::WriteLock>> td_with_lock;
1555 std::make_unique<lockmgr::TableSchemaLockContainer<lockmgr::WriteLock>>(
1557 catalog, table_name,
false));
1558 CHECK(td_with_lock);
1559 td = (*td_with_lock)();
1560 }
catch (
const std::runtime_error& e) {
1563 if (ddl_payload[
"ifExists"].GetBool()) {
1574 throw std::runtime_error(
1575 "Foreign table \"" + table_name +
1576 "\" will not be dropped. User has no DROP TABLE privileges.");
1580 auto table_data_write_lock =
1583 catalog.dropTable(td);
1590 std::shared_ptr<Catalog_Namespace::SessionInfo const> session_ptr)
1601 std::vector<std::string> labels{
"table_name"};
1602 std::vector<TargetMetaInfo> label_infos;
1603 for (
const auto&
label : labels) {
1613 std::vector<RelLogicalValues::RowValues> logical_values;
1614 for (
auto table_name : table_names) {
1616 logical_values.back().emplace_back(
genLiteralStr(table_name));
1620 std::shared_ptr<ResultSet> rSet = std::shared_ptr<ResultSet>(
1628 std::shared_ptr<Catalog_Namespace::SessionInfo const> session_ptr)
1631 if (ddl_payload.HasMember(
"tableNames")) {
1632 CHECK(ddl_payload[
"tableNames"].IsArray());
1633 for (
const auto& table_name : ddl_payload[
"tableNames"].GetArray()) {
1634 CHECK(table_name.IsString());
1647 std::vector<TargetMetaInfo> label_infos;
1651 {
"table_name",
kTEXT,
true},
1652 {
"column_count",
kBIGINT,
true},
1653 {
"is_sharded_table",
kBOOLEAN,
true},
1654 {
"shard_count",
kBIGINT,
true},
1656 {
"fragment_size",
kBIGINT,
true},
1657 {
"max_rollback_epochs",
kBIGINT,
true},
1660 {
"min_epoch_floor",
kBIGINT,
true},
1661 {
"max_epoch_floor",
kBIGINT,
true},
1662 {
"metadata_file_count",
kBIGINT,
true},
1663 {
"total_metadata_file_size",
kBIGINT,
true},
1664 {
"total_metadata_page_count",
kBIGINT,
true},
1665 {
"total_free_metadata_page_count",
kBIGINT,
false},
1666 {
"data_file_count",
kBIGINT,
true},
1667 {
"total_data_file_size",
kBIGINT,
true},
1668 {
"total_data_page_count",
kBIGINT,
true},
1669 {
"total_free_data_page_count",
kBIGINT,
false}});
1671 std::vector<RelLogicalValues::RowValues> logical_values;
1675 const std::string& table_name) {
1676 auto agg_storage_stats =
1682 std::shared_ptr<ResultSet> rSet = std::shared_ptr<ResultSet>(
1691 auto all_table_names =
1694 all_table_names.end(),
1695 all_table_names.begin(),
1696 [](
const std::string& s) {
return to_upper(s); });
1697 std::vector<std::string> filtered_table_names;
1698 if (ddl_payload.HasMember(
"tableNames")) {
1699 std::set<std::string> all_table_names_set(all_table_names.begin(),
1700 all_table_names.end());
1701 for (
const auto& table_name_json : ddl_payload[
"tableNames"].GetArray()) {
1702 std::string table_name = table_name_json.GetString();
1703 if (all_table_names_set.find(
to_upper(table_name)) == all_table_names_set.end()) {
1704 throw std::runtime_error{
"Unable to show table details for table: " + table_name +
1705 ". Table does not exist."};
1707 auto [td, td_with_lock] =
1708 get_table_descriptor_with_lock<lockmgr::ReadLock>(*catalog, table_name,
false);
1709 if (td->isForeignTable()) {
1710 throw std::runtime_error{
1711 "SHOW TABLE DETAILS is not supported for foreign tables. Table name: " +
1714 if (td->isTemporaryTable()) {
1715 throw std::runtime_error{
1716 "SHOW TABLE DETAILS is not supported for temporary tables. Table name: " +
1719 filtered_table_names.emplace_back(table_name);
1725 const std::string& table_name) {
1729 filtered_table_names.emplace_back(table_name);
1732 return filtered_table_names;
1737 std::shared_ptr<Catalog_Namespace::SessionInfo const> session_ptr)
1746 CHECK(ddl_payload.HasMember(
"tableName"));
1747 CHECK(ddl_payload[
"tableName"].IsString());
1748 const std::string& table_name = ddl_payload[
"tableName"].GetString();
1751 auto table_read_lock =
1754 const TableDescriptor* td = catalog.getMetadataForTable(table_name,
false);
1756 throw std::runtime_error(
"Table/View " + table_name +
" does not exist.");
1761 std::vector<DBObject> privObjects = {dbObject};
1765 throw std::runtime_error(
"Table/View " + table_name +
" does not exist.");
1769 auto query_state_proxy = query_state->createQueryStateProxy();
1770 auto calcite_mgr = catalog.getCalciteMgr();
1771 const auto calciteQueryParsingOption =
1772 calcite_mgr->getCalciteQueryParsingOption(
true,
false,
false,
false);
1773 const auto calciteOptimizationOption = calcite_mgr->getCalciteOptimizationOption(
1778 auto result = calcite_mgr->process(query_state_proxy,
1780 calciteQueryParsingOption,
1781 calciteOptimizationOption);
1783 calcite_mgr->checkAccessedObjectsPrivileges(query_state_proxy,
result);
1784 }
catch (
const std::runtime_error&) {
1785 throw std::runtime_error(
"Not enough privileges to show the view SQL");
1797 std::shared_ptr<Catalog_Namespace::SessionInfo const> session_ptr)
1806 std::vector<std::string> labels{
"Database",
"Owner"};
1807 std::vector<TargetMetaInfo> label_infos;
1808 for (
const auto&
label : labels) {
1818 std::vector<RelLogicalValues::RowValues> logical_values;
1819 for (
const auto& db_summary : db_summaries) {
1821 logical_values.back().emplace_back(
genLiteralStr(db_summary.dbName));
1822 logical_values.back().emplace_back(
genLiteralStr(db_summary.dbOwnerName));
1826 std::shared_ptr<ResultSet> rSet = std::shared_ptr<ResultSet>(
1834 std::shared_ptr<Catalog_Namespace::SessionInfo const> session_ptr)
1842 std::vector<TargetMetaInfo> label_infos;
1843 std::vector<RelLogicalValues::RowValues> logical_values;
1845 if (ddl_payload.HasMember(
"ScalarFnNames")) {
1852 for (
const auto& udf_name_json : ddl_payload[
"ScalarFnNames"].GetArray()) {
1853 std::string udf_name = udf_name_json.GetString();
1854 std::vector<ExtensionFunction> ext_funcs =
1860 logical_values.back().emplace_back(
genLiteralStr(udf_name));
1862 logical_values.back().emplace_back(
genLiteralStr(fn.toSignature()));
1874 for (
const auto&
label : {
"Scalar UDF"}) {
1886 std::shared_ptr<ResultSet> rSet = std::shared_ptr<ResultSet>(
1894 std::shared_ptr<Catalog_Namespace::SessionInfo const> session_ptr)
1901 std::vector<TargetMetaInfo> label_infos;
1902 std::vector<RelLogicalValues::RowValues> logical_values;
1905 for (
const auto&
label : {
"Runtime Scalar UDF"}) {
1916 std::shared_ptr<ResultSet> rSet = std::shared_ptr<ResultSet>(
1924 std::shared_ptr<Catalog_Namespace::SessionInfo const> session_ptr)
1934 std::vector<TargetMetaInfo> label_infos;
1935 std::vector<RelLogicalValues::RowValues> logical_values;
1937 if (ddl_payload.HasMember(
"tfNames")) {
1951 for (
const auto& tf_name_json : ddl_payload[
"tfNames"].GetArray()) {
1952 std::string tf_name = tf_name_json.GetString();
1957 logical_values.back().emplace_back(
genLiteralStr(tf.getName(
true,
false)));
1960 tf.getSignature(
false,
true)));
1962 logical_values.back().emplace_back(
1965 logical_values.back().emplace_back(
1968 logical_values.back().emplace_back(
genLiteralStr(tf.getInputArgsDefaultValues()));
1970 logical_values.back().emplace_back(
1973 logical_values.back().emplace_back(
1983 !tf.getFunctionAnnotation(
"filter_table_function_transpose",
"").empty()));
1988 for (
const auto&
label : {
"Table UDF"}) {
1993 std::unordered_set<std::string> unique_names;
1996 std::string
name = tf.getName(
true,
true);
1997 if (unique_names.find(name) == unique_names.end()) {
1998 unique_names.emplace(name);
2006 std::shared_ptr<ResultSet> rSet = std::shared_ptr<ResultSet>(
2014 std::shared_ptr<Catalog_Namespace::SessionInfo const> session_ptr)
2023 std::vector<TargetMetaInfo> label_infos;
2024 std::vector<RelLogicalValues::RowValues> logical_values;
2027 for (
const auto&
label : {
"Runtime Table UDF"}) {
2032 std::unordered_set<std::string> unique_names;
2035 std::string
name = tf.getName(
true,
true);
2036 if (unique_names.find(name) == unique_names.end()) {
2037 unique_names.emplace(name);
2044 std::shared_ptr<ResultSet> rSet = std::shared_ptr<ResultSet>(
2052 std::shared_ptr<Catalog_Namespace::SessionInfo const> session_ptr)
2055 throw std::runtime_error(
"Cannot show models. ML functions are disabled.");
2059 const auto& current_user = session_ptr->get_currentUser();
2060 if (!current_user.isSuper) {
2061 throw std::runtime_error(
2062 "Cannot show models. Showing model information to non-superusers is disabled.");
2071 std::vector<std::string> labels{
"model_name"};
2072 std::vector<TargetMetaInfo> label_infos;
2073 for (
const auto&
label : labels) {
2081 std::vector<RelLogicalValues::RowValues> logical_values;
2082 for (
auto model_name : model_names) {
2084 logical_values.back().emplace_back(
genLiteralStr(model_name));
2088 std::shared_ptr<ResultSet> rSet = std::shared_ptr<ResultSet>(
2096 std::shared_ptr<Catalog_Namespace::SessionInfo const> session_ptr)
2099 throw std::runtime_error(
"Cannot show model details. ML functions are disabled.");
2103 const auto& current_user = session_ptr->get_currentUser();
2104 if (!current_user.isSuper) {
2105 throw std::runtime_error(
2106 "Cannot show model details. Showing model information to non-superusers is "
2115 std::vector<TargetMetaInfo> label_infos;
2132 std::vector<RelLogicalValues::RowValues> logical_values;
2133 for (
auto& model_name : model_names) {
2135 logical_values.back().emplace_back(
genLiteralStr(model_name));
2137 logical_values.back().emplace_back(
genLiteralStr(model_metadata.getModelTypeStr()));
2138 logical_values.back().emplace_back(
genLiteralStr(model_metadata.getPredicted()));
2139 const auto& features = model_metadata.getFeatures();
2140 std::ostringstream features_oss;
2141 bool is_first_feature =
true;
2142 for (
auto& feature : features) {
2143 if (!is_first_feature) {
2144 features_oss <<
", ";
2146 is_first_feature =
false;
2148 features_oss << feature;
2150 auto features_str = features_oss.str();
2151 logical_values.back().emplace_back(
genLiteralStr(features_str));
2152 logical_values.back().emplace_back(
genLiteralStr(model_metadata.getTrainingQuery()));
2153 logical_values.back().emplace_back(
2155 logical_values.back().emplace_back(
genLiteralBigInt(model_metadata.getNumFeatures()));
2156 logical_values.back().emplace_back(
2158 logical_values.back().emplace_back(
2160 model_metadata.getNumCategoricalFeatures()));
2161 logical_values.back().emplace_back(
2163 logical_values.back().emplace_back(
2168 std::shared_ptr<ResultSet> rSet = std::shared_ptr<ResultSet>(
2177 if (ddl_payload.HasMember(
"modelNames")) {
2178 std::vector<std::string> filtered_model_names;
2179 std::set<std::string> all_model_names_set(all_model_names.begin(),
2180 all_model_names.end());
2181 for (
const auto& model_name_json : ddl_payload[
"modelNames"].GetArray()) {
2182 std::string model_name = model_name_json.GetString();
2183 const auto model_name_upper =
to_upper(model_name);
2184 if (all_model_names_set.find(
to_upper(model_name_upper)) ==
2185 all_model_names_set.end()) {
2186 throw std::runtime_error{
"Unable to show model details for model: " +
2187 model_name_upper +
". Model does not exist."};
2189 filtered_model_names.emplace_back(model_name_upper);
2191 return filtered_model_names;
2193 return all_model_names;
2199 std::shared_ptr<Catalog_Namespace::SessionInfo const> session_ptr)
2202 throw std::runtime_error(
2203 "Cannot show model feature details. ML functions are disabled.");
2207 const auto& current_user = session_ptr->get_currentUser();
2208 if (!current_user.isSuper) {
2209 throw std::runtime_error(
2210 "Cannot show model feature details. Showing model information to "
2211 "non-superusers is "
2218 std::vector<TargetMetaInfo> label_infos;
2226 std::pair<std::vector<double>, std::vector<std::vector<double>>>
2228 std::shared_ptr<AbstractMLModel> model,
2229 std::vector<TargetMetaInfo>& label_infos)
const {
2230 std::vector<double> extra_metadata;
2231 std::vector<std::vector<double>> eigenvectors;
2233 switch (model->getModelType()) {
2236 const auto linear_reg_model =
2238 extra_metadata = linear_reg_model->
getCoefs();
2243 const auto random_forest_reg_model =
2244 std::dynamic_pointer_cast<AbstractRandomForestModel>(model);
2245 extra_metadata = random_forest_reg_model->getVariableImportanceScores();
2246 if (!extra_metadata.empty()) {
2254 const auto pca_model = std::dynamic_pointer_cast<
PcaModel>(model);
2256 eigenvectors = pca_model->getEigenvectors();
2257 CHECK_EQ(eigenvectors.size(), extra_metadata.size());
2260 #endif // HAVE_ONEDAL
2266 return std::make_pair(std::move(extra_metadata), std::move(eigenvectors));
2269 std::vector<RelLogicalValues::RowValues>
2272 const std::vector<std::vector<std::string>>& cat_sub_features,
2273 std::vector<double>& extra_metadata,
2274 const std::vector<std::vector<double>>& eigenvectors,
2275 const std::vector<int64_t>& inverse_permutations)
const {
2276 std::vector<RelLogicalValues::RowValues> logical_values;
2281 logical_values.back().emplace_back(
genLiteralStr(
"intercept"));
2285 extra_metadata.erase(extra_metadata.begin());
2287 const auto& features = model_metadata.
getFeatures();
2288 const int64_t num_features =
static_cast<int64_t
>(features.size());
2289 std::vector<int64_t> physical_feature_idx_prefix_sums = {0};
2290 for (int64_t feature_idx = 1; feature_idx < num_features; ++feature_idx) {
2291 if (feature_idx - 1 < static_cast<int64_t>(cat_sub_features.size())) {
2292 physical_feature_idx_prefix_sums.emplace_back(
2293 physical_feature_idx_prefix_sums.back() +
2294 static_cast<int64_t
>(cat_sub_features[feature_idx - 1].size()));
2296 physical_feature_idx_prefix_sums.emplace_back(
2297 physical_feature_idx_prefix_sums.back() + 1);
2300 for (int64_t original_feature_idx = 0; original_feature_idx < num_features;
2301 ++original_feature_idx) {
2302 const auto feature_idx = inverse_permutations.empty()
2303 ? original_feature_idx
2304 : inverse_permutations[original_feature_idx];
2305 int64_t num_sub_features =
2306 feature_idx >=
static_cast<int64_t
>(cat_sub_features.size())
2308 : static_cast<int64_t>(cat_sub_features[feature_idx].size());
2309 const bool has_sub_features = num_sub_features > 0;
2310 num_sub_features = num_sub_features == 0 ? 1 : num_sub_features;
2311 int64_t physical_feature_idx = physical_feature_idx_prefix_sums[feature_idx];
2312 for (int64_t sub_feature_idx = 0; sub_feature_idx < num_sub_features;
2313 ++sub_feature_idx) {
2316 logical_values.back().emplace_back(
genLiteralBigInt(original_feature_idx + 1));
2317 logical_values.back().emplace_back(
genLiteralStr(features[original_feature_idx]));
2319 if (has_sub_features) {
2320 logical_values.back().emplace_back(
2321 genLiteralStr(cat_sub_features[feature_idx][sub_feature_idx]));
2325 if (!extra_metadata.empty()) {
2326 logical_values.back().emplace_back(
2329 if (!eigenvectors.empty()) {
2330 std::ostringstream eigenvector_oss;
2331 eigenvector_oss <<
"[";
2332 for (
size_t i = 0; i < eigenvectors[physical_feature_idx].size(); ++i) {
2334 eigenvector_oss <<
", ";
2336 eigenvector_oss << eigenvectors[physical_feature_idx][i];
2338 eigenvector_oss <<
"]";
2339 logical_values.back().emplace_back(
genLiteralStr(eigenvector_oss.str()));
2341 physical_feature_idx++;
2344 return logical_values;
2350 CHECK(ddl_payload.HasMember(
"modelName")) <<
"Model name missing.";
2351 const auto model_name = ddl_payload[
"modelName"].GetString();
2353 const auto model_metadata = model->getModelMetadata();
2356 const auto& feature_permutations = model_metadata.getFeaturePermutations();
2358 std::vector<int64_t> inverse_permutations(feature_permutations.size());
2359 for (int64_t perm_idx = 0; perm_idx < static_cast<int64_t>(feature_permutations.size());
2361 inverse_permutations[feature_permutations[perm_idx]] = perm_idx;
2369 const auto& cat_sub_features = model->getCatFeatureKeys();
2374 inverse_permutations);
2377 std::shared_ptr<ResultSet> rSet = std::shared_ptr<ResultSet>(
2385 std::shared_ptr<Catalog_Namespace::SessionInfo const> session_ptr)
2388 throw std::runtime_error(
"Cannot evaluate model. ML functions are disabled.");
2395 std::string model_name;
2396 std::string select_query;
2397 if (ddl_payload.HasMember(
"modelName")) {
2398 model_name = ddl_payload[
"modelName"].GetString();
2400 if (ddl_payload.HasMember(
"query")) {
2401 select_query = ddl_payload[
"query"].GetString();
2403 std::regex newline_re(
"\\n");
2404 std::regex backtick_re(
"`");
2405 select_query = std::regex_replace(select_query, newline_re,
" ");
2406 select_query = std::regex_replace(select_query, backtick_re,
"");
2408 const auto model_type = model_metadata.getModelType();
2410 const auto& model_type_str = model_metadata.getModelTypeStr();
2411 std::ostringstream error_oss;
2412 error_oss <<
"EVALUATE MODEL not supported for " << model_type_str <<
" models.";
2413 throw std::runtime_error(error_oss.str());
2416 if (select_query.empty()) {
2417 const double data_split_eval_fraction = model_metadata.getDataSplitEvalFraction();
2418 CHECK_LE(data_split_eval_fraction, 1.0);
2419 if (data_split_eval_fraction <= 0.0) {
2420 throw std::runtime_error(
2421 "Unable to evaluate model: " + model_name +
2422 ". Model was not trained with a data split evaluation fraction.");
2424 const auto& training_query = model_metadata.getTrainingQuery();
2425 const auto& feature_permutations = model_metadata.getFeaturePermutations();
2426 std::ostringstream select_query_oss;
2431 const double data_split_train_fraction = 1.0 - data_split_eval_fraction;
2432 select_query_oss <<
"SELECT ";
2433 if (!feature_permutations.empty()) {
2434 select_query_oss << model_metadata.getPredicted() <<
", ";
2435 const auto& features = model_metadata.getFeatures();
2436 for (
const auto feature_permutation : feature_permutations) {
2437 select_query_oss << features[feature_permutation];
2438 if (feature_permutation != feature_permutations.back()) {
2439 select_query_oss <<
", ";
2443 select_query_oss <<
" * ";
2446 select_query_oss <<
" FROM (" << training_query <<
") WHERE NOT SAMPLE_RATIO("
2447 << data_split_train_fraction <<
")";
2448 select_query = select_query_oss.str();
2450 const auto& feature_permutations = model_metadata.getFeaturePermutations();
2451 if (!feature_permutations.empty()) {
2453 auto validate_query_state =
2455 auto validate_result = local_connector.
query(
2456 validate_query_state->createQueryStateProxy(), select_query, {},
true,
false);
2457 auto column_descriptors_list =
2459 std::vector<ColumnDescriptor> column_descriptors;
2460 for (
auto& cd : column_descriptors_list) {
2461 column_descriptors.emplace_back(cd);
2463 std::ostringstream select_query_oss;
2464 select_query_oss <<
"SELECT " << model_metadata.getPredicted() <<
", ";
2465 for (
const auto feature_permutation : feature_permutations) {
2466 select_query_oss << column_descriptors[feature_permutation + 1].columnName;
2467 if (feature_permutation != feature_permutations.back()) {
2468 select_query_oss <<
", ";
2471 select_query_oss <<
" FROM (" << select_query <<
")";
2472 select_query = select_query_oss.str();
2475 std::ostringstream r2_query_oss;
2476 r2_query_oss <<
"SELECT * FROM TABLE(r2_score(model_name => '" << model_name <<
"', "
2477 <<
"data => CURSOR(" << select_query <<
")))";
2478 std::string r2_query = r2_query_oss.str();
2484 local_connector.
query(query_state->createQueryStateProxy(), r2_query, {},
false);
2485 std::vector<std::string> labels{
"r2"};
2486 std::vector<TargetMetaInfo> label_infos;
2487 for (
const auto&
label : labels) {
2490 std::vector<RelLogicalValues::RowValues> logical_values;
2497 auto result_row =
result[0].rs->getNextRow(
true,
true);
2499 auto scalar_r = boost::get<ScalarTargetValue>(&result_row[0]);
2500 auto p = boost::get<double>(scalar_r);
2504 std::shared_ptr<ResultSet> rSet = std::shared_ptr<ResultSet>(
2508 }
catch (
const std::exception& e) {
2509 std::ostringstream error_oss;
2519 auto get_error_substring = [](
const std::string& message) -> std::string {
2520 size_t colon_position = std::string::npos;
2521 for (
int i = 0; i < 3; ++i) {
2522 colon_position = message.find(
':', colon_position + 1);
2523 if (colon_position == std::string::npos) {
2528 if (colon_position + 2 >= message.length()) {
2531 return message.substr(colon_position + 2);
2534 const auto error_substr = get_error_substring(e.what());
2535 error_oss <<
"Could not evaluate model " << model_name <<
". " << error_substr;
2536 throw std::runtime_error(error_oss.str());
2542 std::shared_ptr<Catalog_Namespace::SessionInfo const> session_ptr)
2545 throw std::runtime_error(
"Unsupported command: SHOW FOREIGN SERVERS");
2549 CHECK(ddl_payload.HasMember(
"command"));
2550 if (ddl_payload.HasMember(
"filters")) {
2551 CHECK(ddl_payload[
"filters"].IsArray());
2552 int num_filters = 0;
2553 for (
auto const& filter_def : ddl_payload[
"filters"].GetArray()) {
2554 CHECK(filter_def.IsObject());
2555 CHECK(filter_def.HasMember(
"attribute"));
2556 CHECK(filter_def[
"attribute"].IsString());
2557 CHECK(filter_def.HasMember(
"value"));
2558 CHECK(filter_def[
"value"].IsString());
2559 CHECK(filter_def.HasMember(
"operation"));
2560 CHECK(filter_def[
"operation"].IsString());
2561 if (num_filters > 0) {
2562 CHECK(filter_def.HasMember(
"chain"));
2563 CHECK(filter_def[
"chain"].IsString());
2565 CHECK(!filter_def.HasMember(
"chain"));
2577 std::vector<TargetMetaInfo> label_infos;
2581 std::vector<std::string> labels{
"server_name",
"data_wrapper",
"created_at",
"options"};
2590 std::vector<const foreign_storage::ForeignServer*> results;
2596 std::vector<RelLogicalValues::RowValues> logical_values;
2597 for (
auto const& server_ptr : results) {
2599 logical_values.back().emplace_back(
genLiteralStr(server_ptr->name));
2600 logical_values.back().emplace_back(
genLiteralStr(server_ptr->data_wrapper_type));
2602 logical_values.back().emplace_back(
2606 std::shared_ptr<ResultSet> rSet = std::shared_ptr<ResultSet>(
2614 std::shared_ptr<Catalog_Namespace::SessionInfo const> session_ptr)
2617 throw std::runtime_error(
"Unsupported command: SHOW CREATE SERVER");
2621 CHECK(payload.HasMember(
"serverName"));
2622 CHECK(payload[
"serverName"].IsString());
2623 server_ = (payload[
"serverName"].GetString());
2630 using namespace Catalog_Namespace;
2632 const auto server = catalog.getForeignServer(
server_);
2634 throw std::runtime_error(
"Foreign server " +
server_ +
" does not exist.");
2638 std::vector<DBObject> privObjects = {dbObject};
2641 throw std::runtime_error(
"Foreign server " +
server_ +
" does not exist.");
2643 auto create_stmt = catalog.dumpCreateServer(
server_);
2645 std::vector<std::string> labels{
"create_server_sql"};
2646 std::vector<TargetMetaInfo> label_infos;
2649 std::vector<RelLogicalValues::RowValues> logical_values;
2651 logical_values.back().emplace_back(
genLiteralStr(create_stmt));
2653 std::shared_ptr<ResultSet> rSet = std::shared_ptr<ResultSet>(
2661 std::shared_ptr<Catalog_Namespace::SessionInfo const> session_ptr)
2664 throw std::runtime_error(
"Unsupported command: REFRESH FOREIGN TABLE");
2667 CHECK(ddl_payload.HasMember(
"tableNames"));
2668 CHECK(ddl_payload[
"tableNames"].IsArray());
2669 for (
auto const& tablename_def : ddl_payload[
"tableNames"].GetArray()) {
2670 CHECK(tablename_def.IsString());
2675 if (read_only_mode) {
2676 throw std::runtime_error(
"REFRESH FOREIGN TABLE invalid in read only mode.");
2681 bool evict_cached_entries{
false};
2684 if (ddl_payload.HasMember(
"options") && !ddl_payload[
"options"].IsNull()) {
2686 for (
const auto& entry : opt.
options) {
2687 if (entry.first !=
"EVICT") {
2688 throw std::runtime_error{
2689 "Invalid option \"" + entry.first +
2690 "\" provided for refresh command. Only \"EVICT\" option is supported."};
2695 if (boost::iequals(opt.
options[
"EVICT"],
"true") ||
2696 boost::iequals(opt.
options[
"EVICT"],
"false")) {
2697 if (boost::iequals(opt.
options[
"EVICT"],
"true")) {
2698 evict_cached_entries =
true;
2701 throw std::runtime_error{
2702 "Invalid value \"" + opt.
options[
"EVICT"] +
2703 "\" provided for EVICT option. Value must be either \"true\" or \"false\"."};
2708 const auto& current_user =
session_ptr_->get_currentUser();
2710 if (!current_user.isSuper) {
2711 for (
const auto& table_name_json : ddl_payload[
"tableNames"].GetArray()) {
2712 std::string table_name = table_name_json.GetString();
2715 throw std::runtime_error(
2716 std::string(
"REFRESH FOREIGN TABLES failed on table \"") + table_name +
2717 "\". It can only be executed by super user or "
2724 for (
const auto& table_name_json : ddl_payload[
"tableNames"].GetArray()) {
2725 std::string table_name = table_name_json.GetString();
2726 static const std::array<std::string, 4> log_system_tables{
2732 throw std::runtime_error(
2733 "REFRESH FOREIGN TABLE can only be executed for the following tables: " +
2734 join(log_system_tables,
","));
2743 std::shared_ptr<const Catalog_Namespace::SessionInfo> session_ptr)
2747 CHECK(ddl_payload.HasMember(
"tableName"));
2748 CHECK(ddl_payload[
"tableName"].IsString());
2750 CHECK(ddl_payload.HasMember(
"alterType"));
2751 CHECK(ddl_payload[
"alterType"].IsString());
2756 std::shared_ptr<const Catalog_Namespace::SessionInfo> session_ptr)
2758 , recovery_mgr_(session_ptr->getCatalog())
2763 CHECK_EQ(std::string(ddl_payload[
"alterType"].GetString()),
"ALTER_COLUMN");
2765 CHECK(ddl_payload.HasMember(
"alterData"));
2766 CHECK(ddl_payload[
"alterData"].IsArray());
2768 const auto elements = ddl_payload[
"alterData"].GetArray();
2769 for (
const auto& element : elements) {
2770 CHECK(element.HasMember(
"type"));
2771 CHECK(element[
"type"].IsString());
2772 CHECK_EQ(std::string(element[
"type"].GetString()),
"SQL_COLUMN_DECLARATION");
2774 CHECK(element.HasMember(
"name"));
2775 CHECK(element[
"name"].IsString());
2777 CHECK(element.HasMember(
"default"));
2779 CHECK(element.HasMember(
"nullable"));
2780 CHECK(element[
"nullable"].IsBool());
2782 CHECK(element.HasMember(
"encodingType"));
2783 CHECK(element.HasMember(
"encodingSize"));
2785 CHECK(element.HasMember(
"sqltype"));
2786 CHECK(element[
"sqltype"].IsString());
2794 for (
auto& [src_cd, dst_cd] : src_dst_cds) {
2795 if (dst_cd->columnType.is_geometry()) {
2798 auto compare_result =
2800 CHECK(!compare_result.sql_types_match || !compare_result.defaults_match);
2802 catalog.alterColumnTypeTransactional(*dst_cd);
2811 std::list<const ColumnDescriptor*> non_geo_cds;
2812 for (
auto& [src_cd, dst_cd] : src_dst_cds) {
2813 if (dst_cd->columnType.is_geometry()) {
2816 non_geo_cds.emplace_back(dst_cd);
2818 auto compare_result =
2820 if (compare_result.sql_types_match) {
2824 if (dst_cd->columnType.is_dict_encoded_type()) {
2825 catalog.addDictionaryTransactional(*dst_cd);
2836 std::list<std::list<ColumnDescriptor>> physical_geo_columns;
2838 for (
auto& [src_cd, dst_cd] : src_dst_cds) {
2839 if (dst_cd->columnType.is_geometry()) {
2840 std::string col_name = src_cd->columnName;
2841 auto uuid = boost::uuids::random_generator()();
2844 physical_geo_columns.emplace_back();
2845 std::list<ColumnDescriptor>& phy_geo_columns = physical_geo_columns.back();
2846 catalog.expandGeoColumn(*dst_cd, phy_geo_columns);
2848 catalog.addColumnTransactional(*td, *dst_cd);
2850 for (
auto& cd : phy_geo_columns) {
2851 catalog.addColumnTransactional(*td, cd);
2856 return physical_geo_columns;
2861 const std::list<const ColumnDescriptor*>& cds) {
2867 auto io_fragmenter =
2869 CHECK(io_fragmenter);
2870 io_fragmenter->alterNonGeoColumnType(cds);
2876 std::list<const ColumnDescriptor*>>>& geo_src_dst_cds) {
2877 if (geo_src_dst_cds.empty()) {
2882 auto io_fragmenter =
2884 CHECK(io_fragmenter);
2885 io_fragmenter->alterColumnGeoType(geo_src_dst_cds);
2894 column_key.resize(3);
2895 for (
auto& [src_cd, _] : src_dst_cds) {
2896 column_key[2] = src_cd->columnId;
2901 catalog.removeFragmenterForTable(td->
tableId);
2909 auto column_id_start = catalog.getNextAddedColumnId(*td);
2910 auto current_column_id = column_id_start;
2913 for (
auto& [src_cd, dst_cd] : src_dst_cds) {
2914 if (dst_cd->columnType.is_geometry()) {
2917 std::list<ColumnDescriptor> phy_geo_columns;
2918 catalog.expandGeoColumn(*dst_cd, phy_geo_columns);
2920 auto col_to_add = *dst_cd;
2921 col_to_add.tableId = td->
tableId;
2922 col_to_add.columnId = current_column_id++;
2925 for (
auto& cd : phy_geo_columns) {
2928 phys_col_to_add.
columnId = current_column_id++;
2931 }
else if (dst_cd->columnType.is_dict_encoded_type()) {
2939 for (
auto& [src_cd, dst_cd] : src_dst_cds) {
2940 if (dst_cd->columnType.is_geometry()) {
2943 auto compare_result =
2945 CHECK(!compare_result.sql_types_match || !compare_result.defaults_match);
2954 if (std::filesystem::exists(recovery_filepath)) {
2955 std::filesystem::remove(recovery_filepath);
2964 auto table_epochs = catalog.getTableEpochs(catalog.getDatabaseId(), td->
tableId);
2965 CHECK_GT(table_epochs.size(), 0UL);
2971 for (
const auto& [src_cd, dst_cd] : src_dst_cds) {
2984 auto table_epochs = catalog.getTableEpochs(catalog.getDatabaseId(), td->
tableId);
2993 auto geo_src_dst_column_pairs =
3007 }
catch (std::exception& except) {
3008 catalog.setTableEpochs(catalog.getDatabaseId(), table_epochs);
3012 throw std::runtime_error(
"Alter column type: " + std::string(except.what()));
3019 }
catch (std::exception& except) {
3022 LOG(
FATAL) <<
"Alter column type: encountered fatal error during finalizing: "
3032 const auto tableName = std::string(ddl_payload[
"tableName"].GetString());
3037 const auto td_with_lock =
3039 catalog, tableName,
true);
3040 const auto td = td_with_lock();
3043 throw std::runtime_error(
"Table " + tableName +
" does not exist.");
3046 throw std::runtime_error(
"Altering columns in a view is not supported.");
3050 throw std::runtime_error(
"Altering columns in temporary tables is not supported.");
3056 for (
const auto& coldef : columns) {
3057 const auto& column_name = *coldef.get_column_name();
3058 if (catalog.getMetadataForColumn(td->tableId, column_name) ==
nullptr) {
3059 throw std::runtime_error(
"Column " + column_name +
" does not exist.");
3063 CHECK(td->fragmenter);
3064 if (td->sortedColumnId) {
3065 throw std::runtime_error(
3066 "Altering columns to a table is not supported when using the \"sort_column\" "
3076 throw std::runtime_error(
3077 "ALTER TABLE ALTER COLUMN is unsupported in distributed mode.");
3109 if (read_only_mode) {
3110 throw std::runtime_error(
"ALTER TABLE invalid in read only mode.");
3114 const auto tableName = std::string(ddl_payload[
"tableName"].GetString());
3116 CHECK(ddl_payload.HasMember(
"alterType"));
3119 if (type ==
"RENAME_TABLE") {
3120 CHECK(ddl_payload.HasMember(
"newTableName"));
3121 auto newTableName =
json_str(ddl_payload[
"newTableName"]);
3122 std::unique_ptr<Parser::DDLStmt>(
3124 new std::string(newTableName)))
3128 }
else if (type ==
"RENAME_COLUMN") {
3129 CHECK(ddl_payload.HasMember(
"columnName"));
3130 auto columnName =
json_str(ddl_payload[
"columnName"]);
3131 CHECK(ddl_payload.HasMember(
"newColumnName"));
3132 auto newColumnName =
json_str(ddl_payload[
"newColumnName"]);
3133 std::unique_ptr<Parser::DDLStmt>(
3135 new std::string(columnName),
3136 new std::string(newColumnName)))
3140 }
else if (type ==
"ALTER_COLUMN") {
3142 }
else if (type ==
"ADD_COLUMN") {
3143 CHECK(ddl_payload.HasMember(
"columnData"));
3144 CHECK(ddl_payload[
"columnData"].IsArray());
3147 std::list<Parser::ColumnDef*>* table_element_list_ =
3148 new std::list<Parser::ColumnDef*>;
3150 const auto elements = ddl_payload[
"columnData"].GetArray();
3151 for (
const auto& element : elements) {
3152 CHECK(element.IsObject());
3153 CHECK(element.HasMember(
"type"));
3154 if (
json_str(element[
"type"]) ==
"SQL_COLUMN_DECLARATION") {
3156 table_element_list_->emplace_back(col_def.release());
3158 LOG(
FATAL) <<
"Unsupported element type for ALTER TABLE: "
3159 << element[
"type"].GetString();
3163 std::unique_ptr<Parser::DDLStmt>(
3168 }
else if (type ==
"DROP_COLUMN") {
3169 CHECK(ddl_payload.HasMember(
"columnData"));
3170 auto columnData =
json_str(ddl_payload[
"columnData"]);
3173 std::list<std::string*>* cols =
new std::list<std::string*>;
3174 std::vector<std::string> cols1;
3175 boost::split(cols1, columnData, boost::is_any_of(
","));
3176 for (
auto s : cols1) {
3178 boost::algorithm::trim_if(s, boost::is_any_of(
" \"'`"));
3179 std::string* str =
new std::string(s);
3180 cols->emplace_back(str);
3183 std::unique_ptr<Parser::DDLStmt>(
3188 }
else if (type ==
"ALTER_OPTIONS") {
3189 CHECK(ddl_payload.HasMember(
"options"));
3190 const auto& options = ddl_payload[
"options"];
3191 if (options.IsObject()) {
3192 for (
auto itr = options.MemberBegin(); itr != options.MemberEnd(); ++itr) {
3193 std::string* option_name =
new std::string(
json_str(itr->name));
3195 if (itr->value.IsString()) {
3196 std::string literal_string =
json_str(itr->value);
3201 int iVal = std::stoi(literal_string, &sz);
3202 if (sz == literal_string.size()) {
3207 }
else if (itr->value.IsInt() || itr->value.IsInt64()) {
3209 }
else if (itr->value.IsNull()) {
3212 throw std::runtime_error(
"Unable to handle literal for " + *option_name);
3214 CHECK(literal_value);
3217 std::unique_ptr<Parser::DDLStmt>(
3223 CHECK(options.IsNull());
3232 std::shared_ptr<const Catalog_Namespace::SessionInfo> session_ptr)
3235 throw std::runtime_error(
"Unsupported command: ALTER FOREIGN TABLE");
3238 CHECK(ddl_payload.HasMember(
"tableName"));
3239 CHECK(ddl_payload[
"tableName"].IsString());
3240 CHECK(ddl_payload.HasMember(
"alterType"));
3241 CHECK(ddl_payload[
"alterType"].IsString());
3242 if (ddl_payload[
"alterType"] ==
"RENAME_TABLE") {
3243 CHECK(ddl_payload.HasMember(
"newTableName"));
3244 CHECK(ddl_payload[
"newTableName"].IsString());
3245 }
else if (ddl_payload[
"alterType"] ==
"RENAME_COLUMN") {
3246 CHECK(ddl_payload.HasMember(
"oldColumnName"));
3247 CHECK(ddl_payload[
"oldColumnName"].IsString());
3248 CHECK(ddl_payload.HasMember(
"newColumnName"));
3249 CHECK(ddl_payload[
"newColumnName"].IsString());
3250 }
else if (ddl_payload[
"alterType"] ==
"ALTER_OPTIONS") {
3251 CHECK(ddl_payload.HasMember(
"options"));
3252 CHECK(ddl_payload[
"options"].IsObject());
3254 UNREACHABLE() <<
"Not a valid alter foreign table command: "
3255 << ddl_payload[
"alterType"].GetString();
3260 if (read_only_mode) {
3261 throw std::runtime_error(
"ALTER FOREIGN TABLE invalid in read only mode.");
3265 std::string alter_type = ddl_payload[
"alterType"].GetString();
3271 if (alter_type ==
"RENAME_TABLE") {
3278 const std::string& table_name = ddl_payload[
"tableName"].GetString();
3279 auto [td, td_with_lock] =
3280 get_table_descriptor_with_lock<lockmgr::WriteLock>(catalog, table_name,
false);
3286 throw std::runtime_error(
3287 "Current user does not have the privilege to alter foreign table: " + table_name);
3290 auto table_data_write_lock =
3293 CHECK(foreign_table);
3296 if (alter_type ==
"RENAME_TABLE") {
3298 }
else if (alter_type ==
"RENAME_COLUMN") {
3300 }
else if (alter_type ==
"ALTER_OPTIONS") {
3311 const std::string& table_name = ddl_payload[
"tableName"].GetString();
3312 const std::string& new_table_name = ddl_payload[
"newTableName"].GetString();
3313 if (
cat.getForeignTable(new_table_name)) {
3314 throw std::runtime_error(
"Foreign table with name \"" + table_name +
3315 "\" can not be renamed to \"" + new_table_name +
"\". " +
3316 "A different table with name \"" + new_table_name +
3317 "\" already exists.");
3319 cat.renameTable(foreign_table, new_table_name);
3326 const std::string& old_column_name = ddl_payload[
"oldColumnName"].GetString();
3327 const std::string& new_column_name = ddl_payload[
"newColumnName"].GetString();
3328 auto column =
cat.getMetadataForColumn(foreign_table->
tableId, old_column_name);
3330 throw std::runtime_error(
"Column with name \"" + old_column_name +
3331 "\" can not be renamed to \"" + new_column_name +
"\". " +
3332 "Column with name \"" + old_column_name +
3333 "\" does not exist.");
3335 if (
cat.getMetadataForColumn(foreign_table->
tableId, new_column_name)) {
3336 throw std::runtime_error(
"Column with name \"" + old_column_name +
3337 "\" can not be renamed to \"" + new_column_name +
"\". " +
3338 "A column with name \"" + new_column_name +
3339 "\" already exists.");
3341 cat.renameColumn(foreign_table, column, new_column_name);
3347 const std::string& table_name = ddl_payload[
"tableName"].GetString();
3349 auto new_options_map =
3353 cat.setForeignTableOptions(table_name, new_options_map,
false);
3358 std::shared_ptr<Catalog_Namespace::SessionInfo const> session_ptr)
3361 if (ddl_payload.HasMember(
"tableNames")) {
3362 CHECK(ddl_payload[
"tableNames"].IsArray());
3363 for (
auto const& tablename_def : ddl_payload[
"tableNames"].GetArray()) {
3364 CHECK(tablename_def.IsString());
3370 auto table_names =
session_ptr_->get_catalog_ptr()->getTableNamesForUser(
3374 if (ddl_payload.HasMember(
"tableNames")) {
3375 std::vector<std::string> filtered_names;
3376 for (
const auto& tablename_def : ddl_payload[
"tableNames"].GetArray()) {
3377 std::string filter_name = tablename_def.GetString();
3378 if (std::find(table_names.begin(), table_names.end(), filter_name) !=
3379 table_names.end()) {
3380 filtered_names.emplace_back(filter_name);
3382 throw std::runtime_error(
"Can not show disk cache usage for table: " +
3383 filter_name +
". Table does not exist.");
3386 return filtered_names;
3400 const auto disk_cache = cat_ptr->getDataMgr().getPersistentStorageMgr()->getDiskCache();
3402 throw std::runtime_error{
"Disk cache not enabled. Cannot show disk cache usage."};
3406 std::vector<std::string> labels{
"table name",
"current cache size"};
3407 std::vector<TargetMetaInfo> label_infos;
3411 std::vector<RelLogicalValues::RowValues> logical_values;
3417 const std::string& table_name) {
3418 auto table_cache_size =
3419 disk_cache->getSpaceReservedByTable(cat_ptr->getDatabaseId(), td->tableId);
3422 logical_values.back().emplace_back(
genLiteralStr(table_name));
3426 std::shared_ptr<ResultSet> rSet = std::shared_ptr<ResultSet>(
3434 std::shared_ptr<Catalog_Namespace::SessionInfo const> session_ptr)
3437 if (ddl_payload.HasMember(
"userNames")) {
3438 CHECK(ddl_payload[
"userNames"].IsArray());
3439 for (
const auto& user_name : ddl_payload[
"userNames"].GetArray()) {
3440 CHECK(user_name.IsString());
3443 CHECK(ddl_payload.HasMember(
"all"));
3444 CHECK(ddl_payload[
"all"].IsBool());
3456 bool all = ddl_payload.HasMember(
"all") ? ddl_payload[
"all"].GetBool() :
false;
3457 if (all && !
self.isSuper) {
3458 throw std::runtime_error(
3459 "SHOW ALL USER DETAILS is only available to superusers. (Try SHOW USER "
3460 "DETAILS instead?)");
3464 std::vector<TargetMetaInfo> label_infos;
3474 std::vector<RelLogicalValues::RowValues> logical_values;
3481 std::map<std::string, Catalog_Namespace::UserMetadata> user_map;
3482 auto user_list = !all ? sys_cat.getAllUserMetadata(
cat->getDatabaseId())
3483 : sys_cat.getAllUserMetadata();
3484 for (
auto& user : user_list) {
3485 if (user.can_login ||
self.isSuper) {
3486 user_map[user.userName] = user;
3490 if (ddl_payload.HasMember(
"userNames")) {
3491 std::map<std::string, Catalog_Namespace::UserMetadata> user_map2;
3492 for (
const auto& user_name_json : ddl_payload[
"userNames"].GetArray()) {
3493 std::string user_name = user_name_json.GetString();
3494 auto uit = user_map.find(user_name);
3495 if (uit == user_map.end()) {
3496 throw std::runtime_error(
"User \"" + user_name +
"\" not found. ");
3498 user_map2[uit->first] = uit->second;
3500 user_map = user_map2;
3504 std::unordered_set<std::string> visible_databases;
3505 if (!
self.isSuper) {
3506 for (
const auto& dbsum : dbsums) {
3507 visible_databases.insert(dbsum.dbName);
3511 for (
const auto& [user_name, user] : user_map) {
3515 if (sys_cat.getMetadataForDBById(user.defaultDbId, db)) {
3516 if (
self.isSuper || visible_databases.count(db.
dbName)) {
3526 logical_values.back().emplace_back(
genLiteralStr(user.userName));
3538 CHECK_EQ(logical_values.size(), user_map.size());
3539 if (logical_values.size() >= 1U) {
3540 CHECK_EQ(logical_values[0].size(), label_infos.size());
3542 std::shared_ptr<ResultSet> rSet = std::shared_ptr<ResultSet>(
3550 std::shared_ptr<Catalog_Namespace::SessionInfo const> session_ptr)
3553 CHECK(ddl_payload[
"userName"].IsString());
3554 CHECK(ddl_payload[
"effective"].IsBool());
3566 std::vector<TargetMetaInfo> label_infos;
3567 std::vector<std::string> labels{
"ROLES"};
3571 std::vector<RelLogicalValues::RowValues> logical_values;
3572 std::vector<std::string> roles_list;
3574 std::string user_name = ddl_payload[
"userName"].GetString();
3575 bool effective = ddl_payload[
"effective"].GetBool();
3576 if (user_name.empty()) {
3577 user_name =
self.userName;
3580 bool is_user = sys_cat.getMetadataForUser(user_name, user);
3581 if (!
self.isSuper) {
3583 if (
self.userId != user.
userId) {
3584 throw std::runtime_error(
3585 "Only a superuser is authorized to request list of roles granted to another "
3589 if (!sys_cat.isRoleGrantedToGrantee(
3590 self.userName, user_name,
false)) {
3591 throw std::runtime_error(
3592 "Only a superuser is authorized to request list of roles granted to a role "
3593 "they don't have.");
3598 auto s = sys_cat.getCreatedRoles();
3599 roles_list.insert(roles_list.end(), s.begin(), s.end());
3601 roles_list = sys_cat.getRoles(user_name, effective);
3603 for (
const std::string& role_name : roles_list) {
3605 logical_values.back().emplace_back(
genLiteralStr(role_name));
3609 std::shared_ptr<ResultSet> rSet = std::shared_ptr<ResultSet>(
3617 std::shared_ptr<Catalog_Namespace::SessionInfo const> session_ptr)
3620 CHECK(ddl_payload.HasMember(
"all"));
3621 CHECK(ddl_payload[
"all"].IsBool());
3622 CHECK(ddl_payload.HasMember(
"oldOwners"));
3623 CHECK(ddl_payload[
"oldOwners"].IsArray());
3624 for (
const auto& old_owner : ddl_payload[
"oldOwners"].GetArray()) {
3625 CHECK(old_owner.IsString());
3628 CHECK(ddl_payload.HasMember(
"newOwner"));
3629 CHECK(ddl_payload[
"newOwner"].IsString());
3630 new_owner_ = ddl_payload[
"newOwner"].GetString();
3631 all_ = ddl_payload[
"all"].GetBool();
3637 if (read_only_mode) {
3638 throw std::runtime_error(
"REASSIGN OWNER invalid in read only mode.");
3641 throw std::runtime_error{
3642 "Only super users can reassign ownership of database objects."};
3646 for (
auto& catalog : catalogs) {
ExecutionResult execute(bool read_only_mode) override
bool contains(const T &container, const U &element)
std::list< ColumnAltered > altered_columns
int32_t maxRollbackEpochs
ShowForeignServersCommand(const DdlCommandData &ddl_data, std::shared_ptr< Catalog_Namespace::SessionInfo const > session_ptr)
static constexpr const char * WS_SERVER_ACCESS_LOGS_SYS_TABLE_NAME
void alterGeoColumnData(const TableDescriptor *td, const std::list< std::pair< const ColumnDescriptor *, std::list< const ColumnDescriptor * >>> &geo_src_dst_cds)
ExecutionResult execute(bool read_only_mode) override
ExecutionResult execute(bool read_only_mode) override
std::vector< int > ChunkKey
ShowRolesCommand(const DdlCommandData &ddl_data, std::shared_ptr< Catalog_Namespace::SessionInfo const > session_ptr)
std::list< ColumnDescriptor > renamed_columns
static constexpr const char * SERVER_LOGS_SYS_TABLE_NAME
ExecutionResult execute(bool read_only_mode) override
std::vector< std::string > getFilteredModelNames()
AlterForeignServerCommand(const DdlCommandData &ddl_data, std::shared_ptr< Catalog_Namespace::SessionInfo const > session_ptr)
void cleanupRecoveryInfo(const TableDescriptor *td)
static std::vector< TableFunction > get_table_funcs()
std::pair< std::vector< double >, std::vector< std::vector< double > > > extractExtraMetadata(std::shared_ptr< AbstractMLModel > model, std::vector< TargetMetaInfo > &label_infos) const
AlterTableAlterColumnCommand(const DdlCommandData &ddl_data, std::shared_ptr< Catalog_Namespace::SessionInfo const > session_ptr)
void alterOptions(const foreign_storage::ForeignTable &foreign_table)
uint64_t total_data_page_count
const std::string getTargetQuerySessionToKill() const
declare this class scoped local to avoid exposing rapidjson in the header file
std::vector< Catalog * > getCatalogsForAllDbs()
ShowCreateTableCommand(const DdlCommandData &ddl_data, std::shared_ptr< Catalog_Namespace::SessionInfo const > session_ptr)
JsonColumnSqlType(const rapidjson::Value &data_type)
static const AccessPrivileges DROP_SERVER
ShowCreateServerCommand(const DdlCommandData &ddl_data, std::shared_ptr< Catalog_Namespace::SessionInfo const > session_ptr)
void validate_alter_type_allowed(const std::string &colname, const SQLTypeInfo &src, const SQLTypeInfo &dst)
std::unique_ptr< DdlCommandData > ddl_data_
std::string getOptionsAsJsonString() const
static std::vector< ExtensionFunction > get_ext_funcs(const std::string &name)
class for a per-database catalog. also includes metadata for the current database and the current use...
const std::string commandStr() const
void clearInMemoryData(const TableDescriptor *td, const TypePairs &src_dst_cds)
ExecutionResult execute(bool read_only_mode) override
static TimeT::rep execution(F func, Args &&...args)
ExecutionResult execute(bool read_only_mode) override
CompareResult compare_column_descriptors(const ColumnDescriptor *lhs, const ColumnDescriptor *rhs)
uint32_t metadata_file_count
void set_column_descriptor(ColumnDescriptor &cd, const ColumnDef *coldef)
ExecutionResult execute(bool read_only_mode) override
static const AccessPrivileges ALTER_TABLE
ExecutionResult execute(bool read_only_mode) override
AlterTableAlterColumnCommandRecoveryMgr::RecoveryInfo recovery_info_
auto getExecuteReadLock()
CreateForeignServerCommand(const DdlCommandData &ddl_data, std::shared_ptr< Catalog_Namespace::SessionInfo const > session_ptr)
RecoveryParamFilepathInfo getRecoveryFilepathInfo(const int32_t table_id=-1)
Data_Namespace::DataMgr & getDataMgr() const
std::unique_ptr< RexLiteral > genLiteralDouble(double val)
void validateAlterOptions(const OptionsMap &options_map) const
Verifies that the given options map only contains options that can be legally altered.
ExecutionResult execute(bool read_only_mode) override
std::pair< std::list< ColumnDescriptor >, std::list< ColumnDescriptor > > get_alter_column_src_dst_cds(const std::list< Parser::ColumnDef > &columns, Catalog_Namespace::Catalog &catalog, const TableDescriptor *td)
void renameForeignServer()
ShowDatabasesCommand(const DdlCommandData &ddl_data, std::shared_ptr< Catalog_Namespace::SessionInfo const > session_ptr)
ExecutionResult execute(bool read_only_mode) override
std::vector< MLModelMetadata > getModelMetadata() const
ExecutionResult execute(bool read_only_mode) override
void revokeDBObjectPrivilegesFromAll(DBObject object, Catalog *catalog)
const std::string json_str(const rapidjson::Value &obj) noexcept
static const AccessPrivileges SERVER_USAGE
static std::shared_ptr< QueryState > create(ARGS &&...args)
DropForeignTableCommand(const DdlCommandData &ddl_data, std::shared_ptr< Catalog_Namespace::SessionInfo const > session_ptr)
ExecutionResult execute(bool read_only_mode) override
Driver for running cleanup processes on a table. TableOptimizer provides functions for various cleanu...
void throw_reserved_server_prefix_exception()
CreateForeignTableCommand(const DdlCommandData &ddl_data, std::shared_ptr< Catalog_Namespace::SessionInfo const > session_ptr)
void validateSupportedOptionKeys(const OptionsMap &options_map) const
Verifies that the options_map contains the keys required by a foreign table; including those specifie...
The InsertOrderFragmenter is a child class of AbstractFragmenter, and fragments data in insert order...
void add_table_details(std::vector< RelLogicalValues::RowValues > &logical_values, const TableDescriptor *logical_table, const AggregratedStorageStats &agg_storage_stats)
void aggregate(const File_Namespace::StorageStats &storage_stats)
std::optional< uint64_t > total_free_data_page_count
void refresh_foreign_table(Catalog_Namespace::Catalog &catalog, const std::string &table_name, const bool evict_cached_entries)
ShowTablesCommand(const DdlCommandData &ddl_data, std::shared_ptr< Catalog_Namespace::SessionInfo const > session_ptr)
ShowDiskCacheUsageCommand(const DdlCommandData &ddl_data, std::shared_ptr< Catalog_Namespace::SessionInfo const > session_ptr)
bool isForeignTable() const
AggregatedResult query(QueryStateProxy, std::string &sql_query_string, std::vector< size_t > outer_frag_indices, bool validate_only, bool allow_interrupt)
ExecutionResult execute(bool read_only_mode) override
std::list< ColumnDescriptor > updated_dict_cds
void createDBObject(const UserMetadata &user, const std::string &objectName, DBObjectType type, const Catalog_Namespace::Catalog &catalog, int32_t objectId=-1)
void alterColumns(const TableDescriptor *td, const TypePairs &src_dst_cds)
void set_headers_with_type(std::vector< TargetMetaInfo > &label_infos, const std::vector< std::tuple< std::string, SQLTypes, bool >> &headers)
DistributedExecutionDetails getDistributedExecutionDetails() const
std::pair< std::string, std::string > getSessionParameter() const
EvaluateModelCommand(const DdlCommandData &ddl_data, std::shared_ptr< Catalog_Namespace::SessionInfo const > session_ptr)
std::unique_lock< WrapperType< std::shared_mutex >> ExecutorWriteLock
ExecutionResult execute(bool read_only_mode) override
void validate_non_duplicate_column(const std::string &column_name, std::unordered_set< std::string > &upper_column_names)
ExecutionResult execute(bool read_only_mode) override
std::set< std::string > old_owners_
bool isShowQueries() const
static constexpr const char * REQUEST_LOGS_SYS_TABLE_NAME
void alterNonGeoColumnData(const TableDescriptor *td, const std::list< const ColumnDescriptor * > &cds)
void set_column_descriptor(const std::string &column_name, ColumnDescriptor &cd, SqlType *column_type, const bool not_null, const Encoding *encoding, const std::string *default_value)
static std::shared_ptr< Executor > getExecutor(const ExecutorId id, const std::string &debug_dir="", const std::string &debug_file="", const SystemParameters &system_parameters=SystemParameters())
static OptionsMap createOptionsMap(const rapidjson::Value &json_options)
Creates an options map from given options. Converts options that must be upper case appropriately...
static const AccessPrivileges ALTER_SERVER
std::unique_ptr< RexLiteral > genLiteralBigInt(int64_t val)
This file contains the class specification and related data structures for Catalog.
bool g_restrict_ml_model_metadata_to_superusers
ExecutionResult execute(bool read_only_mode) override
void setTableDetails(const std::string &table_name, TableDescriptor &td, const std::list< ColumnDescriptor > &columns)
bool isAlterSystemClear() const
ExecutionResult execute(bool read_only_mode) override
const DdlCommandData & ddl_data_
std::list< std::pair< const ColumnDescriptor *, std::list< const ColumnDescriptor * > > > get_alter_column_geo_pairs_from_src_dst_pairs_phys_cds(const AlterTableAlterColumnCommand::TypePairs &src_dst_cds, const std::list< std::list< ColumnDescriptor >> &phys_cds)
bool is_default_server(const std::string &server_name)
ShowModelFeatureDetailsCommand(const DdlCommandData &ddl_data, std::shared_ptr< Catalog_Namespace::SessionInfo const > session_ptr)
std::shared_lock< WrapperType< std::shared_mutex >> ExecutorReadLock
static SysCatalog & instance()
This file contains the class specification and related data structures for SysCatalog.
std::vector< TargetMetaInfo > prepareLabelInfos() const
int32_t validate_and_get_fragment_size(const std::string &fragment_size_str)
void populateAndWriteRecoveryInfo(const TableDescriptor *td, const TypePairs &src_dst_cds)
std::list< std::pair< ColumnDescriptor, ColumnDescriptor > > src_dst_cds
Classes representing a parse tree.
void checkpoint(const TableDescriptor *td, const TypePairs &src_dst_cds)
ExecutionResult execute(bool read_only_mode) override
ShowTableDetailsCommand(const DdlCommandData &ddl_data, std::shared_ptr< Catalog_Namespace::SessionInfo const > session_ptr)
void setColumnDetails(std::list< ColumnDescriptor > &columns)
const rapidjson::Value & query() const
DropForeignServerCommand(const DdlCommandData &ddl_data, std::shared_ptr< Catalog_Namespace::SessionInfo const > session_ptr)
static const AccessPrivileges DROP_TABLE
std::string ddl_statement_
std::optional< uint64_t > total_free_metadata_page_count
ExecutionResult execute(bool read_only_mode) override
void populateOptionsMap(OptionsMap &&options_map, bool clear=false)
void getChunkMetadataVecForKeyPrefix(ChunkMetadataVector &chunkMetadataVec, const ChunkKey &keyPrefix)
const int64_t json_i64(const rapidjson::Value &obj) noexcept
std::list< ColumnDef > get_columns_from_json_payload(const std::string &payload_key, const rapidjson::Value &payload)
bool hasAlterServerPrivileges()
std::list< const ColumnDescriptor * > prepareColumns(const TableDescriptor *td, const TypePairs &src_dst_cds)
const rapidjson::Value & extractPayload(const DdlCommandData &ddl_data)
static std::unordered_set< std::string > get_udfs_name(const bool is_runtime)
std::unique_ptr< RexLiteral > genLiteralTimestamp(time_t val)
AlterDatabaseCommand(const DdlCommandData &ddl_data, std::shared_ptr< Catalog_Namespace::SessionInfo const > session_ptr)
bool isShowUserSessions() const
const ColumnDescriptor * getMetadataForColumn(int tableId, const std::string &colName) const
ExecutionResult execute(bool read_only_mode) override
DBSummaryList getDatabaseListForUser(const UserMetadata &user)
Checked json field retrieval.
void setForeignServerOptions()
int getDatabaseId() const
uint64_t total_metadata_page_count
static const AccessPrivileges CREATE_SERVER
void updateResultSet(const std::string &query_ra, RType type, bool success=true)
void vacuumDeletedRows() const
Compacts fragments to remove deleted rows. When a row is deleted, a boolean deleted system column is ...
std::string recoveryFilepath(const RecoveryParamFilepathInfo &filepath_info)
bool is_dict_encoded_type() const
std::unique_ptr< RexLiteral > genLiteralBoolean(bool val)
void validate_non_reserved_keyword(const std::string &column_name)
specifies the content in-memory of a row in the column metadata table
OUTPUT transform(INPUT const &input, FUNC const &func)
void collectExpectedCatalogChanges(const TableDescriptor *td, const TypePairs &src_dst_cds)
AggregationType aggregation_type
void alterColumnTypes(const TableDescriptor *td, const TypePairs &src_dst_cds)
std::list< std::list< ColumnDescriptor > > prepareGeoColumns(const TableDescriptor *td, const TypePairs &src_dst_cds)
std::shared_ptr< AbstractMLModel > getModel(const std::string &model_name) const
static const AccessPrivileges CREATE_TABLE
std::vector< const TableDescriptor * > getPhysicalTablesDescriptors(const TableDescriptor *logical_table_desc, bool populate_fragmenter=true) const
ExecutionResult execute(bool read_only_mode) override
void set_default_table_attributes(const std::string &table_name, TableDescriptor &td, const int32_t column_count)
std::shared_ptr< Fragmenter_Namespace::AbstractFragmenter > fragmenter
File_Namespace::GlobalFileMgr * getGlobalFileMgr() const
static ResultSet * create(std::vector< TargetMetaInfo > &label_infos, std::vector< RelLogicalValues::RowValues > &logical_values)
void set_comp_param(int p)
JsonColumnEncoding(const rapidjson::Value &data_type)
bool isAlterSessionSet() const
const rapidjson::Value & payload() const
std::shared_ptr< Catalog_Namespace::SessionInfo const > session_ptr_
void check_alter_table_privilege(const Catalog_Namespace::SessionInfo &session, const TableDescriptor *td)
std::vector< std::string > getFilteredTableNames()
DdlCommandExecutor(const std::string &ddl_statement, std::shared_ptr< Catalog_Namespace::SessionInfo const > session_ptr)
ShowModelDetailsCommand(const DdlCommandData &ddl_data, std::shared_ptr< Catalog_Namespace::SessionInfo const > session_ptr)
ExecutionResult execute(bool read_only_mode)
AggregratedStorageStats get_agg_storage_stats(const TableDescriptor *td, const Catalog_Namespace::Catalog *catalog)
ExecutionResult execute(bool read_only_mode) override
rapidjson::Document ddl_query
uint64_t total_metadata_file_size
bool isTemporaryTable() const
std::string returnQueueAction() const
AlterTableAlterColumnCommandRecoveryMgr recovery_mgr_
bool table_is_temporary(const TableDescriptor *const td)
void changeForeignServerOwner()
static WriteLock getWriteLockForTable(const Catalog_Namespace::Catalog &cat, const std::string &table_name)
AlterTableCommand(const DdlCommandData &ddl_data, std::shared_ptr< Catalog_Namespace::SessionInfo const > session_ptr)
ExecutionResult execute(bool read_only_mode) override
void setStringDictKey(const shared::StringDictKey &dict_key)
Basic constructors and methods of the row set interface.
std::tuple< const TableDescriptor *, std::unique_ptr< lockmgr::TableSchemaLockContainer< LockType > > > get_table_descriptor_with_lock(Catalog_Namespace::Catalog &cat, const std::string &table_name, const bool populate_fragmenter)
void renameDatabase(std::string const &old_name, std::string const &new_name)
uint64_t total_data_file_size
AlterTableAlterColumnCommand::TypePairs get_alter_column_pairs_from_src_dst_cds(std::list< ColumnDescriptor > &src_cds, std::list< ColumnDescriptor > &dst_cds)
~DdlCommandDataImpl() override
static const AccessPrivileges ACCESS
ReassignOwnedCommand(const DdlCommandData &ddl_data, std::shared_ptr< Catalog_Namespace::SessionInfo const > session_ptr)
std::vector< std::string > getFilteredTableNames()
bool g_enable_ml_functions
void validate_alter_type_metadata(const Catalog_Namespace::Catalog &catalog, const TableDescriptor *td, const ColumnDescriptor &cd)
HOST DEVICE int get_comp_param() const
static std::unique_ptr< RexLiteral > genLiteralStr(std::string val)
ExecutionResult execute(bool read_only_mode) override
std::string returnCacheType() const
void validate_table_type(const TableDescriptor *td, const TableType expected_table_type, const std::string &command)
const ForeignServer * foreign_server
void cleanup(const TableDescriptor *td, const TypePairs &src_dst_cds)
void renameTable(const foreign_storage::ForeignTable *foreign_table)
ShowFunctionsCommand(const DdlCommandData &ddl_data, std::shared_ptr< Catalog_Namespace::SessionInfo const > session_ptr)
const std::vector< double > & getCoefs() const
alter_column_shared::TypePairs TypePairs
#define DEBUG_TIMER(name)
const std::vector< double > & getEigenvalues() const
ExecutionResult execute(bool read_only_mode) override
std::unique_ptr< ColumnDef > column_from_json(const rapidjson::Value &element)
std::vector< std::string > getModelNames() const
static void clearExternalCaches(bool for_update, const TableDescriptor *td, const int current_db_id)
void exec_for_tables_which_exist(const std::vector< std::string > &table_names, Catalog_Namespace::Catalog *cat_ptr, Func func)
ExecutionResult execute(bool read_only_mode) override
std::vector< RelLogicalValues::RowValues > prepareLogicalValues(const MLModelMetadata &model_metadata, const std::vector< std::vector< std::string >> &cat_sub_features, std::vector< double > &extra_metadata, const std::vector< std::vector< double >> &eigenvectors, const std::vector< int64_t > &inverse_permutations) const
auto getExecuteWriteLock()
void vacuum_table_if_required(const Catalog_Namespace::Catalog &catalog, const TableDescriptor *td)
bool is_regression_model(const MLModelType model_type)
std::list< DBSummary > DBSummaryList
std::list< ColumnDescriptor > getColumnDescriptors(AggregatedResult &result, bool for_create)
bool is_dict_encoded_string() const
AggregratedStorageStats(const File_Namespace::StorageStats &storage_stats)
std::list< ColumnDescriptor > added_columns
bool any_of(std::vector< Analyzer::Expr * > const &target_exprs)
const TableDescriptor * getMetadataForTable(const std::string &tableName, const bool populateFragmenter=true) const
Returns a pointer to a const TableDescriptor struct matching the provided tableName.
std::shared_ptr< Catalog_Namespace::SessionInfo const > session_ptr_
static constexpr ExecutorId UNITARY_EXECUTOR_ID
std::vector< std::unique_ptr< const RexScalar >> RowValues
ExecutionResult execute(bool read_only_mode) override
ExecutionLocation execution_location
bool isAlterSystemControlExecutorQueue() const
void rollback(const TableDescriptor *td, const RecoveryInfo ¶m)
const rapidjson::Value * extractFilters(const rapidjson::Value &payload)
AlterForeignTableCommand(const DdlCommandData &ddl_data, std::shared_ptr< Catalog_Namespace::SessionInfo const > session_ptr)
HOST DEVICE bool get_notnull() const
bool isAggregator() const
void renameColumn(const foreign_storage::ForeignTable *foreign_table)
const std::array< std::string, 3 > kReservedServerPrefixes
void writeSerializedRecoveryInformation(const RecoveryInfo ¶m, const RecoveryParamFilepathInfo &filepath_info)
std::string commandStr() override
static constexpr char const * FOREIGN_TABLE
ShowRuntimeFunctionsCommand(const DdlCommandData &ddl_data, std::shared_ptr< Catalog_Namespace::SessionInfo const > session_ptr)
static constexpr const char * WS_SERVER_LOGS_SYS_TABLE_NAME
ShowUserDetailsCommand(const DdlCommandData &ddl_data, std::shared_ptr< Catalog_Namespace::SessionInfo const > session_ptr)
void setForeignServerDataWrapper()
static ReadLock getReadLockForTable(Catalog_Namespace::Catalog &cat, const std::string &table_name)
ShowRuntimeTableFunctionsCommand(const DdlCommandData &ddl_data, std::shared_ptr< Catalog_Namespace::SessionInfo const > session_ptr)
RefreshForeignTablesCommand(const DdlCommandData &ddl_data, std::shared_ptr< Catalog_Namespace::SessionInfo const > session_ptr)
ExecutionResult execute(bool read_only_mode) override
ShowModelsCommand(const DdlCommandData &ddl_data, std::shared_ptr< Catalog_Namespace::SessionInfo const > session_ptr)
ShowTableFunctionsCommand(const DdlCommandData &ddl_data, std::shared_ptr< Catalog_Namespace::SessionInfo const > session_ptr)