OmniSciDB  72c90bc290
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Parser Namespace Reference

Namespaces

 anonymous_namespace{ParserNode.cpp}
 
 Compress
 

Classes

class  Node
 
class  SQLType
 
class  Expr
 
class  Literal
 
class  NullLiteral
 
class  StringLiteral
 
class  IntLiteral
 
class  FixedPtLiteral
 
class  FloatLiteral
 
class  DoubleLiteral
 
class  TimestampLiteral
 
class  UserLiteral
 
class  ArrayLiteral
 
class  OperExpr
 
class  SubqueryExpr
 
class  IsNullExpr
 
class  InExpr
 
class  InSubquery
 
class  InValues
 
class  BetweenExpr
 
class  CharLengthExpr
 
class  CardinalityExpr
 
class  LikeExpr
 
class  RegexpExpr
 
class  WidthBucketExpr
 
class  LikelihoodExpr
 
class  ExistsExpr
 
class  ColumnRef
 
class  FunctionRef
 
class  CastExpr
 
class  ExprPair
 
class  CaseExpr
 
class  TableRef
 
class  Stmt
 
class  DMLStmt
 
class  DDLStmt
 
class  TableElement
 
class  ColumnConstraintDef
 
class  CompressDef
 
class  ColumnDef
 
class  TableConstraintDef
 
class  UniqueDef
 
class  ForeignKeyDef
 
class  CheckDef
 
class  SharedDictionaryDef
 
class  ShardKeyDef
 
class  NameValueAssign
 
class  CreateTableBaseStmt
 
class  CreateTableStmt
 
class  QueryConnector
 
class  LocalQueryConnector
 
class  CreateDataframeStmt
 
class  InsertIntoTableAsSelectStmt
 
class  CreateTableAsSelectStmt
 
class  DropTableStmt
 
class  TruncateTableStmt
 
class  OptimizeTableStmt
 
class  ValidateStmt
 
class  RenameDBStmt
 
class  RenameUserStmt
 
class  RenameTableStmt
 
class  RenameColumnStmt
 
class  AddColumnStmt
 
class  DropColumnStmt
 
class  AlterTableParamStmt
 
class  DumpRestoreTableStmtBase
 
class  DumpTableStmt
 
class  RestoreTableStmt
 
class  CopyTableStmt
 
class  CreateRoleStmt
 
class  DropRoleStmt
 
class  GrantPrivilegesStmt
 
class  RevokePrivilegesStmt
 
class  ShowPrivilegesStmt
 
class  GrantRoleStmt
 
class  RevokeRoleStmt
 
class  QueryExpr
 
class  UnionQuery
 
class  SelectEntry
 
class  QuerySpec
 
class  OrderSpec
 
class  SelectStmt
 
class  ExportQueryStmt
 
class  CreateViewStmt
 
class  DropViewStmt
 
class  CreateDBStmt
 
class  DropDBStmt
 
class  CreateModelStmt
 
class  DropModelStmt
 
class  CreateUserStmt
 
class  AlterUserStmt
 
class  DropUserStmt
 
class  InsertStmt
 
class  ValuesList
 
class  InsertValuesStmt
 
class  Assignment
 
class  UpdateStmt
 
class  DeleteStmt
 
struct  DefaultValidate
 
struct  DefaultValidate< IntLiteral >
 
struct  PositiveOrZeroValidate
 
struct  DefaultValidate< StringLiteral >
 
struct  CaseSensitiveValidate
 

Typedefs

using SubstituteMap = std::map< std::string, std::string >
 

Functions

bool check_session_interrupted (const QuerySessionId &query_session, Executor *executor)
 
std::vector< int > getTableChunkKey (const TableDescriptor *td, Catalog_Namespace::Catalog &catalog)
 
bool should_translate_strings (const std::shared_ptr< Analyzer::Expr > &lhs_expr, const std::shared_ptr< Analyzer::Expr > &rhs_expr)
 
SQLTypeInfo const & get_str_dict_cast_type (const SQLTypeInfo &lhs_type_info, const SQLTypeInfo &rhs_type_info, const Executor *executor)
 
SQLTypeInfo common_string_type (const SQLTypeInfo &lhs_type_info, const SQLTypeInfo &rhs_type_info, const Executor *executor)
 
std::unique_ptr< ColumnDefcolumn_from_json (const rapidjson::Value &element)
 
std::list< ColumnDefget_columns_from_json_payload (const std::string &payload_key, const rapidjson::Value &payload)
 
std::string write_model_params_to_json (const std::string &predicted, const std::vector< std::string > &features, const std::string &training_query, const double data_split_train_fraction, const double data_split_eval_fraction, const std::vector< int64_t > &feature_permutations)
 
std::shared_ptr< ResultSetgetResultSet (QueryStateProxy query_state_proxy, const std::string select_stmt, std::vector< TargetMetaInfo > &targets, bool validate_only=false, std::vector< size_t > outer_fragment_indices={}, bool allow_interrupt=false)
 
bool repair_type (std::list< std::unique_ptr< NameValueAssign >> &options)
 
void check_alter_table_privilege (const Catalog_Namespace::SessionInfo &session, const TableDescriptor *td)
 
void set_column_descriptor (ColumnDescriptor &cd, const ColumnDef *coldef)
 
std::vector< std::string > splitObjectHierName (const std::string &hierName)
 
std::string extractObjectNameFromHierName (const std::string &objectHierName, const std::string &objectType, const Catalog_Namespace::Catalog &cat)
 
static std::pair
< AccessPrivileges,
DBObjectType
parseStringPrivs (const std::string &privs, const DBObjectType &objectType, const std::string &object_name)
 
static DBObject createObject (const std::string &objectName, DBObjectType objectType)
 
static void verifyObject (Catalog_Namespace::Catalog &sessionCatalog, const std::string &objectName, DBObjectType objectType, const std::string &command)
 
static void checkStringLiteral (const std::string &option_name, const std::unique_ptr< NameValueAssign > &p)
 
static bool readBooleanLiteral (const std::string &option_name, const std::unique_ptr< NameValueAssign > &p)
 
std::unique_ptr< Parser::Stmtcreate_stmt_for_query (const std::string &queryStr, const Catalog_Namespace::SessionInfo &session_info)
 
std::unique_ptr< Parser::Stmtcreate_stmt_for_json (const std::string &query_json)
 
void execute_stmt_for_json (const std::string &query_json, std::shared_ptr< Catalog_Namespace::SessionInfo const > session_ptr, bool read_only_mode)
 
int32_t validate_and_get_fragment_size (const std::string &fragment_size_str)
 
void parser_slistval_to_vector (std::list< std::string * > *l, std::vector< std::string > &v)
 

Typedef Documentation

using Parser::SubstituteMap = typedef std::map<std::string, std::string>

Definition at line 5170 of file ParserNode.cpp.

Function Documentation

void Parser::check_alter_table_privilege ( const Catalog_Namespace::SessionInfo session,
const TableDescriptor td 
)

Definition at line 5076 of file ParserNode.cpp.

References AccessPrivileges::ALTER_TABLE, Catalog_Namespace::SessionInfo::get_currentUser(), Catalog_Namespace::SessionInfo::getCatalog(), Catalog_Namespace::UserMetadata::isSuper, DBObject::loadKey(), DBObject::setPrivileges(), TableDBObjectType, TableDescriptor::tableName, TableDescriptor::userId, and Catalog_Namespace::UserMetadata::userId.

Referenced by AlterTableAlterColumnCommand::alterColumn(), Parser::AddColumnStmt::check_executable(), Parser::RenameTableStmt::execute(), Parser::RenameColumnStmt::execute(), Parser::DropColumnStmt::execute(), and Parser::AlterTableParamStmt::execute().

5077  {
5078  if (session.get_currentUser().isSuper ||
5079  session.get_currentUser().userId == td->userId) {
5080  return;
5081  }
5082  std::vector<DBObject> privObjects;
5083  DBObject dbObject(td->tableName, TableDBObjectType);
5084  dbObject.loadKey(session.getCatalog());
5085  dbObject.setPrivileges(AccessPrivileges::ALTER_TABLE);
5086  privObjects.push_back(dbObject);
5087  if (!SysCatalog::instance().checkPrivileges(session.get_currentUser(), privObjects)) {
5088  throw std::runtime_error("Current user does not have the privilege to alter table: " +
5089  td->tableName);
5090  }
5091 }
std::string tableName
static const AccessPrivileges ALTER_TABLE
Definition: DBObject.h:165
Catalog & getCatalog() const
Definition: SessionInfo.h:75
const UserMetadata & get_currentUser() const
Definition: SessionInfo.h:88
std::atomic< bool > isSuper
Definition: SysCatalog.h:107

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool Parser::check_session_interrupted ( const QuerySessionId query_session,
Executor executor 
)

Definition at line 106 of file ParserNode.cpp.

References g_enable_non_kernel_time_query_interrupt.

Referenced by Parser::InsertIntoTableAsSelectStmt::populateData().

106  {
107  // we call this function with unitary executor but is okay since
108  // we know the exact session info from a global session map object
109  // in the executor
112  executor->getSessionLock());
113  return executor->checkIsQuerySessionInterrupted(query_session, session_read_lock);
114  }
115  return false;
116 }
bool g_enable_non_kernel_time_query_interrupt
Definition: Execute.cpp:134
std::shared_lock< T > shared_lock

+ Here is the caller graph for this function:

static void Parser::checkStringLiteral ( const std::string &  option_name,
const std::unique_ptr< NameValueAssign > &  p 
)
static

Definition at line 6830 of file ParserNode.cpp.

References CHECK.

Referenced by Parser::CreateDBStmt::execute(), Parser::CreateUserStmt::execute(), and Parser::AlterUserStmt::execute().

6831  {
6832  CHECK(p);
6833  if (!dynamic_cast<const StringLiteral*>(p->get_value())) {
6834  throw std::runtime_error(option_name + " option must be a string literal.");
6835  }
6836 }
#define CHECK(condition)
Definition: Logger.h:291

+ Here is the caller graph for this function:

std::unique_ptr< ColumnDef > Parser::column_from_json ( const rapidjson::Value &  element)

Definition at line 3137 of file ParserNode.cpp.

References CHECK, json_bool(), json_i64(), json_str(), and to_sql_type().

Referenced by AlterTableCommand::execute(), get_columns_from_json_payload(), and Parser::anonymous_namespace{ParserNode.cpp}::parse_elements().

3137  {
3138  CHECK(element.HasMember("name"));
3139  auto col_name = std::make_unique<std::string>(json_str(element["name"]));
3140  CHECK(element.HasMember("sqltype"));
3141  const auto sql_types = to_sql_type(json_str(element["sqltype"]));
3142 
3143  // decimal / numeric precision / scale
3144  int precision = -1;
3145  int scale = -1;
3146  if (element.HasMember("precision")) {
3147  precision = json_i64(element["precision"]);
3148  }
3149  if (element.HasMember("scale")) {
3150  scale = json_i64(element["scale"]);
3151  }
3152 
3153  std::optional<int64_t> array_size;
3154  if (element.HasMember("arraySize")) {
3155  // We do not yet support geo arrays
3156  array_size = json_i64(element["arraySize"]);
3157  }
3158  std::unique_ptr<SQLType> sql_type;
3159  if (element.HasMember("subtype")) {
3160  CHECK(element.HasMember("coordinateSystem"));
3161  const auto subtype_sql_types = to_sql_type(json_str(element["subtype"]));
3162  sql_type =
3163  std::make_unique<SQLType>(subtype_sql_types,
3164  static_cast<int>(sql_types),
3165  static_cast<int>(json_i64(element["coordinateSystem"])),
3166  false);
3167  } else if (precision > 0 && scale > 0) {
3168  sql_type = std::make_unique<SQLType>(sql_types,
3169  precision,
3170  scale,
3171  /*is_array=*/array_size.has_value(),
3172  array_size ? *array_size : -1);
3173  } else if (precision > 0) {
3174  sql_type = std::make_unique<SQLType>(sql_types,
3175  precision,
3176  0,
3177  /*is_array=*/array_size.has_value(),
3178  array_size ? *array_size : -1);
3179  } else {
3180  sql_type = std::make_unique<SQLType>(sql_types,
3181  /*is_array=*/array_size.has_value(),
3182  array_size ? *array_size : -1);
3183  }
3184  CHECK(sql_type);
3185 
3186  CHECK(element.HasMember("nullable"));
3187  const auto nullable = json_bool(element["nullable"]);
3188  std::unique_ptr<ColumnConstraintDef> constraint_def;
3189  StringLiteral* str_literal = nullptr;
3190  if (element.HasMember("default") && !element["default"].IsNull()) {
3191  std::string* defaultval = new std::string(json_str(element["default"]));
3192  boost::algorithm::trim_if(*defaultval, boost::is_any_of(" \"'`"));
3193  str_literal = new StringLiteral(defaultval);
3194  }
3195 
3196  constraint_def = std::make_unique<ColumnConstraintDef>(/*notnull=*/!nullable,
3197  /*unique=*/false,
3198  /*primarykey=*/false,
3199  /*defaultval=*/str_literal);
3200  std::unique_ptr<CompressDef> compress_def;
3201  if (element.HasMember("encodingType") && !element["encodingType"].IsNull()) {
3202  std::string encoding_type = json_str(element["encodingType"]);
3203  CHECK(element.HasMember("encodingSize"));
3204  auto encoding_name = std::make_unique<std::string>(json_str(element["encodingType"]));
3205  compress_def = std::make_unique<CompressDef>(encoding_name.release(),
3206  json_i64(element["encodingSize"]));
3207  }
3208  return std::make_unique<ColumnDef>(col_name.release(),
3209  sql_type.release(),
3210  compress_def ? compress_def.release() : nullptr,
3211  constraint_def ? constraint_def.release() : nullptr);
3212 }
SQLTypes to_sql_type(const std::string &type_name)
const bool json_bool(const rapidjson::Value &obj) noexcept
Definition: JsonAccessors.h:51
const std::string json_str(const rapidjson::Value &obj) noexcept
Definition: JsonAccessors.h:46
const int64_t json_i64(const rapidjson::Value &obj) noexcept
Definition: JsonAccessors.h:41
#define CHECK(condition)
Definition: Logger.h:291

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

SQLTypeInfo Parser::common_string_type ( const SQLTypeInfo lhs_type_info,
const SQLTypeInfo rhs_type_info,
const Executor executor 
)

Definition at line 354 of file ParserNode.cpp.

References CHECK, shared::StringDictKey::dict_id, SQLTypeInfo::get_dimension(), get_str_dict_cast_type(), SQLTypeInfo::getStringDictKey(), SQLTypeInfo::is_dict_encoded_string(), SQLTypeInfo::is_none_encoded_string(), SQLTypeInfo::is_string(), SQLTypeInfo::set_dimension(), and TRANSIENT_DICT.

Referenced by Parser::CaseExpr::normalize().

356  {
357  CHECK(lhs_type_info.is_string());
358  CHECK(rhs_type_info.is_string());
359  if (lhs_type_info.is_dict_encoded_string() && rhs_type_info.is_dict_encoded_string()) {
360  const auto& lhs_dict_key = lhs_type_info.getStringDictKey();
361  const auto& rhs_dict_key = rhs_type_info.getStringDictKey();
362  if (lhs_dict_key == rhs_dict_key ||
363  (lhs_dict_key.db_id == rhs_dict_key.db_id &&
364  lhs_dict_key.dict_id == TRANSIENT_DICT(rhs_dict_key.dict_id))) {
365  return lhs_dict_key.dict_id <= rhs_dict_key.dict_id ? lhs_type_info : rhs_type_info;
366  }
367  return get_str_dict_cast_type(lhs_type_info, rhs_type_info, executor);
368  }
369  CHECK(lhs_type_info.is_none_encoded_string() || rhs_type_info.is_none_encoded_string());
370  SQLTypeInfo ret_ti =
371  rhs_type_info.is_none_encoded_string() ? lhs_type_info : rhs_type_info;
372  if (ret_ti.is_none_encoded_string()) {
373  ret_ti.set_dimension(
374  std::max(lhs_type_info.get_dimension(), rhs_type_info.get_dimension()));
375  }
376  return ret_ti;
377 }
void set_dimension(int d)
Definition: sqltypes.h:470
bool is_none_encoded_string() const
Definition: sqltypes.h:645
HOST DEVICE int get_dimension() const
Definition: sqltypes.h:393
#define CHECK(condition)
Definition: Logger.h:291
bool is_dict_encoded_string() const
Definition: sqltypes.h:641
bool is_string() const
Definition: sqltypes.h:559
#define TRANSIENT_DICT(ID)
Definition: sqltypes.h:322
SQLTypeInfo const & get_str_dict_cast_type(const SQLTypeInfo &lhs_type_info, const SQLTypeInfo &rhs_type_info, const Executor *executor)
Definition: ParserNode.cpp:331
const shared::StringDictKey & getStringDictKey() const
Definition: sqltypes.h:1055

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

std::unique_ptr< Parser::Stmt > Parser::create_stmt_for_json ( const std::string &  query_json)

Definition at line 7273 of file ParserNode.cpp.

References CHECK, UNREACHABLE, and VLOG.

Referenced by create_stmt_for_query(), QueryRunner::QueryRunner::createStatement(), and execute_stmt_for_json().

7273  {
7274  CHECK(!query_json.empty());
7275  VLOG(2) << "Parsing JSON DDL from Calcite: " << query_json;
7276  rapidjson::Document ddl_query;
7277  ddl_query.Parse(query_json);
7278  CHECK(ddl_query.IsObject());
7279  CHECK(ddl_query.HasMember("payload"));
7280  CHECK(ddl_query["payload"].IsObject());
7281  const auto& payload = ddl_query["payload"].GetObject();
7282  CHECK(payload.HasMember("command"));
7283  CHECK(payload["command"].IsString());
7284 
7285  const auto& ddl_command = std::string_view(payload["command"].GetString());
7286 
7287  Parser::Stmt* stmt = nullptr;
7288  if (ddl_command == "CREATE_TABLE") {
7289  stmt = new Parser::CreateTableStmt(payload);
7290  } else if (ddl_command == "DROP_TABLE") {
7291  stmt = new Parser::DropTableStmt(payload);
7292  } else if (ddl_command == "RENAME_TABLE") {
7293  stmt = new Parser::RenameTableStmt(payload);
7294  } else if (ddl_command == "ALTER_TABLE") {
7295  // no-op: fall-back to DdlCommandExecutor by returning a nullptr
7296  } else if (ddl_command == "TRUNCATE_TABLE") {
7297  stmt = new Parser::TruncateTableStmt(payload);
7298  } else if (ddl_command == "DUMP_TABLE") {
7299  stmt = new Parser::DumpTableStmt(payload);
7300  } else if (ddl_command == "RESTORE_TABLE") {
7301  stmt = new Parser::RestoreTableStmt(payload);
7302  } else if (ddl_command == "OPTIMIZE_TABLE") {
7303  stmt = new Parser::OptimizeTableStmt(payload);
7304  } else if (ddl_command == "COPY_TABLE") {
7305  stmt = new Parser::CopyTableStmt(payload);
7306  } else if (ddl_command == "EXPORT_QUERY") {
7307  stmt = new Parser::ExportQueryStmt(payload);
7308  } else if (ddl_command == "CREATE_VIEW") {
7309  stmt = new Parser::CreateViewStmt(payload);
7310  } else if (ddl_command == "DROP_VIEW") {
7311  stmt = new Parser::DropViewStmt(payload);
7312  } else if (ddl_command == "CREATE_DB") {
7313  stmt = new Parser::CreateDBStmt(payload);
7314  } else if (ddl_command == "DROP_DB") {
7315  stmt = new Parser::DropDBStmt(payload);
7316  } else if (ddl_command == "RENAME_DB") {
7317  stmt = new Parser::RenameDBStmt(payload);
7318  } else if (ddl_command == "CREATE_USER") {
7319  stmt = new Parser::CreateUserStmt(payload);
7320  } else if (ddl_command == "DROP_USER") {
7321  stmt = new Parser::DropUserStmt(payload);
7322  } else if (ddl_command == "ALTER_USER") {
7323  stmt = new Parser::AlterUserStmt(payload);
7324  } else if (ddl_command == "RENAME_USER") {
7325  stmt = new Parser::RenameUserStmt(payload);
7326  } else if (ddl_command == "CREATE_ROLE") {
7327  stmt = new Parser::CreateRoleStmt(payload);
7328  } else if (ddl_command == "DROP_ROLE") {
7329  stmt = new Parser::DropRoleStmt(payload);
7330  } else if (ddl_command == "GRANT_ROLE") {
7331  stmt = new Parser::GrantRoleStmt(payload);
7332  } else if (ddl_command == "REVOKE_ROLE") {
7333  stmt = new Parser::RevokeRoleStmt(payload);
7334  } else if (ddl_command == "GRANT_PRIVILEGE") {
7335  stmt = new Parser::GrantPrivilegesStmt(payload);
7336  } else if (ddl_command == "REVOKE_PRIVILEGE") {
7337  stmt = new Parser::RevokePrivilegesStmt(payload);
7338  } else if (ddl_command == "CREATE_DATAFRAME") {
7339  stmt = new Parser::CreateDataframeStmt(payload);
7340  } else if (ddl_command == "CREATE_MODEL") {
7341  stmt = new Parser::CreateModelStmt(payload);
7342  } else if (ddl_command == "DROP_MODEL") {
7343  stmt = new Parser::DropModelStmt(payload);
7344  } else if (ddl_command == "VALIDATE_SYSTEM") {
7345  // VALIDATE should have been excuted in outer context before it reaches here
7346  UNREACHABLE(); // not-implemented alterType
7347  } else {
7348  throw std::runtime_error("Unsupported DDL command");
7349  }
7350  return std::unique_ptr<Parser::Stmt>(stmt);
7351 }
#define UNREACHABLE()
Definition: Logger.h:338
#define CHECK(condition)
Definition: Logger.h:291
#define VLOG(n)
Definition: Logger.h:388

+ Here is the caller graph for this function:

std::unique_ptr< Parser::Stmt > Parser::create_stmt_for_query ( const std::string &  queryStr,
const Catalog_Namespace::SessionInfo session_info 
)

Helper functions for parsing the DDL returned from calcite as part of the plan result to a parser node in this class. Currently only used in QueryRunner/DistributedQueryRunner, where we do not want to link in the thrift dependencies wich DdlCommandExecutor currently brings along.

Definition at line 7248 of file ParserNode.cpp.

References cat(), query_state::QueryState::create(), create_stmt_for_json(), g_enable_watchdog, Catalog_Namespace::SessionInfo::getCatalog(), Catalog_Namespace::SysCatalog::instance(), Catalog_Namespace::SysCatalog::isAggregator(), and pg_shim().

Referenced by TableArchiver::restoreTable(), and DBHandler::sql_execute_impl().

7250  {
7251  auto session_copy = session_info;
7252  auto session_ptr = std::shared_ptr<Catalog_Namespace::SessionInfo>(
7253  &session_copy, boost::null_deleter());
7254  auto query_state = query_state::QueryState::create(session_ptr, queryStr);
7255  const auto& cat = session_info.getCatalog();
7256  auto calcite_mgr = cat.getCalciteMgr();
7257  const auto calciteQueryParsingOption =
7258  calcite_mgr->getCalciteQueryParsingOption(true, false, true, false);
7259  const auto calciteOptimizationOption = calcite_mgr->getCalciteOptimizationOption(
7260  false,
7262  {},
7264  const auto query_json = calcite_mgr
7265  ->process(query_state->createQueryStateProxy(),
7266  pg_shim(queryStr),
7267  calciteQueryParsingOption,
7268  calciteOptimizationOption)
7269  .plan_result;
7270  return create_stmt_for_json(query_json);
7271 }
std::string cat(Ts &&...args)
static std::shared_ptr< QueryState > create(ARGS &&...args)
Definition: QueryState.h:148
static SysCatalog & instance()
Definition: SysCatalog.h:343
std::unique_ptr< Parser::Stmt > create_stmt_for_json(const std::string &query_json)
bool g_enable_watchdog
Catalog & getCatalog() const
Definition: SessionInfo.h:75
std::string pg_shim(const std::string &query)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static DBObject Parser::createObject ( const std::string &  objectName,
DBObjectType  objectType 
)
static

Definition at line 6092 of file ParserNode.cpp.

References DashboardDBObjectType.

Referenced by Parser::GrantPrivilegesStmt::execute(), Parser::RevokePrivilegesStmt::execute(), and Parser::ShowPrivilegesStmt::execute().

6092  {
6093  if (objectType == DashboardDBObjectType) {
6094  int32_t dashboard_id = -1;
6095  if (!objectName.empty()) {
6096  try {
6097  dashboard_id = stoi(objectName);
6098  } catch (const std::exception&) {
6099  throw std::runtime_error(
6100  "Privileges on dashboards should be changed via integer dashboard ID");
6101  }
6102  }
6103  return DBObject(dashboard_id, objectType);
6104  } else {
6105  return DBObject(objectName, objectType);
6106  }
6107 }

+ Here is the caller graph for this function:

void Parser::execute_stmt_for_json ( const std::string &  query_json,
std::shared_ptr< Catalog_Namespace::SessionInfo const >  session_ptr,
bool  read_only_mode 
)

Definition at line 7353 of file ParserNode.cpp.

References create_stmt_for_json(), and Parser::DDLStmt::execute().

7356  {
7357  std::unique_ptr<Parser::Stmt> stmt = create_stmt_for_json(query_json);
7358  auto ddl = dynamic_cast<Parser::DDLStmt*>(stmt.get());
7359  if (ddl != nullptr) {
7360  (*ddl).execute(*session_ptr, read_only_mode);
7361  }
7362 }
std::unique_ptr< Parser::Stmt > create_stmt_for_json(const std::string &query_json)
virtual void execute(const Catalog_Namespace::SessionInfo &session, bool read_only_mode)=0

+ Here is the call graph for this function:

std::string Parser::extractObjectNameFromHierName ( const std::string &  objectHierName,
const std::string &  objectType,
const Catalog_Namespace::Catalog cat 
)

Definition at line 5955 of file ParserNode.cpp.

References splitObjectHierName().

Referenced by Parser::GrantPrivilegesStmt::execute(), Parser::RevokePrivilegesStmt::execute(), and Parser::ShowPrivilegesStmt::execute().

5957  {
5958  std::string objectName;
5959  std::vector<std::string> componentNames = splitObjectHierName(objectHierName);
5960  if (objectType.compare("DATABASE") == 0) {
5961  if (componentNames.size() == 1) {
5962  objectName = componentNames[0];
5963  } else {
5964  throw std::runtime_error("DB object name is not correct " + objectHierName);
5965  }
5966  } else {
5967  if (objectType.compare("TABLE") == 0 || objectType.compare("DASHBOARD") == 0 ||
5968  objectType.compare("VIEW") == 0 || objectType.compare("SERVER") == 0) {
5969  switch (componentNames.size()) {
5970  case (1): {
5971  objectName = componentNames[0];
5972  break;
5973  }
5974  case (2): {
5975  objectName = componentNames[1];
5976  break;
5977  }
5978  default: {
5979  throw std::runtime_error("DB object name is not correct " + objectHierName);
5980  }
5981  }
5982  } else {
5983  throw std::runtime_error("DB object type " + objectType + " is not supported.");
5984  }
5985  }
5986  return objectName;
5987 }
std::vector< std::string > splitObjectHierName(const std::string &hierName)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

std::list< ColumnDef > Parser::get_columns_from_json_payload ( const std::string &  payload_key,
const rapidjson::Value &  payload 
)

Definition at line 3214 of file ParserNode.cpp.

References CHECK, column_from_json(), logger::FATAL, json_str(), and LOG.

Referenced by AlterTableAlterColumnCommand::alterColumn().

3215  {
3216  std::list<ColumnDef> table_element_list;
3217  CHECK(payload[payload_key].IsArray());
3218 
3219  const auto elements = payload[payload_key].GetArray();
3220  for (const auto& element : elements) {
3221  CHECK(element.IsObject());
3222  CHECK(element.HasMember("type"));
3223  if (json_str(element["type"]) == "SQL_COLUMN_DECLARATION") {
3224  auto col_def = column_from_json(element);
3225  table_element_list.emplace_back(std::move(*col_def));
3226  } else {
3227  LOG(FATAL) << "Unsupported element type for ALTER TABLE: "
3228  << element["type"].GetString();
3229  }
3230  }
3231  return table_element_list;
3232 }
#define LOG(tag)
Definition: Logger.h:285
const std::string json_str(const rapidjson::Value &obj) noexcept
Definition: JsonAccessors.h:46
#define CHECK(condition)
Definition: Logger.h:291
std::unique_ptr< ColumnDef > column_from_json(const rapidjson::Value &element)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

SQLTypeInfo const& Parser::get_str_dict_cast_type ( const SQLTypeInfo lhs_type_info,
const SQLTypeInfo rhs_type_info,
const Executor executor 
)

Definition at line 331 of file ParserNode.cpp.

References CHECK, CHECK_NE, SQLTypeInfo::get_compression(), SQLTypeInfo::getStringDictKey(), SQLTypeInfo::is_string(), and kENCODING_DICT.

Referenced by common_string_type(), and Parser::OperExpr::normalize().

333  {
334  CHECK(lhs_type_info.is_string());
335  CHECK(lhs_type_info.get_compression() == kENCODING_DICT);
336  CHECK(rhs_type_info.is_string());
337  CHECK(rhs_type_info.get_compression() == kENCODING_DICT);
338  const auto& lhs_dict_key = lhs_type_info.getStringDictKey();
339  const auto& rhs_dict_key = rhs_type_info.getStringDictKey();
340  CHECK_NE(lhs_dict_key, rhs_dict_key);
341  if (lhs_dict_key.isTransientDict()) {
342  return rhs_type_info;
343  }
344  if (rhs_dict_key.isTransientDict()) {
345  return lhs_type_info;
346  }
347  // If here then neither lhs or rhs type was transient, we should see which
348  // type has the largest dictionary and make that the destination type
349  const auto lhs_sdp = executor->getStringDictionaryProxy(lhs_dict_key, true);
350  const auto rhs_sdp = executor->getStringDictionaryProxy(rhs_dict_key, true);
351  return lhs_sdp->entryCount() >= rhs_sdp->entryCount() ? lhs_type_info : rhs_type_info;
352 }
#define CHECK_NE(x, y)
Definition: Logger.h:302
HOST DEVICE EncodingType get_compression() const
Definition: sqltypes.h:399
#define CHECK(condition)
Definition: Logger.h:291
bool is_string() const
Definition: sqltypes.h:559
const shared::StringDictKey & getStringDictKey() const
Definition: sqltypes.h:1055

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

std::shared_ptr<ResultSet> Parser::getResultSet ( QueryStateProxy  query_state_proxy,
const std::string  select_stmt,
std::vector< TargetMetaInfo > &  targets,
bool  validate_only = false,
std::vector< size_t >  outer_fragment_indices = {},
bool  allow_interrupt = false 
)

Definition at line 3857 of file ParserNode.cpp.

Referenced by Parser::LocalQueryConnector::query().

3861  {},
3862  bool allow_interrupt = false) {
3863  auto const session = query_state_proxy->getConstSessionInfo();
3864  auto& catalog = session->getCatalog();
3865 
3867 #ifdef HAVE_CUDA
3868  const auto device_type = session->get_executor_device_type();
3869 #else
3870  const auto device_type = ExecutorDeviceType::CPU;
3871 #endif // HAVE_CUDA
3872  auto calcite_mgr = catalog.getCalciteMgr();
3873 
3874  // TODO MAT this should actually get the global or the session parameter for
3875  // view optimization
3876  const auto calciteQueryParsingOption =
3877  calcite_mgr->getCalciteQueryParsingOption(true, false, true, false);
3878  const auto calciteOptimizationOption = calcite_mgr->getCalciteOptimizationOption(
3879  false,
3881  {},
3883  const auto query_ra = calcite_mgr
3884  ->process(query_state_proxy,
3885  pg_shim(select_stmt),
3886  calciteQueryParsingOption,
3887  calciteOptimizationOption)
3888  .plan_result;
3889  RelAlgExecutor ra_executor(
3890  executor.get(), query_ra, query_state_proxy->shared_from_this());
3892  // TODO(adb): Need a better method of dropping constants into this ExecutionOptions
3893  // struct
3894  ExecutionOptions eo = {false,
3895  false,
3896  true,
3897  false,
3898  true,
3899  false,
3900  false,
3901  validate_only,
3902  false,
3903  10000,
3904  false,
3905  false,
3906  1000,
3907  allow_interrupt,
3911  false,
3912  std::numeric_limits<size_t>::max(),
3914  outer_fragment_indices};
3915 
3916  ExecutionResult result{std::make_shared<ResultSet>(std::vector<TargetInfo>{},
3919  nullptr,
3920  0,
3921  0),
3922  {}};
3923  result = ra_executor.executeRelAlgQuery(co, eo, false, false, nullptr);
3924  targets = result.getTargetsMeta();
3925 
3926  return result.getRows();
3927 }
double g_running_query_interrupt_freq
Definition: Execute.cpp:137
unsigned g_pending_query_interrupt_freq
Definition: Execute.cpp:136
static std::shared_ptr< Executor > getExecutor(const ExecutorId id, const std::string &debug_dir="", const std::string &debug_file="", const SystemParameters &system_parameters=SystemParameters())
Definition: Execute.cpp:509
static SysCatalog & instance()
Definition: SysCatalog.h:343
bool g_enable_watchdog
bool g_optimize_cuda_block_and_grid_sizes
Definition: Execute.cpp:165
static CompilationOptions defaults(const ExecutorDeviceType device_type=ExecutorDeviceType::GPU)
static constexpr ExecutorId UNITARY_EXECUTOR_ID
Definition: Execute.h:423
std::shared_ptr< Catalog_Namespace::SessionInfo const > getConstSessionInfo() const
Definition: QueryState.cpp:84
std::string pg_shim(const std::string &query)

+ Here is the caller graph for this function:

std::vector<int> Parser::getTableChunkKey ( const TableDescriptor td,
Catalog_Namespace::Catalog catalog 
)

Definition at line 118 of file ParserNode.cpp.

References Catalog_Namespace::DBMetadata::dbId, TableDescriptor::fragmenter, Catalog_Namespace::Catalog::getCurrentDB(), and TableDescriptor::tableId.

119  {
120  std::vector<int> table_chunk_key_prefix;
121  if (td) {
122  if (td->fragmenter) {
123  table_chunk_key_prefix = td->fragmenter->getFragmentsForQuery().chunkKeyPrefix;
124  } else {
125  table_chunk_key_prefix.push_back(catalog.getCurrentDB().dbId);
126  table_chunk_key_prefix.push_back(td->tableId);
127  }
128  }
129  return table_chunk_key_prefix;
130 }
const DBMetadata & getCurrentDB() const
Definition: Catalog.h:265
std::shared_ptr< Fragmenter_Namespace::AbstractFragmenter > fragmenter

+ Here is the call graph for this function:

void Parser::parser_slistval_to_vector ( std::list< std::string * > *  l,
std::vector< std::string > &  v 
)
inline

Definition at line 1541 of file ParserNode.h.

References CHECK.

Referenced by Parser::GrantPrivilegesStmt::GrantPrivilegesStmt(), Parser::GrantRoleStmt::GrantRoleStmt(), Parser::RevokePrivilegesStmt::RevokePrivilegesStmt(), and Parser::RevokeRoleStmt::RevokeRoleStmt().

1542  {
1543  CHECK(l);
1544  for (auto str : *l) {
1545  v.push_back(*str);
1546  delete str;
1547  }
1548  delete l;
1549 }
#define CHECK(condition)
Definition: Logger.h:291

+ Here is the caller graph for this function:

static std::pair<AccessPrivileges, DBObjectType> Parser::parseStringPrivs ( const std::string &  privs,
const DBObjectType objectType,
const std::string &  object_name 
)
static

Definition at line 5989 of file ParserNode.cpp.

References AccessPrivileges::ACCESS, AccessPrivileges::ALL_DASHBOARD, AccessPrivileges::ALL_DATABASE, AccessPrivileges::ALL_SERVER, AccessPrivileges::ALL_TABLE, AccessPrivileges::ALL_VIEW, AccessPrivileges::ALTER_SERVER, AccessPrivileges::ALTER_TABLE, AccessPrivileges::CREATE_DASHBOARD, AccessPrivileges::CREATE_SERVER, AccessPrivileges::CREATE_TABLE, AccessPrivileges::CREATE_VIEW, DashboardDBObjectType, DatabaseDBObjectType, AccessPrivileges::DELETE_DASHBOARD, AccessPrivileges::DELETE_FROM_TABLE, AccessPrivileges::DROP_SERVER, AccessPrivileges::DROP_TABLE, AccessPrivileges::DROP_VIEW, AccessPrivileges::EDIT_DASHBOARD, AccessPrivileges::INSERT_INTO_TABLE, run_benchmark_import::result, AccessPrivileges::SELECT_FROM_TABLE, AccessPrivileges::SELECT_FROM_VIEW, AccessPrivileges::SERVER_USAGE, ServerDBObjectType, TableDBObjectType, AccessPrivileges::TRUNCATE_TABLE, AccessPrivileges::UPDATE_IN_TABLE, AccessPrivileges::VIEW_DASHBOARD, AccessPrivileges::VIEW_SQL_EDITOR, and ViewDBObjectType.

Referenced by Parser::GrantPrivilegesStmt::execute(), and Parser::RevokePrivilegesStmt::execute().

5992  {
5993  static const std::map<std::pair<const std::string, const DBObjectType>,
5994  std::pair<const AccessPrivileges, const DBObjectType>>
5995  privileges_lookup{
5996  {{"ALL"s, DatabaseDBObjectType},
5999  {{"ALL"s, DashboardDBObjectType},
6002  {{"ALL"s, ServerDBObjectType},
6004 
6005  {{"CREATE TABLE"s, DatabaseDBObjectType},
6007  {{"CREATE"s, DatabaseDBObjectType},
6009  {{"SELECT"s, DatabaseDBObjectType},
6011  {{"INSERT"s, DatabaseDBObjectType},
6013  {{"TRUNCATE"s, DatabaseDBObjectType},
6015  {{"UPDATE"s, DatabaseDBObjectType},
6017  {{"DELETE"s, DatabaseDBObjectType},
6019  {{"DROP"s, DatabaseDBObjectType},
6021  {{"ALTER"s, DatabaseDBObjectType},
6023 
6024  {{"SELECT"s, TableDBObjectType},
6026  {{"INSERT"s, TableDBObjectType},
6028  {{"TRUNCATE"s, TableDBObjectType},
6030  {{"UPDATE"s, TableDBObjectType},
6032  {{"DELETE"s, TableDBObjectType},
6034  {{"DROP"s, TableDBObjectType},
6036  {{"ALTER"s, TableDBObjectType},
6038 
6039  {{"CREATE VIEW"s, DatabaseDBObjectType},
6041  {{"SELECT VIEW"s, DatabaseDBObjectType},
6043  {{"DROP VIEW"s, DatabaseDBObjectType},
6045  {{"SELECT"s, ViewDBObjectType},
6048 
6049  {{"CREATE DASHBOARD"s, DatabaseDBObjectType},
6051  {{"EDIT DASHBOARD"s, DatabaseDBObjectType},
6053  {{"VIEW DASHBOARD"s, DatabaseDBObjectType},
6055  {{"DELETE DASHBOARD"s, DatabaseDBObjectType},
6057  {{"VIEW"s, DashboardDBObjectType},
6059  {{"EDIT"s, DashboardDBObjectType},
6061  {{"DELETE"s, DashboardDBObjectType},
6063 
6064  {{"CREATE SERVER"s, DatabaseDBObjectType},
6066  {{"DROP SERVER"s, DatabaseDBObjectType},
6068  {{"DROP"s, ServerDBObjectType},
6070  {{"ALTER SERVER"s, DatabaseDBObjectType},
6072  {{"ALTER"s, ServerDBObjectType},
6074  {{"USAGE"s, ServerDBObjectType},
6076  {{"SERVER USAGE"s, DatabaseDBObjectType},
6078 
6079  {{"VIEW SQL EDITOR"s, DatabaseDBObjectType},
6081  {{"ACCESS"s, DatabaseDBObjectType},
6083 
6084  auto result = privileges_lookup.find(std::make_pair(privs, objectType));
6085  if (result == privileges_lookup.end()) {
6086  throw std::runtime_error("Privileges " + privs + " on DB object " + object_name +
6087  " are not correct.");
6088  }
6089  return result->second;
6090 }
static const AccessPrivileges VIEW_SQL_EDITOR
Definition: DBObject.h:152
static const AccessPrivileges VIEW_DASHBOARD
Definition: DBObject.h:171
static const AccessPrivileges DROP_SERVER
Definition: DBObject.h:189
static const AccessPrivileges ALL_DATABASE
Definition: DBObject.h:151
static const AccessPrivileges ALTER_TABLE
Definition: DBObject.h:165
static const AccessPrivileges TRUNCATE_TABLE
Definition: DBObject.h:164
static const AccessPrivileges INSERT_INTO_TABLE
Definition: DBObject.h:161
static const AccessPrivileges CREATE_DASHBOARD
Definition: DBObject.h:170
static const AccessPrivileges SERVER_USAGE
Definition: DBObject.h:191
static const AccessPrivileges SELECT_FROM_TABLE
Definition: DBObject.h:160
static const AccessPrivileges ALL_VIEW
Definition: DBObject.h:177
static const AccessPrivileges ALTER_SERVER
Definition: DBObject.h:190
static const AccessPrivileges DROP_TABLE
Definition: DBObject.h:159
static const AccessPrivileges ALL_SERVER
Definition: DBObject.h:187
static const AccessPrivileges CREATE_SERVER
Definition: DBObject.h:188
static const AccessPrivileges DELETE_FROM_TABLE
Definition: DBObject.h:163
static const AccessPrivileges CREATE_TABLE
Definition: DBObject.h:158
static const AccessPrivileges SELECT_FROM_VIEW
Definition: DBObject.h:180
static const AccessPrivileges ALL_DASHBOARD
Definition: DBObject.h:169
static const AccessPrivileges ACCESS
Definition: DBObject.h:153
static const AccessPrivileges ALL_TABLE
Definition: DBObject.h:157
static const AccessPrivileges DROP_VIEW
Definition: DBObject.h:179
static const AccessPrivileges CREATE_VIEW
Definition: DBObject.h:178
static const AccessPrivileges DELETE_DASHBOARD
Definition: DBObject.h:173
static const AccessPrivileges EDIT_DASHBOARD
Definition: DBObject.h:172
static const AccessPrivileges UPDATE_IN_TABLE
Definition: DBObject.h:162

+ Here is the caller graph for this function:

static bool Parser::readBooleanLiteral ( const std::string &  option_name,
const std::unique_ptr< NameValueAssign > &  p 
)
static

Definition at line 6922 of file ParserNode.cpp.

References CHECK.

Referenced by Parser::CreateUserStmt::execute(), and Parser::AlterUserStmt::execute().

6923  {
6924  CHECK(p);
6925  const std::string* str =
6926  static_cast<const StringLiteral*>(p->get_value())->get_stringval();
6927  if (boost::iequals(*str, "true")) {
6928  return true;
6929  } else if (boost::iequals(*str, "false")) {
6930  return false;
6931  } else {
6932  throw std::runtime_error("Value to " + option_name + " must be TRUE or FALSE.");
6933  }
6934 }
#define CHECK(condition)
Definition: Logger.h:291

+ Here is the caller graph for this function:

bool Parser::repair_type ( std::list< std::unique_ptr< NameValueAssign >> &  options)

Definition at line 5032 of file ParserNode.cpp.

References CHECK.

Referenced by Parser::ValidateStmt::ValidateStmt().

5032  {
5033  for (const auto& opt : options) {
5034  if (boost::iequals(*opt->get_name(), "REPAIR_TYPE")) {
5035  const auto repair_type =
5036  static_cast<const StringLiteral*>(opt->get_value())->get_stringval();
5037  CHECK(repair_type);
5038  if (boost::iequals(*repair_type, "REMOVE")) {
5039  return true;
5040  } else {
5041  throw std::runtime_error("REPAIR_TYPE must be REMOVE.");
5042  }
5043  } else {
5044  throw std::runtime_error("The only VALIDATE WITH options is REPAIR_TYPE.");
5045  }
5046  }
5047  return false;
5048 }
bool repair_type(std::list< std::unique_ptr< NameValueAssign >> &options)
#define CHECK(condition)
Definition: Logger.h:291

+ Here is the caller graph for this function:

void Parser::set_column_descriptor ( ColumnDescriptor cd,
const ColumnDef *  coldef 
)

Definition at line 5314 of file ParserNode.cpp.

References Parser::ColumnDef::get_column_constraint(), Parser::ColumnDef::get_column_name(), Parser::ColumnDef::get_column_type(), Parser::ColumnDef::get_compression(), Parser::ColumnConstraintDef::get_defaultval(), ddl_utils::SqlType::get_is_array(), Parser::ColumnConstraintDef::get_notnull(), Parser::StringLiteral::get_stringval(), and ddl_utils::set_column_descriptor().

Referenced by anonymous_namespace{DdlCommandExecutor.cpp}::get_alter_column_src_dst_cds(), and Parser::DDLStmt::setColumnDescriptor().

5314  {
5315  bool not_null;
5316  const ColumnConstraintDef* cc = coldef->get_column_constraint();
5317  if (cc == nullptr) {
5318  not_null = false;
5319  } else {
5320  not_null = cc->get_notnull();
5321  }
5322  std::string default_value;
5323  const std::string* default_value_ptr = nullptr;
5324  if (cc) {
5325  if (auto def_val_literal = cc->get_defaultval()) {
5326  auto defaultsp = dynamic_cast<const StringLiteral*>(def_val_literal);
5327  default_value =
5328  defaultsp ? *defaultsp->get_stringval() : def_val_literal->to_string();
5329  // The preprocessing below is needed because:
5330  // a) TypedImportBuffer expects arrays in the {...} format
5331  // b) TypedImportBuffer expects string literals inside arrays w/o any quotes
5332  if (coldef->get_column_type()->get_is_array()) {
5333  std::regex array_re(R"(^ARRAY\s*\[(.*)\]$)", std::regex_constants::icase);
5334  default_value = std::regex_replace(default_value, array_re, "{$1}");
5335  boost::erase_all(default_value, "\'");
5336  }
5337  default_value_ptr = &default_value;
5338  }
5339  }
5340  ddl_utils::set_column_descriptor(*coldef->get_column_name(),
5341  cd,
5342  coldef->get_column_type(),
5343  not_null,
5344  coldef->get_compression(),
5345  default_value_ptr);
5346 }
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)
Definition: DdlUtils.cpp:698

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool Parser::should_translate_strings ( const std::shared_ptr< Analyzer::Expr > &  lhs_expr,
const std::shared_ptr< Analyzer::Expr > &  rhs_expr 
)

Definition at line 316 of file ParserNode.cpp.

References CHECK.

Referenced by Parser::OperExpr::normalize().

317  {
318  if (dynamic_cast<Analyzer::Constant*>(rhs_expr.get())) {
319  // we must translate rhs string literal against lhs str dictionary
320  return true;
321  }
322  std::set<int> lhs_rte_idx;
323  lhs_expr->collect_rte_idx(lhs_rte_idx);
324  CHECK(!lhs_rte_idx.empty());
325  std::set<int> rhs_rte_idx;
326  rhs_expr->collect_rte_idx(rhs_rte_idx);
327  CHECK(!rhs_rte_idx.empty());
328  return lhs_rte_idx.size() == 1UL && lhs_rte_idx == rhs_rte_idx;
329 }
#define CHECK(condition)
Definition: Logger.h:291

+ Here is the caller graph for this function:

std::vector<std::string> Parser::splitObjectHierName ( const std::string &  hierName)

Definition at line 5949 of file ParserNode.cpp.

References split().

Referenced by extractObjectNameFromHierName().

5949  {
5950  std::vector<std::string> componentNames;
5951  boost::split(componentNames, hierName, boost::is_any_of("."));
5952  return componentNames;
5953 }
std::vector< std::string > split(std::string_view str, std::string_view delim, std::optional< size_t > maxsplit)
split apart a string into a vector of substrings

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int32_t Parser::validate_and_get_fragment_size ( const std::string &  fragment_size_str)

Definition at line 7364 of file ParserNode.cpp.

References to_string().

Referenced by Parser::anonymous_namespace{ParserNode.cpp}::get_frag_size_def(), and CreateForeignTableCommand::setTableDetails().

7364  {
7365  int64_t fragment_size_value{-1};
7366  bool validation_failed{false};
7367  try {
7368  fragment_size_value = std::stoll(fragment_size_str);
7369  } catch (std::out_of_range& e) {
7370  validation_failed = true;
7371  }
7372  constexpr int64_t max_fragment_size = std::numeric_limits<int32_t>::max();
7373  if (!validation_failed &&
7374  (fragment_size_value <= 0 || fragment_size_value > max_fragment_size)) {
7375  validation_failed = true;
7376  }
7377  if (validation_failed) {
7378  throw std::runtime_error(
7379  "Invalid value \"" + fragment_size_str +
7380  "\" provided for FRAGMENT_SIZE option, expected a positive integer between "
7381  "1 and " +
7382  std::to_string(max_fragment_size) + ".");
7383  }
7384  return fragment_size_value;
7385 }
std::string to_string(char const *&&v)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void Parser::verifyObject ( Catalog_Namespace::Catalog sessionCatalog,
const std::string &  objectName,
DBObjectType  objectType,
const std::string &  command 
)
static

Definition at line 6111 of file ParserNode.cpp.

References DBObjectTypeToString(), Catalog_Namespace::Catalog::getMetadataForTable(), TableDescriptor::isView, TableDBObjectType, and ViewDBObjectType.

Referenced by Parser::GrantPrivilegesStmt::execute(), Parser::RevokePrivilegesStmt::execute(), and Parser::ShowPrivilegesStmt::execute().

6114  {
6115  if (objectType == TableDBObjectType) {
6116  auto td = sessionCatalog.getMetadataForTable(objectName, false);
6117  if (!td || td->isView) {
6118  // expected TABLE, found VIEW
6119  throw std::runtime_error(command + " failed. Object '" + objectName + "' of type " +
6120  DBObjectTypeToString(objectType) + " not found.");
6121  }
6122 
6123  } else if (objectType == ViewDBObjectType) {
6124  auto td = sessionCatalog.getMetadataForTable(objectName, false);
6125  if (!td || !td->isView) {
6126  // expected VIEW, found TABLE
6127  throw std::runtime_error(command + " failed. Object '" + objectName + "' of type " +
6128  DBObjectTypeToString(objectType) + " not found.");
6129  }
6130  }
6131 }
std::string DBObjectTypeToString(DBObjectType type)
Definition: DBObject.cpp:92
const TableDescriptor * getMetadataForTable(const std::string &tableName, const bool populateFragmenter=true) const
Returns a pointer to a const TableDescriptor struct matching the provided tableName.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

std::string Parser::write_model_params_to_json ( const std::string &  predicted,
const std::vector< std::string > &  features,
const std::string &  training_query,
const double  data_split_train_fraction,
const double  data_split_eval_fraction,
const std::vector< int64_t > &  feature_permutations 
)

Definition at line 3469 of file ParserNode.cpp.

Referenced by Parser::CreateModelStmt::train_model().

3474  {
3475  // Create a RapidJSON document
3476  rapidjson::Document doc;
3477  doc.SetObject();
3478 
3479  // Add the fields to the document
3480  rapidjson::Value predicted_value;
3481  predicted_value.SetString(predicted.c_str(), predicted.length(), doc.GetAllocator());
3482  doc.AddMember("predicted", predicted_value, doc.GetAllocator());
3483 
3484  rapidjson::Value features_array(rapidjson::kArrayType);
3485  for (const auto& feature : features) {
3486  rapidjson::Value feature_value;
3487  feature_value.SetString(feature.c_str(), feature.length(), doc.GetAllocator());
3488  features_array.PushBack(feature_value, doc.GetAllocator());
3489  }
3490  doc.AddMember("features", features_array, doc.GetAllocator());
3491 
3492  rapidjson::Value training_query_value;
3493  training_query_value.SetString(
3494  training_query.c_str(), training_query.length(), doc.GetAllocator());
3495  doc.AddMember("training_query", training_query_value, doc.GetAllocator());
3496 
3497  rapidjson::Value data_split_train_fraction_key("data_split_train_fraction",
3498  doc.GetAllocator());
3499 
3500  rapidjson::Value data_split_train_fraction_value(data_split_train_fraction);
3501 
3502  doc.AddMember(
3503  data_split_train_fraction_key, data_split_train_fraction_value, doc.GetAllocator());
3504 
3505  rapidjson::Value data_split_eval_fraction_key("data_split_eval_fraction",
3506  doc.GetAllocator());
3507 
3508  rapidjson::Value data_split_eval_fraction_value(data_split_eval_fraction);
3509 
3510  doc.AddMember(
3511  data_split_eval_fraction_key, data_split_eval_fraction_value, doc.GetAllocator());
3512 
3513  rapidjson::Value feature_permutations_array(rapidjson::kArrayType);
3514  for (const auto& feature_permutation : feature_permutations) {
3515  rapidjson::Value feature_permutation_value;
3516  feature_permutation_value.SetInt64(feature_permutation);
3517  feature_permutations_array.PushBack(feature_permutation_value, doc.GetAllocator());
3518  }
3519  doc.AddMember("feature_permutations", feature_permutations_array, doc.GetAllocator());
3520 
3521  // Convert the document to a JSON string
3522  rapidjson::StringBuffer buffer;
3523  rapidjson::Writer<rapidjson::StringBuffer> writer(buffer);
3524  doc.Accept(writer);
3525 
3526  return buffer.GetString();
3527 }

+ Here is the caller graph for this function: