OmniSciDB  f17484ade4
 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 5169 of file ParserNode.cpp.

Function Documentation

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

Definition at line 5075 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().

5076  {
5077  if (session.get_currentUser().isSuper ||
5078  session.get_currentUser().userId == td->userId) {
5079  return;
5080  }
5081  std::vector<DBObject> privObjects;
5082  DBObject dbObject(td->tableName, TableDBObjectType);
5083  dbObject.loadKey(session.getCatalog());
5084  dbObject.setPrivileges(AccessPrivileges::ALTER_TABLE);
5085  privObjects.push_back(dbObject);
5086  if (!SysCatalog::instance().checkPrivileges(session.get_currentUser(), privObjects)) {
5087  throw std::runtime_error("Current user does not have the privilege to alter table: " +
5088  td->tableName);
5089  }
5090 }
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:131
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 6829 of file ParserNode.cpp.

References CHECK.

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

6830  {
6831  CHECK(p);
6832  if (!dynamic_cast<const StringLiteral*>(p->get_value())) {
6833  throw std::runtime_error(option_name + " option must be a string literal.");
6834  }
6835 }
#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 7272 of file ParserNode.cpp.

References CHECK, UNREACHABLE, and VLOG.

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

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

7249  {
7250  auto session_copy = session_info;
7251  auto session_ptr = std::shared_ptr<Catalog_Namespace::SessionInfo>(
7252  &session_copy, boost::null_deleter());
7253  auto query_state = query_state::QueryState::create(session_ptr, queryStr);
7254  const auto& cat = session_info.getCatalog();
7255  auto calcite_mgr = cat.getCalciteMgr();
7256  const auto calciteQueryParsingOption =
7257  calcite_mgr->getCalciteQueryParsingOption(true, false, true);
7258  const auto calciteOptimizationOption = calcite_mgr->getCalciteOptimizationOption(
7259  false,
7261  {},
7263  const auto query_json = calcite_mgr
7264  ->process(query_state->createQueryStateProxy(),
7265  pg_shim(queryStr),
7266  calciteQueryParsingOption,
7267  calciteOptimizationOption)
7268  .plan_result;
7269  return create_stmt_for_json(query_json);
7270 }
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 6091 of file ParserNode.cpp.

References DashboardDBObjectType.

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

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

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

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

7355  {
7356  std::unique_ptr<Parser::Stmt> stmt = create_stmt_for_json(query_json);
7357  auto ddl = dynamic_cast<Parser::DDLStmt*>(stmt.get());
7358  if (ddl != nullptr) {
7359  (*ddl).execute(*session_ptr, read_only_mode);
7360  }
7361 }
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 5954 of file ParserNode.cpp.

References splitObjectHierName().

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

5956  {
5957  std::string objectName;
5958  std::vector<std::string> componentNames = splitObjectHierName(objectHierName);
5959  if (objectType.compare("DATABASE") == 0) {
5960  if (componentNames.size() == 1) {
5961  objectName = componentNames[0];
5962  } else {
5963  throw std::runtime_error("DB object name is not correct " + objectHierName);
5964  }
5965  } else {
5966  if (objectType.compare("TABLE") == 0 || objectType.compare("DASHBOARD") == 0 ||
5967  objectType.compare("VIEW") == 0 || objectType.compare("SERVER") == 0) {
5968  switch (componentNames.size()) {
5969  case (1): {
5970  objectName = componentNames[0];
5971  break;
5972  }
5973  case (2): {
5974  objectName = componentNames[1];
5975  break;
5976  }
5977  default: {
5978  throw std::runtime_error("DB object name is not correct " + objectHierName);
5979  }
5980  }
5981  } else {
5982  throw std::runtime_error("DB object type " + objectType + " is not supported.");
5983  }
5984  }
5985  return objectName;
5986 }
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);
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  std::numeric_limits<size_t>::max(),
3913  outer_fragment_indices};
3914 
3915  ExecutionResult result{std::make_shared<ResultSet>(std::vector<TargetInfo>{},
3918  nullptr,
3919  0,
3920  0),
3921  {}};
3922  result = ra_executor.executeRelAlgQuery(co, eo, false, false, nullptr);
3923  targets = result.getTargetsMeta();
3924 
3925  return result.getRows();
3926 }
double g_running_query_interrupt_freq
Definition: Execute.cpp:134
unsigned g_pending_query_interrupt_freq
Definition: Execute.cpp:133
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:505
static SysCatalog & instance()
Definition: SysCatalog.h:343
bool g_enable_watchdog
bool g_optimize_cuda_block_and_grid_sizes
Definition: Execute.cpp:162
static CompilationOptions defaults(const ExecutorDeviceType device_type=ExecutorDeviceType::GPU)
std::shared_ptr< Catalog_Namespace::SessionInfo const > getConstSessionInfo() const
Definition: QueryState.cpp:84
std::string pg_shim(const std::string &query)
static const ExecutorId UNITARY_EXECUTOR_ID
Definition: Execute.h:423

+ 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 5988 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().

5991  {
5992  static const std::map<std::pair<const std::string, const DBObjectType>,
5993  std::pair<const AccessPrivileges, const DBObjectType>>
5994  privileges_lookup{
5995  {{"ALL"s, DatabaseDBObjectType},
5998  {{"ALL"s, DashboardDBObjectType},
6001  {{"ALL"s, ServerDBObjectType},
6003 
6004  {{"CREATE TABLE"s, DatabaseDBObjectType},
6006  {{"CREATE"s, DatabaseDBObjectType},
6008  {{"SELECT"s, DatabaseDBObjectType},
6010  {{"INSERT"s, DatabaseDBObjectType},
6012  {{"TRUNCATE"s, DatabaseDBObjectType},
6014  {{"UPDATE"s, DatabaseDBObjectType},
6016  {{"DELETE"s, DatabaseDBObjectType},
6018  {{"DROP"s, DatabaseDBObjectType},
6020  {{"ALTER"s, DatabaseDBObjectType},
6022 
6023  {{"SELECT"s, TableDBObjectType},
6025  {{"INSERT"s, TableDBObjectType},
6027  {{"TRUNCATE"s, TableDBObjectType},
6029  {{"UPDATE"s, TableDBObjectType},
6031  {{"DELETE"s, TableDBObjectType},
6033  {{"DROP"s, TableDBObjectType},
6035  {{"ALTER"s, TableDBObjectType},
6037 
6038  {{"CREATE VIEW"s, DatabaseDBObjectType},
6040  {{"SELECT VIEW"s, DatabaseDBObjectType},
6042  {{"DROP VIEW"s, DatabaseDBObjectType},
6044  {{"SELECT"s, ViewDBObjectType},
6047 
6048  {{"CREATE DASHBOARD"s, DatabaseDBObjectType},
6050  {{"EDIT DASHBOARD"s, DatabaseDBObjectType},
6052  {{"VIEW DASHBOARD"s, DatabaseDBObjectType},
6054  {{"DELETE DASHBOARD"s, DatabaseDBObjectType},
6056  {{"VIEW"s, DashboardDBObjectType},
6058  {{"EDIT"s, DashboardDBObjectType},
6060  {{"DELETE"s, DashboardDBObjectType},
6062 
6063  {{"CREATE SERVER"s, DatabaseDBObjectType},
6065  {{"DROP SERVER"s, DatabaseDBObjectType},
6067  {{"DROP"s, ServerDBObjectType},
6069  {{"ALTER SERVER"s, DatabaseDBObjectType},
6071  {{"ALTER"s, ServerDBObjectType},
6073  {{"USAGE"s, ServerDBObjectType},
6075  {{"SERVER USAGE"s, DatabaseDBObjectType},
6077 
6078  {{"VIEW SQL EDITOR"s, DatabaseDBObjectType},
6080  {{"ACCESS"s, DatabaseDBObjectType},
6082 
6083  auto result = privileges_lookup.find(std::make_pair(privs, objectType));
6084  if (result == privileges_lookup.end()) {
6085  throw std::runtime_error("Privileges " + privs + " on DB object " + object_name +
6086  " are not correct.");
6087  }
6088  return result->second;
6089 }
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 6921 of file ParserNode.cpp.

References CHECK.

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

6922  {
6923  CHECK(p);
6924  const std::string* str =
6925  static_cast<const StringLiteral*>(p->get_value())->get_stringval();
6926  if (boost::iequals(*str, "true")) {
6927  return true;
6928  } else if (boost::iequals(*str, "false")) {
6929  return false;
6930  } else {
6931  throw std::runtime_error("Value to " + option_name + " must be TRUE or FALSE.");
6932  }
6933 }
#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 5031 of file ParserNode.cpp.

References CHECK.

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

5031  {
5032  for (const auto& opt : options) {
5033  if (boost::iequals(*opt->get_name(), "REPAIR_TYPE")) {
5034  const auto repair_type =
5035  static_cast<const StringLiteral*>(opt->get_value())->get_stringval();
5036  CHECK(repair_type);
5037  if (boost::iequals(*repair_type, "REMOVE")) {
5038  return true;
5039  } else {
5040  throw std::runtime_error("REPAIR_TYPE must be REMOVE.");
5041  }
5042  } else {
5043  throw std::runtime_error("The only VALIDATE WITH options is REPAIR_TYPE.");
5044  }
5045  }
5046  return false;
5047 }
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 5313 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().

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

References split().

Referenced by extractObjectNameFromHierName().

5948  {
5949  std::vector<std::string> componentNames;
5950  boost::split(componentNames, hierName, boost::is_any_of("."));
5951  return componentNames;
5952 }
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 7363 of file ParserNode.cpp.

References to_string().

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

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

6113  {
6114  if (objectType == TableDBObjectType) {
6115  auto td = sessionCatalog.getMetadataForTable(objectName, false);
6116  if (!td || td->isView) {
6117  // expected TABLE, found VIEW
6118  throw std::runtime_error(command + " failed. Object '" + objectName + "' of type " +
6119  DBObjectTypeToString(objectType) + " not found.");
6120  }
6121 
6122  } else if (objectType == ViewDBObjectType) {
6123  auto td = sessionCatalog.getMetadataForTable(objectName, false);
6124  if (!td || !td->isView) {
6125  // expected VIEW, found TABLE
6126  throw std::runtime_error(command + " failed. Object '" + objectName + "' of type " +
6127  DBObjectTypeToString(objectType) + " not found.");
6128  }
6129  }
6130 }
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: