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

Namespaces

 anonymous_namespace{ParserNode.cpp}
 
 anonymous_namespace{ParserNode.h}
 
 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 5191 of file ParserNode.cpp.

Function Documentation

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

Definition at line 5097 of file ParserNode.cpp.

References AccessPrivileges::ALTER_TABLE, Catalog_Namespace::SessionInfo::get_currentUser(), Catalog_Namespace::SessionInfo::getCatalog(), lockmgr::instance(), 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().

5098  {
5099  if (session.get_currentUser().isSuper ||
5100  session.get_currentUser().userId == td->userId) {
5101  return;
5102  }
5103  std::vector<DBObject> privObjects;
5104  DBObject dbObject(td->tableName, TableDBObjectType);
5105  dbObject.loadKey(session.getCatalog());
5106  dbObject.setPrivileges(AccessPrivileges::ALTER_TABLE);
5107  privObjects.push_back(dbObject);
5108  if (!SysCatalog::instance().checkPrivileges(session.get_currentUser(), privObjects)) {
5109  throw std::runtime_error("Current user does not have the privilege to alter table: " +
5110  td->tableName);
5111  }
5112 }
std::string tableName
static const AccessPrivileges ALTER_TABLE
Definition: DBObject.h:165
Catalog & getCatalog() const
Definition: SessionInfo.h:75
T & instance()
Definition: LockMgr.cpp:101
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 107 of file ParserNode.cpp.

References g_enable_non_kernel_time_query_interrupt.

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

107  {
108  // we call this function with unitary executor but is okay since
109  // we know the exact session info from a global session map object
110  // in the executor
113  executor->getSessionLock());
114  return executor->checkIsQuerySessionInterrupted(query_session, session_read_lock);
115  }
116  return false;
117 }
bool g_enable_non_kernel_time_query_interrupt
Definition: Execute.cpp:138
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 6851 of file ParserNode.cpp.

References CHECK.

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

6852  {
6853  CHECK(p);
6854  if (!dynamic_cast<const StringLiteral*>(p->get_value())) {
6855  throw std::runtime_error(option_name + " option must be a string literal.");
6856  }
6857 }
#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 3153 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().

3153  {
3154  CHECK(element.HasMember("name"));
3155  auto col_name = std::make_unique<std::string>(json_str(element["name"]));
3156  CHECK(element.HasMember("sqltype"));
3157  const auto sql_types = to_sql_type(json_str(element["sqltype"]));
3158 
3159  // decimal / numeric precision / scale
3160  int precision = -1;
3161  int scale = -1;
3162  if (element.HasMember("precision")) {
3163  precision = json_i64(element["precision"]);
3164  }
3165  if (element.HasMember("scale")) {
3166  scale = json_i64(element["scale"]);
3167  }
3168 
3169  std::optional<int64_t> array_size;
3170  if (element.HasMember("arraySize")) {
3171  // We do not yet support geo arrays
3172  array_size = json_i64(element["arraySize"]);
3173  }
3174  std::unique_ptr<SQLType> sql_type;
3175  if (element.HasMember("subtype")) {
3176  CHECK(element.HasMember("coordinateSystem"));
3177  const auto subtype_sql_types = to_sql_type(json_str(element["subtype"]));
3178  sql_type =
3179  std::make_unique<SQLType>(subtype_sql_types,
3180  static_cast<int>(sql_types),
3181  static_cast<int>(json_i64(element["coordinateSystem"])),
3182  false);
3183  } else if (precision > 0 && scale > 0) {
3184  sql_type = std::make_unique<SQLType>(sql_types,
3185  precision,
3186  scale,
3187  /*is_array=*/array_size.has_value(),
3188  array_size ? *array_size : -1);
3189  } else if (precision > 0) {
3190  sql_type = std::make_unique<SQLType>(sql_types,
3191  precision,
3192  0,
3193  /*is_array=*/array_size.has_value(),
3194  array_size ? *array_size : -1);
3195  } else {
3196  sql_type = std::make_unique<SQLType>(sql_types,
3197  /*is_array=*/array_size.has_value(),
3198  array_size ? *array_size : -1);
3199  }
3200  CHECK(sql_type);
3201 
3202  CHECK(element.HasMember("nullable"));
3203  const auto nullable = json_bool(element["nullable"]);
3204  std::unique_ptr<ColumnConstraintDef> constraint_def;
3205  StringLiteral* str_literal = nullptr;
3206  if (element.HasMember("default") && !element["default"].IsNull()) {
3207  std::string* defaultval = new std::string(json_str(element["default"]));
3208  boost::algorithm::trim_if(*defaultval, boost::is_any_of(" \"'`"));
3209  str_literal = new StringLiteral(defaultval);
3210  }
3211 
3212  constraint_def = std::make_unique<ColumnConstraintDef>(/*notnull=*/!nullable,
3213  /*unique=*/false,
3214  /*primarykey=*/false,
3215  /*defaultval=*/str_literal);
3216  std::unique_ptr<CompressDef> compress_def;
3217  if (element.HasMember("encodingType") && !element["encodingType"].IsNull()) {
3218  std::string encoding_type = json_str(element["encodingType"]);
3219  CHECK(element.HasMember("encodingSize"));
3220  auto encoding_name = std::make_unique<std::string>(json_str(element["encodingType"]));
3221  compress_def = std::make_unique<CompressDef>(encoding_name.release(),
3222  json_i64(element["encodingSize"]));
3223  }
3224  return std::make_unique<ColumnDef>(col_name.release(),
3225  sql_type.release(),
3226  compress_def ? compress_def.release() : nullptr,
3227  constraint_def ? constraint_def.release() : nullptr);
3228 }
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 355 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().

357  {
358  CHECK(lhs_type_info.is_string());
359  CHECK(rhs_type_info.is_string());
360  if (lhs_type_info.is_dict_encoded_string() && rhs_type_info.is_dict_encoded_string()) {
361  const auto& lhs_dict_key = lhs_type_info.getStringDictKey();
362  const auto& rhs_dict_key = rhs_type_info.getStringDictKey();
363  if (lhs_dict_key == rhs_dict_key ||
364  (lhs_dict_key.db_id == rhs_dict_key.db_id &&
365  lhs_dict_key.dict_id == TRANSIENT_DICT(rhs_dict_key.dict_id))) {
366  return lhs_dict_key.dict_id <= rhs_dict_key.dict_id ? lhs_type_info : rhs_type_info;
367  }
368  return get_str_dict_cast_type(lhs_type_info, rhs_type_info, executor);
369  }
370  CHECK(lhs_type_info.is_none_encoded_string() || rhs_type_info.is_none_encoded_string());
371  SQLTypeInfo ret_ti =
372  rhs_type_info.is_none_encoded_string() ? lhs_type_info : rhs_type_info;
373  if (ret_ti.is_none_encoded_string()) {
374  ret_ti.set_dimension(
375  std::max(lhs_type_info.get_dimension(), rhs_type_info.get_dimension()));
376  }
377  return ret_ti;
378 }
void set_dimension(int d)
Definition: sqltypes.h:472
bool is_none_encoded_string() const
Definition: sqltypes.h:647
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:643
bool is_string() const
Definition: sqltypes.h:561
#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:332
const shared::StringDictKey & getStringDictKey() const
Definition: sqltypes.h:1057

+ 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 7294 of file ParserNode.cpp.

References CHECK, UNREACHABLE, and VLOG.

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

7294  {
7295  CHECK(!query_json.empty());
7296  VLOG(2) << "Parsing JSON DDL from Calcite: " << query_json;
7297  rapidjson::Document ddl_query;
7298  ddl_query.Parse(query_json);
7299  CHECK(ddl_query.IsObject());
7300  CHECK(ddl_query.HasMember("payload"));
7301  CHECK(ddl_query["payload"].IsObject());
7302  const auto& payload = ddl_query["payload"].GetObject();
7303  CHECK(payload.HasMember("command"));
7304  CHECK(payload["command"].IsString());
7305 
7306  const auto& ddl_command = std::string_view(payload["command"].GetString());
7307 
7308  Parser::Stmt* stmt = nullptr;
7309  if (ddl_command == "CREATE_TABLE") {
7310  stmt = new Parser::CreateTableStmt(payload);
7311  } else if (ddl_command == "DROP_TABLE") {
7312  stmt = new Parser::DropTableStmt(payload);
7313  } else if (ddl_command == "RENAME_TABLE") {
7314  stmt = new Parser::RenameTableStmt(payload);
7315  } else if (ddl_command == "ALTER_TABLE") {
7316  // no-op: fall-back to DdlCommandExecutor by returning a nullptr
7317  } else if (ddl_command == "TRUNCATE_TABLE") {
7318  stmt = new Parser::TruncateTableStmt(payload);
7319  } else if (ddl_command == "DUMP_TABLE") {
7320  stmt = new Parser::DumpTableStmt(payload);
7321  } else if (ddl_command == "RESTORE_TABLE") {
7322  stmt = new Parser::RestoreTableStmt(payload);
7323  } else if (ddl_command == "OPTIMIZE_TABLE") {
7324  stmt = new Parser::OptimizeTableStmt(payload);
7325  } else if (ddl_command == "COPY_TABLE") {
7326  stmt = new Parser::CopyTableStmt(payload);
7327  } else if (ddl_command == "EXPORT_QUERY") {
7328  stmt = new Parser::ExportQueryStmt(payload);
7329  } else if (ddl_command == "CREATE_VIEW") {
7330  stmt = new Parser::CreateViewStmt(payload);
7331  } else if (ddl_command == "DROP_VIEW") {
7332  stmt = new Parser::DropViewStmt(payload);
7333  } else if (ddl_command == "CREATE_DB") {
7334  stmt = new Parser::CreateDBStmt(payload);
7335  } else if (ddl_command == "DROP_DB") {
7336  stmt = new Parser::DropDBStmt(payload);
7337  } else if (ddl_command == "RENAME_DB") {
7338  stmt = new Parser::RenameDBStmt(payload);
7339  } else if (ddl_command == "CREATE_USER") {
7340  stmt = new Parser::CreateUserStmt(payload);
7341  } else if (ddl_command == "DROP_USER") {
7342  stmt = new Parser::DropUserStmt(payload);
7343  } else if (ddl_command == "ALTER_USER") {
7344  stmt = new Parser::AlterUserStmt(payload);
7345  } else if (ddl_command == "RENAME_USER") {
7346  stmt = new Parser::RenameUserStmt(payload);
7347  } else if (ddl_command == "CREATE_ROLE") {
7348  stmt = new Parser::CreateRoleStmt(payload);
7349  } else if (ddl_command == "DROP_ROLE") {
7350  stmt = new Parser::DropRoleStmt(payload);
7351  } else if (ddl_command == "GRANT_ROLE") {
7352  stmt = new Parser::GrantRoleStmt(payload);
7353  } else if (ddl_command == "REVOKE_ROLE") {
7354  stmt = new Parser::RevokeRoleStmt(payload);
7355  } else if (ddl_command == "GRANT_PRIVILEGE") {
7356  stmt = new Parser::GrantPrivilegesStmt(payload);
7357  } else if (ddl_command == "REVOKE_PRIVILEGE") {
7358  stmt = new Parser::RevokePrivilegesStmt(payload);
7359  } else if (ddl_command == "CREATE_DATAFRAME") {
7360  stmt = new Parser::CreateDataframeStmt(payload);
7361  } else if (ddl_command == "CREATE_MODEL") {
7362  stmt = new Parser::CreateModelStmt(payload);
7363  } else if (ddl_command == "DROP_MODEL") {
7364  stmt = new Parser::DropModelStmt(payload);
7365  } else if (ddl_command == "VALIDATE_SYSTEM") {
7366  // VALIDATE should have been excuted in outer context before it reaches here
7367  UNREACHABLE(); // not-implemented alterType
7368  } else {
7369  throw std::runtime_error("Unsupported DDL command");
7370  }
7371  return std::unique_ptr<Parser::Stmt>(stmt);
7372 }
#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 7269 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().

7271  {
7272  auto session_copy = session_info;
7273  auto session_ptr = std::shared_ptr<Catalog_Namespace::SessionInfo>(
7274  &session_copy, boost::null_deleter());
7275  auto query_state = query_state::QueryState::create(session_ptr, queryStr);
7276  const auto& cat = session_info.getCatalog();
7277  auto calcite_mgr = cat.getCalciteMgr();
7278  const auto calciteQueryParsingOption =
7279  calcite_mgr->getCalciteQueryParsingOption(true, false, true, false);
7280  const auto calciteOptimizationOption = calcite_mgr->getCalciteOptimizationOption(
7281  false,
7283  {},
7285  const auto query_json = calcite_mgr
7286  ->process(query_state->createQueryStateProxy(),
7287  pg_shim(queryStr),
7288  calciteQueryParsingOption,
7289  calciteOptimizationOption)
7290  .plan_result;
7291  return create_stmt_for_json(query_json);
7292 }
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(std::string const &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 6113 of file ParserNode.cpp.

References DashboardDBObjectType.

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

6113  {
6114  if (objectType == DashboardDBObjectType) {
6115  int32_t dashboard_id = -1;
6116  if (!objectName.empty()) {
6117  try {
6118  dashboard_id = stoi(objectName);
6119  } catch (const std::exception&) {
6120  throw std::runtime_error(
6121  "Privileges on dashboards should be changed via integer dashboard ID");
6122  }
6123  }
6124  return DBObject(dashboard_id, objectType);
6125  } else {
6126  return DBObject(objectName, objectType);
6127  }
6128 }

+ 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 7374 of file ParserNode.cpp.

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

7377  {
7378  std::unique_ptr<Parser::Stmt> stmt = create_stmt_for_json(query_json);
7379  auto ddl = dynamic_cast<Parser::DDLStmt*>(stmt.get());
7380  if (ddl != nullptr) {
7381  (*ddl).execute(*session_ptr, read_only_mode);
7382  }
7383 }
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 5976 of file ParserNode.cpp.

References splitObjectHierName().

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

5978  {
5979  std::string objectName;
5980  std::vector<std::string> componentNames = splitObjectHierName(objectHierName);
5981  if (objectType.compare("DATABASE") == 0) {
5982  if (componentNames.size() == 1) {
5983  objectName = componentNames[0];
5984  } else {
5985  throw std::runtime_error("DB object name is not correct " + objectHierName);
5986  }
5987  } else {
5988  if (objectType.compare("TABLE") == 0 || objectType.compare("DASHBOARD") == 0 ||
5989  objectType.compare("VIEW") == 0 || objectType.compare("SERVER") == 0) {
5990  switch (componentNames.size()) {
5991  case (1): {
5992  objectName = componentNames[0];
5993  break;
5994  }
5995  case (2): {
5996  objectName = componentNames[1];
5997  break;
5998  }
5999  default: {
6000  throw std::runtime_error("DB object name is not correct " + objectHierName);
6001  }
6002  }
6003  } else {
6004  throw std::runtime_error("DB object type " + objectType + " is not supported.");
6005  }
6006  }
6007  return objectName;
6008 }
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 3230 of file ParserNode.cpp.

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

Referenced by AlterTableAlterColumnCommand::alterColumn().

3231  {
3232  std::list<ColumnDef> table_element_list;
3233  CHECK(payload[payload_key].IsArray());
3234 
3235  const auto elements = payload[payload_key].GetArray();
3236  for (const auto& element : elements) {
3237  CHECK(element.IsObject());
3238  CHECK(element.HasMember("type"));
3239  if (json_str(element["type"]) == "SQL_COLUMN_DECLARATION") {
3240  auto col_def = column_from_json(element);
3241  table_element_list.emplace_back(std::move(*col_def));
3242  } else {
3243  LOG(FATAL) << "Unsupported element type for ALTER TABLE: "
3244  << element["type"].GetString();
3245  }
3246  }
3247  return table_element_list;
3248 }
#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 332 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().

334  {
335  CHECK(lhs_type_info.is_string());
336  CHECK(lhs_type_info.get_compression() == kENCODING_DICT);
337  CHECK(rhs_type_info.is_string());
338  CHECK(rhs_type_info.get_compression() == kENCODING_DICT);
339  const auto& lhs_dict_key = lhs_type_info.getStringDictKey();
340  const auto& rhs_dict_key = rhs_type_info.getStringDictKey();
341  CHECK_NE(lhs_dict_key, rhs_dict_key);
342  if (lhs_dict_key.isTransientDict()) {
343  return rhs_type_info;
344  }
345  if (rhs_dict_key.isTransientDict()) {
346  return lhs_type_info;
347  }
348  // If here then neither lhs or rhs type was transient, we should see which
349  // type has the largest dictionary and make that the destination type
350  const auto lhs_sdp = executor->getStringDictionaryProxy(lhs_dict_key, true);
351  const auto rhs_sdp = executor->getStringDictionaryProxy(rhs_dict_key, true);
352  return lhs_sdp->entryCount() >= rhs_sdp->entryCount() ? lhs_type_info : rhs_type_info;
353 }
#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:561
const shared::StringDictKey & getStringDictKey() const
Definition: sqltypes.h:1057

+ 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 3873 of file ParserNode.cpp.

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

3877  {},
3878  bool allow_interrupt = false) {
3879  auto const session = query_state_proxy->getConstSessionInfo();
3880  auto& catalog = session->getCatalog();
3881 
3883 #ifdef HAVE_CUDA
3884  const auto device_type = session->get_executor_device_type();
3885 #else
3886  const auto device_type = ExecutorDeviceType::CPU;
3887 #endif // HAVE_CUDA
3888  auto calcite_mgr = catalog.getCalciteMgr();
3889 
3890  // TODO MAT this should actually get the global or the session parameter for
3891  // view optimization
3892  const auto calciteQueryParsingOption =
3893  calcite_mgr->getCalciteQueryParsingOption(true, false, true, false);
3894  const auto calciteOptimizationOption = calcite_mgr->getCalciteOptimizationOption(
3895  false,
3897  {},
3899  const auto query_ra = calcite_mgr
3900  ->process(query_state_proxy,
3901  pg_shim(select_stmt),
3902  calciteQueryParsingOption,
3903  calciteOptimizationOption)
3904  .plan_result;
3905  RelAlgExecutor ra_executor(
3906  executor.get(), query_ra, query_state_proxy->shared_from_this());
3908  // TODO(adb): Need a better method of dropping constants into this ExecutionOptions
3909  // struct
3910  ExecutionOptions eo = {false,
3911  false,
3912  true,
3913  false,
3914  true,
3915  false,
3916  false,
3917  validate_only,
3918  false,
3919  10000,
3920  false,
3921  false,
3922  1000,
3923  allow_interrupt,
3928  false,
3929  std::numeric_limits<size_t>::max(),
3931  outer_fragment_indices};
3932 
3933  ExecutionResult result{std::make_shared<ResultSet>(std::vector<TargetInfo>{},
3936  nullptr,
3937  0,
3938  0),
3939  {}};
3940  result = ra_executor.executeRelAlgQuery(co, eo, false, false, nullptr);
3941  targets = result.getTargetsMeta();
3942 
3943  return result.getRows();
3944 }
double g_running_query_interrupt_freq
Definition: Execute.cpp:141
unsigned g_pending_query_interrupt_freq
Definition: Execute.cpp:140
bool g_from_table_reordering
Definition: Execute.cpp:97
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:513
static SysCatalog & instance()
Definition: SysCatalog.h:343
bool g_enable_watchdog
bool g_optimize_cuda_block_and_grid_sizes
Definition: Execute.cpp:169
static CompilationOptions defaults(const ExecutorDeviceType device_type=ExecutorDeviceType::GPU)
std::string pg_shim(std::string const &query)
static constexpr ExecutorId UNITARY_EXECUTOR_ID
Definition: Execute.h:423
std::shared_ptr< Catalog_Namespace::SessionInfo const > getConstSessionInfo() const
Definition: QueryState.cpp:84

+ Here is the caller graph for this function:

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

Definition at line 119 of file ParserNode.cpp.

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

120  {
121  std::vector<int> table_chunk_key_prefix;
122  if (td) {
123  if (td->fragmenter) {
124  table_chunk_key_prefix = td->fragmenter->getFragmentsForQuery().chunkKeyPrefix;
125  } else {
126  table_chunk_key_prefix.push_back(catalog.getCurrentDB().dbId);
127  table_chunk_key_prefix.push_back(td->tableId);
128  }
129  }
130  return table_chunk_key_prefix;
131 }
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 6010 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().

6013  {
6014  static const std::map<std::pair<const std::string, const DBObjectType>,
6015  std::pair<const AccessPrivileges, const DBObjectType>>
6016  privileges_lookup{
6017  {{"ALL"s, DatabaseDBObjectType},
6020  {{"ALL"s, DashboardDBObjectType},
6023  {{"ALL"s, ServerDBObjectType},
6025 
6026  {{"CREATE TABLE"s, DatabaseDBObjectType},
6028  {{"CREATE"s, DatabaseDBObjectType},
6030  {{"SELECT"s, DatabaseDBObjectType},
6032  {{"INSERT"s, DatabaseDBObjectType},
6034  {{"TRUNCATE"s, DatabaseDBObjectType},
6036  {{"UPDATE"s, DatabaseDBObjectType},
6038  {{"DELETE"s, DatabaseDBObjectType},
6040  {{"DROP"s, DatabaseDBObjectType},
6042  {{"ALTER"s, DatabaseDBObjectType},
6044 
6045  {{"SELECT"s, TableDBObjectType},
6047  {{"INSERT"s, TableDBObjectType},
6049  {{"TRUNCATE"s, TableDBObjectType},
6051  {{"UPDATE"s, TableDBObjectType},
6053  {{"DELETE"s, TableDBObjectType},
6055  {{"DROP"s, TableDBObjectType},
6057  {{"ALTER"s, TableDBObjectType},
6059 
6060  {{"CREATE VIEW"s, DatabaseDBObjectType},
6062  {{"SELECT VIEW"s, DatabaseDBObjectType},
6064  {{"DROP VIEW"s, DatabaseDBObjectType},
6066  {{"SELECT"s, ViewDBObjectType},
6069 
6070  {{"CREATE DASHBOARD"s, DatabaseDBObjectType},
6072  {{"EDIT DASHBOARD"s, DatabaseDBObjectType},
6074  {{"VIEW DASHBOARD"s, DatabaseDBObjectType},
6076  {{"DELETE DASHBOARD"s, DatabaseDBObjectType},
6078  {{"VIEW"s, DashboardDBObjectType},
6080  {{"EDIT"s, DashboardDBObjectType},
6082  {{"DELETE"s, DashboardDBObjectType},
6084 
6085  {{"CREATE SERVER"s, DatabaseDBObjectType},
6087  {{"DROP SERVER"s, DatabaseDBObjectType},
6089  {{"DROP"s, ServerDBObjectType},
6091  {{"ALTER SERVER"s, DatabaseDBObjectType},
6093  {{"ALTER"s, ServerDBObjectType},
6095  {{"USAGE"s, ServerDBObjectType},
6097  {{"SERVER USAGE"s, DatabaseDBObjectType},
6099 
6100  {{"VIEW SQL EDITOR"s, DatabaseDBObjectType},
6102  {{"ACCESS"s, DatabaseDBObjectType},
6104 
6105  auto result = privileges_lookup.find(std::make_pair(privs, objectType));
6106  if (result == privileges_lookup.end()) {
6107  throw std::runtime_error("Privileges " + privs + " on DB object " + object_name +
6108  " are not correct.");
6109  }
6110  return result->second;
6111 }
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 6943 of file ParserNode.cpp.

References CHECK.

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

6944  {
6945  CHECK(p);
6946  const std::string* str =
6947  static_cast<const StringLiteral*>(p->get_value())->get_stringval();
6948  if (boost::iequals(*str, "true")) {
6949  return true;
6950  } else if (boost::iequals(*str, "false")) {
6951  return false;
6952  } else {
6953  throw std::runtime_error("Value to " + option_name + " must be TRUE or FALSE.");
6954  }
6955 }
#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 5053 of file ParserNode.cpp.

References CHECK.

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

5053  {
5054  for (const auto& opt : options) {
5055  if (boost::iequals(*opt->get_name(), "REPAIR_TYPE")) {
5056  const auto repair_type =
5057  static_cast<const StringLiteral*>(opt->get_value())->get_stringval();
5058  CHECK(repair_type);
5059  if (boost::iequals(*repair_type, "REMOVE")) {
5060  return true;
5061  } else {
5062  throw std::runtime_error("REPAIR_TYPE must be REMOVE.");
5063  }
5064  } else {
5065  throw std::runtime_error("The only VALIDATE WITH options is REPAIR_TYPE.");
5066  }
5067  }
5068  return false;
5069 }
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 5335 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().

5335  {
5336  bool not_null;
5337  const ColumnConstraintDef* cc = coldef->get_column_constraint();
5338  if (cc == nullptr) {
5339  not_null = false;
5340  } else {
5341  not_null = cc->get_notnull();
5342  }
5343  std::string default_value;
5344  const std::string* default_value_ptr = nullptr;
5345  if (cc) {
5346  if (auto def_val_literal = cc->get_defaultval()) {
5347  auto defaultsp = dynamic_cast<const StringLiteral*>(def_val_literal);
5348  default_value =
5349  defaultsp ? *defaultsp->get_stringval() : def_val_literal->to_string();
5350  // The preprocessing below is needed because:
5351  // a) TypedImportBuffer expects arrays in the {...} format
5352  // b) TypedImportBuffer expects string literals inside arrays w/o any quotes
5353  if (coldef->get_column_type()->get_is_array()) {
5354  std::regex array_re(R"(^ARRAY\s*\[(.*)\]$)", std::regex_constants::icase);
5355  default_value = std::regex_replace(default_value, array_re, "{$1}");
5356  boost::erase_all(default_value, "\'");
5357  }
5358  default_value_ptr = &default_value;
5359  }
5360  }
5361  ddl_utils::set_column_descriptor(*coldef->get_column_name(),
5362  cd,
5363  coldef->get_column_type(),
5364  not_null,
5365  coldef->get_compression(),
5366  default_value_ptr);
5367 }
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 317 of file ParserNode.cpp.

References CHECK.

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

318  {
319  if (dynamic_cast<Analyzer::Constant*>(rhs_expr.get())) {
320  // we must translate rhs string literal against lhs str dictionary
321  return true;
322  }
323  std::set<int> lhs_rte_idx;
324  lhs_expr->collect_rte_idx(lhs_rte_idx);
325  CHECK(!lhs_rte_idx.empty());
326  std::set<int> rhs_rte_idx;
327  rhs_expr->collect_rte_idx(rhs_rte_idx);
328  CHECK(!rhs_rte_idx.empty());
329  return lhs_rte_idx.size() == 1UL && lhs_rte_idx == rhs_rte_idx;
330 }
#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 5970 of file ParserNode.cpp.

References split().

Referenced by extractObjectNameFromHierName().

5970  {
5971  std::vector<std::string> componentNames;
5972  boost::split(componentNames, hierName, boost::is_any_of("."));
5973  return componentNames;
5974 }
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 7385 of file ParserNode.cpp.

References to_string().

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

7385  {
7386  int64_t fragment_size_value{-1};
7387  bool validation_failed{false};
7388  try {
7389  fragment_size_value = std::stoll(fragment_size_str);
7390  } catch (std::out_of_range& e) {
7391  validation_failed = true;
7392  }
7393  constexpr int64_t max_fragment_size = std::numeric_limits<int32_t>::max();
7394  if (!validation_failed &&
7395  (fragment_size_value <= 0 || fragment_size_value > max_fragment_size)) {
7396  validation_failed = true;
7397  }
7398  if (validation_failed) {
7399  throw std::runtime_error(
7400  "Invalid value \"" + fragment_size_str +
7401  "\" provided for FRAGMENT_SIZE option, expected a positive integer between "
7402  "1 and " +
7403  std::to_string(max_fragment_size) + ".");
7404  }
7405  return fragment_size_value;
7406 }
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 6132 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().

6135  {
6136  if (objectType == TableDBObjectType) {
6137  auto td = sessionCatalog.getMetadataForTable(objectName, false);
6138  if (!td || td->isView) {
6139  // expected TABLE, found VIEW
6140  throw std::runtime_error(command + " failed. Object '" + objectName + "' of type " +
6141  DBObjectTypeToString(objectType) + " not found.");
6142  }
6143 
6144  } else if (objectType == ViewDBObjectType) {
6145  auto td = sessionCatalog.getMetadataForTable(objectName, false);
6146  if (!td || !td->isView) {
6147  // expected VIEW, found TABLE
6148  throw std::runtime_error(command + " failed. Object '" + objectName + "' of type " +
6149  DBObjectTypeToString(objectType) + " not found.");
6150  }
6151  }
6152 }
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 3485 of file ParserNode.cpp.

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

3490  {
3491  // Create a RapidJSON document
3492  rapidjson::Document doc;
3493  doc.SetObject();
3494 
3495  // Add the fields to the document
3496  rapidjson::Value predicted_value;
3497  predicted_value.SetString(predicted.c_str(), predicted.length(), doc.GetAllocator());
3498  doc.AddMember("predicted", predicted_value, doc.GetAllocator());
3499 
3500  rapidjson::Value features_array(rapidjson::kArrayType);
3501  for (const auto& feature : features) {
3502  rapidjson::Value feature_value;
3503  feature_value.SetString(feature.c_str(), feature.length(), doc.GetAllocator());
3504  features_array.PushBack(feature_value, doc.GetAllocator());
3505  }
3506  doc.AddMember("features", features_array, doc.GetAllocator());
3507 
3508  rapidjson::Value training_query_value;
3509  training_query_value.SetString(
3510  training_query.c_str(), training_query.length(), doc.GetAllocator());
3511  doc.AddMember("training_query", training_query_value, doc.GetAllocator());
3512 
3513  rapidjson::Value data_split_train_fraction_key("data_split_train_fraction",
3514  doc.GetAllocator());
3515 
3516  rapidjson::Value data_split_train_fraction_value(data_split_train_fraction);
3517 
3518  doc.AddMember(
3519  data_split_train_fraction_key, data_split_train_fraction_value, doc.GetAllocator());
3520 
3521  rapidjson::Value data_split_eval_fraction_key("data_split_eval_fraction",
3522  doc.GetAllocator());
3523 
3524  rapidjson::Value data_split_eval_fraction_value(data_split_eval_fraction);
3525 
3526  doc.AddMember(
3527  data_split_eval_fraction_key, data_split_eval_fraction_value, doc.GetAllocator());
3528 
3529  rapidjson::Value feature_permutations_array(rapidjson::kArrayType);
3530  for (const auto& feature_permutation : feature_permutations) {
3531  rapidjson::Value feature_permutation_value;
3532  feature_permutation_value.SetInt64(feature_permutation);
3533  feature_permutations_array.PushBack(feature_permutation_value, doc.GetAllocator());
3534  }
3535  doc.AddMember("feature_permutations", feature_permutations_array, doc.GetAllocator());
3536 
3537  // Convert the document to a JSON string
3538  rapidjson::StringBuffer buffer;
3539  rapidjson::Writer<rapidjson::StringBuffer> writer(buffer);
3540  doc.Accept(writer);
3541 
3542  return buffer.GetString();
3543 }

+ Here is the caller graph for this function: