OmniSciDB  cde582ebc3
 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  AlterTableStmt
 
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  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
 
struct  ShouldInvalidateSessionsByDB
 
struct  ShouldInvalidateSessionsByUser
 
struct  ShouldInvalidateSessionsByDB< DropDBStmt >
 
struct  ShouldInvalidateSessionsByUser< DropUserStmt >
 
struct  ShouldInvalidateSessionsByDB< RenameDBStmt >
 
struct  ShouldInvalidateSessionsByUser< RenameUserStmt >
 

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 exprs_share_one_and_same_rte_idx (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::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)
 
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)
 
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 4773 of file ParserNode.cpp.

Function Documentation

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

Definition at line 4676 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 Parser::AddColumnStmt::check_executable(), Parser::RenameTableStmt::execute(), Parser::RenameColumnStmt::execute(), Parser::DropColumnStmt::execute(), and Parser::AlterTableParamStmt::execute().

4677  {
4678  if (session.get_currentUser().isSuper ||
4679  session.get_currentUser().userId == td->userId) {
4680  return;
4681  }
4682  std::vector<DBObject> privObjects;
4683  DBObject dbObject(td->tableName, TableDBObjectType);
4684  dbObject.loadKey(session.getCatalog());
4685  dbObject.setPrivileges(AccessPrivileges::ALTER_TABLE);
4686  privObjects.push_back(dbObject);
4687  if (!SysCatalog::instance().checkPrivileges(session.get_currentUser(), privObjects)) {
4688  throw std::runtime_error("Current user does not have the privilege to alter table: " +
4689  td->tableName);
4690  }
4691 }
std::string tableName
static const AccessPrivileges ALTER_TABLE
Definition: DBObject.h:165
Catalog & getCatalog() const
Definition: SessionInfo.h:65
const UserMetadata & get_currentUser() const
Definition: SessionInfo.h:71
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 102 of file ParserNode.cpp.

References g_enable_non_kernel_time_query_interrupt.

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

102  {
103  // we call this function with unitary executor but is okay since
104  // we know the exact session info from a global session map object
105  // in the executor
108  executor->getSessionLock());
109  return executor->checkIsQuerySessionInterrupted(query_session, session_read_lock);
110  }
111  return false;
112 }
bool g_enable_non_kernel_time_query_interrupt
Definition: Execute.cpp:126
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 6460 of file ParserNode.cpp.

References CHECK.

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

6461  {
6462  CHECK(p);
6463  if (!dynamic_cast<const StringLiteral*>(p->get_value())) {
6464  throw std::runtime_error(option_name + " option must be a string literal.");
6465  }
6466 }
#define CHECK(condition)
Definition: Logger.h:222

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

References CHECK, SQLTypeInfo::get_comp_param(), SQLTypeInfo::get_dimension(), get_str_dict_cast_type(), SQLTypeInfo::is_dict_encoded_string(), SQLTypeInfo::is_none_encoded_string(), SQLTypeInfo::is_string(), SQLTypeInfo::set_dimension(), and TRANSIENT_DICT.

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

348  {
349  CHECK(lhs_type_info.is_string());
350  CHECK(rhs_type_info.is_string());
351  const auto lhs_comp_param = lhs_type_info.get_comp_param();
352  const auto rhs_comp_param = rhs_type_info.get_comp_param();
353  if (lhs_type_info.is_dict_encoded_string() && rhs_type_info.is_dict_encoded_string()) {
354  if (lhs_comp_param == rhs_comp_param ||
355  lhs_comp_param == TRANSIENT_DICT(rhs_comp_param)) {
356  return lhs_comp_param <= rhs_comp_param ? lhs_type_info : rhs_type_info;
357  }
358  return get_str_dict_cast_type(lhs_type_info, rhs_type_info, executor);
359  }
360  CHECK(lhs_type_info.is_none_encoded_string() || rhs_type_info.is_none_encoded_string());
361  SQLTypeInfo ret_ti =
362  rhs_type_info.is_none_encoded_string() ? lhs_type_info : rhs_type_info;
363  if (ret_ti.is_none_encoded_string()) {
364  ret_ti.set_dimension(
365  std::max(lhs_type_info.get_dimension(), rhs_type_info.get_dimension()));
366  }
367  return ret_ti;
368 }
void set_dimension(int d)
Definition: sqltypes.h:431
bool is_none_encoded_string() const
Definition: sqltypes.h:552
HOST DEVICE int get_dimension() const
Definition: sqltypes.h:331
HOST DEVICE int get_comp_param() const
Definition: sqltypes.h:338
#define CHECK(condition)
Definition: Logger.h:222
bool is_dict_encoded_string() const
Definition: sqltypes.h:548
bool is_string() const
Definition: sqltypes.h:510
#define TRANSIENT_DICT(ID)
Definition: sqltypes.h:260
SQLTypeInfo const & get_str_dict_cast_type(const SQLTypeInfo &lhs_type_info, const SQLTypeInfo &rhs_type_info, const Executor *executor)
Definition: ParserNode.cpp:323

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

References CHECK, Parser::AlterTableStmt::delegate(), UNREACHABLE, and VLOG.

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

6878  {
6879  CHECK(!query_json.empty());
6880  VLOG(2) << "Parsing JSON DDL from Calcite: " << query_json;
6881  rapidjson::Document ddl_query;
6882  ddl_query.Parse(query_json);
6883  CHECK(ddl_query.IsObject());
6884  CHECK(ddl_query.HasMember("payload"));
6885  CHECK(ddl_query["payload"].IsObject());
6886  const auto& payload = ddl_query["payload"].GetObject();
6887  CHECK(payload.HasMember("command"));
6888  CHECK(payload["command"].IsString());
6889 
6890  const auto& ddl_command = std::string_view(payload["command"].GetString());
6891 
6892  Parser::Stmt* stmt = nullptr;
6893  if (ddl_command == "CREATE_TABLE") {
6894  stmt = new Parser::CreateTableStmt(payload);
6895  } else if (ddl_command == "DROP_TABLE") {
6896  stmt = new Parser::DropTableStmt(payload);
6897  } else if (ddl_command == "RENAME_TABLE") {
6898  stmt = new Parser::RenameTableStmt(payload);
6899  } else if (ddl_command == "ALTER_TABLE") {
6900  std::unique_ptr<Parser::DDLStmt> ddlStmt;
6901  ddlStmt = Parser::AlterTableStmt::delegate(payload);
6902  if (ddlStmt != nullptr) {
6903  stmt = ddlStmt.get();
6904  ddlStmt.release();
6905  }
6906  } else if (ddl_command == "TRUNCATE_TABLE") {
6907  stmt = new Parser::TruncateTableStmt(payload);
6908  } else if (ddl_command == "DUMP_TABLE") {
6909  stmt = new Parser::DumpTableStmt(payload);
6910  } else if (ddl_command == "RESTORE_TABLE") {
6911  stmt = new Parser::RestoreTableStmt(payload);
6912  } else if (ddl_command == "OPTIMIZE_TABLE") {
6913  stmt = new Parser::OptimizeTableStmt(payload);
6914  } else if (ddl_command == "COPY_TABLE") {
6915  stmt = new Parser::CopyTableStmt(payload);
6916  } else if (ddl_command == "EXPORT_QUERY") {
6917  stmt = new Parser::ExportQueryStmt(payload);
6918  } else if (ddl_command == "CREATE_VIEW") {
6919  stmt = new Parser::CreateViewStmt(payload);
6920  } else if (ddl_command == "DROP_VIEW") {
6921  stmt = new Parser::DropViewStmt(payload);
6922  } else if (ddl_command == "CREATE_DB") {
6923  stmt = new Parser::CreateDBStmt(payload);
6924  } else if (ddl_command == "DROP_DB") {
6925  stmt = new Parser::DropDBStmt(payload);
6926  } else if (ddl_command == "RENAME_DB") {
6927  stmt = new Parser::RenameDBStmt(payload);
6928  } else if (ddl_command == "CREATE_USER") {
6929  stmt = new Parser::CreateUserStmt(payload);
6930  } else if (ddl_command == "DROP_USER") {
6931  stmt = new Parser::DropUserStmt(payload);
6932  } else if (ddl_command == "ALTER_USER") {
6933  stmt = new Parser::AlterUserStmt(payload);
6934  } else if (ddl_command == "RENAME_USER") {
6935  stmt = new Parser::RenameUserStmt(payload);
6936  } else if (ddl_command == "CREATE_ROLE") {
6937  stmt = new Parser::CreateRoleStmt(payload);
6938  } else if (ddl_command == "DROP_ROLE") {
6939  stmt = new Parser::DropRoleStmt(payload);
6940  } else if (ddl_command == "GRANT_ROLE") {
6941  stmt = new Parser::GrantRoleStmt(payload);
6942  } else if (ddl_command == "REVOKE_ROLE") {
6943  stmt = new Parser::RevokeRoleStmt(payload);
6944  } else if (ddl_command == "GRANT_PRIVILEGE") {
6945  stmt = new Parser::GrantPrivilegesStmt(payload);
6946  } else if (ddl_command == "REVOKE_PRIVILEGE") {
6947  stmt = new Parser::RevokePrivilegesStmt(payload);
6948  } else if (ddl_command == "CREATE_DATAFRAME") {
6949  stmt = new Parser::CreateDataframeStmt(payload);
6950  } else if (ddl_command == "VALIDATE_SYSTEM") {
6951  // VALIDATE should have been excuted in outer context before it reaches here
6952  UNREACHABLE(); // not-implemented alterType
6953  } else {
6954  throw std::runtime_error("Unsupported DDL command");
6955  }
6956  return std::unique_ptr<Parser::Stmt>(stmt);
6957 }
#define UNREACHABLE()
Definition: Logger.h:266
#define CHECK(condition)
Definition: Logger.h:222
#define VLOG(n)
Definition: Logger.h:316
static std::unique_ptr< Parser::DDLStmt > delegate(const rapidjson::Value &payload)

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

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

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

6858  {
6859  auto session_copy = session_info;
6860  auto session_ptr = std::shared_ptr<Catalog_Namespace::SessionInfo>(
6861  &session_copy, boost::null_deleter());
6862  auto query_state = query_state::QueryState::create(session_ptr, queryStr);
6863  const auto& cat = session_info.getCatalog();
6864  auto calcite_mgr = cat.getCalciteMgr();
6865  const auto calciteQueryParsingOption =
6866  calcite_mgr->getCalciteQueryParsingOption(true, false, true);
6867  const auto calciteOptimizationOption =
6868  calcite_mgr->getCalciteOptimizationOption(false, g_enable_watchdog, {});
6869  const auto query_json = calcite_mgr
6870  ->process(query_state->createQueryStateProxy(),
6871  pg_shim(queryStr),
6872  calciteQueryParsingOption,
6873  calciteOptimizationOption)
6874  .plan_result;
6875  return create_stmt_for_json(query_json);
6876 }
std::string cat(Ts &&...args)
static std::shared_ptr< QueryState > create(ARGS &&...args)
Definition: QueryState.h:145
std::unique_ptr< Parser::Stmt > create_stmt_for_json(const std::string &query_json)
bool g_enable_watchdog
Catalog & getCatalog() const
Definition: SessionInfo.h:65
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 5712 of file ParserNode.cpp.

References DashboardDBObjectType.

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

5712  {
5713  if (objectType == DashboardDBObjectType) {
5714  int32_t dashboard_id = -1;
5715  if (!objectName.empty()) {
5716  try {
5717  dashboard_id = stoi(objectName);
5718  } catch (const std::exception&) {
5719  throw std::runtime_error(
5720  "Privileges on dashboards should be changed via integer dashboard ID");
5721  }
5722  }
5723  return DBObject(dashboard_id, objectType);
5724  } else {
5725  return DBObject(objectName, objectType);
5726  }
5727 }

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

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

6962  {
6963  std::unique_ptr<Parser::Stmt> stmt = create_stmt_for_json(query_json);
6964  auto ddl = dynamic_cast<Parser::DDLStmt*>(stmt.get());
6965  if (ddl != nullptr) {
6966  (*ddl).execute(*session_ptr, read_only_mode);
6967  }
6968 }
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:

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

Definition at line 312 of file ParserNode.cpp.

References CHECK.

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

313  {
314  std::set<int> lhs_rte_idx;
315  lhs_expr->collect_rte_idx(lhs_rte_idx);
316  CHECK(!lhs_rte_idx.empty());
317  std::set<int> rhs_rte_idx;
318  rhs_expr->collect_rte_idx(rhs_rte_idx);
319  CHECK(!rhs_rte_idx.empty());
320  return lhs_rte_idx.size() == 1UL && lhs_rte_idx == rhs_rte_idx;
321 }
#define CHECK(condition)
Definition: Logger.h:222

+ Here is the caller graph for this function:

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

Definition at line 5575 of file ParserNode.cpp.

References splitObjectHierName().

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

5577  {
5578  std::string objectName;
5579  std::vector<std::string> componentNames = splitObjectHierName(objectHierName);
5580  if (objectType.compare("DATABASE") == 0) {
5581  if (componentNames.size() == 1) {
5582  objectName = componentNames[0];
5583  } else {
5584  throw std::runtime_error("DB object name is not correct " + objectHierName);
5585  }
5586  } else {
5587  if (objectType.compare("TABLE") == 0 || objectType.compare("DASHBOARD") == 0 ||
5588  objectType.compare("VIEW") == 0 || objectType.compare("SERVER") == 0) {
5589  switch (componentNames.size()) {
5590  case (1): {
5591  objectName = componentNames[0];
5592  break;
5593  }
5594  case (2): {
5595  objectName = componentNames[1];
5596  break;
5597  }
5598  default: {
5599  throw std::runtime_error("DB object name is not correct " + objectHierName);
5600  }
5601  }
5602  } else {
5603  throw std::runtime_error("DB object type " + objectType + " is not supported.");
5604  }
5605  }
5606  return objectName;
5607 }
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:

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

Definition at line 323 of file ParserNode.cpp.

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

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

325  {
326  CHECK(lhs_type_info.is_string());
327  CHECK(lhs_type_info.get_compression() == kENCODING_DICT);
328  CHECK(rhs_type_info.is_string());
329  CHECK(rhs_type_info.get_compression() == kENCODING_DICT);
330  const auto lhs_comp_param = lhs_type_info.get_comp_param();
331  const auto rhs_comp_param = rhs_type_info.get_comp_param();
332  CHECK_NE(lhs_comp_param, rhs_comp_param);
333  if (lhs_type_info.get_comp_param() == TRANSIENT_DICT_ID) {
334  return rhs_type_info;
335  }
336  if (rhs_type_info.get_comp_param() == TRANSIENT_DICT_ID) {
337  return lhs_type_info;
338  }
339  // If here then neither lhs or rhs type was transient, we should see which
340  // type has the largest dictionary and make that the destination type
341  const auto lhs_sdp = executor->getStringDictionaryProxy(lhs_comp_param, true);
342  const auto rhs_sdp = executor->getStringDictionaryProxy(rhs_comp_param, true);
343  return lhs_sdp->entryCount() >= rhs_sdp->entryCount() ? lhs_type_info : rhs_type_info;
344 }
#define CHECK_NE(x, y)
Definition: Logger.h:231
#define TRANSIENT_DICT_ID
Definition: sqltypes.h:259
HOST DEVICE EncodingType get_compression() const
Definition: sqltypes.h:337
HOST DEVICE int get_comp_param() const
Definition: sqltypes.h:338
#define CHECK(condition)
Definition: Logger.h:222
bool is_string() const
Definition: sqltypes.h:510

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

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

3378  {},
3379  bool allow_interrupt = false) {
3380  auto const session = query_state_proxy.getQueryState().getConstSessionInfo();
3381  auto& catalog = session->getCatalog();
3382 
3384 #ifdef HAVE_CUDA
3385  const auto device_type = session->get_executor_device_type();
3386 #else
3387  const auto device_type = ExecutorDeviceType::CPU;
3388 #endif // HAVE_CUDA
3389  auto calcite_mgr = catalog.getCalciteMgr();
3390 
3391  // TODO MAT this should actually get the global or the session parameter for
3392  // view optimization
3393  const auto calciteQueryParsingOption =
3394  calcite_mgr->getCalciteQueryParsingOption(true, false, true);
3395  const auto calciteOptimizationOption =
3396  calcite_mgr->getCalciteOptimizationOption(false, g_enable_watchdog, {});
3397  const auto query_ra = calcite_mgr
3398  ->process(query_state_proxy,
3399  pg_shim(select_stmt),
3400  calciteQueryParsingOption,
3401  calciteOptimizationOption)
3402  .plan_result;
3403  RelAlgExecutor ra_executor(executor.get(),
3404  catalog,
3405  query_ra,
3406  query_state_proxy.getQueryState().shared_from_this());
3408  // TODO(adb): Need a better method of dropping constants into this ExecutionOptions
3409  // struct
3410  ExecutionOptions eo = {false,
3411  false,
3412  true,
3413  false,
3414  true,
3415  false,
3416  false,
3417  validate_only,
3418  false,
3419  10000,
3420  false,
3421  false,
3422  1000,
3423  allow_interrupt,
3427  outer_fragment_indices};
3428 
3429  ExecutionResult result{std::make_shared<ResultSet>(std::vector<TargetInfo>{},
3432  nullptr,
3433  nullptr,
3434  0,
3435  0),
3436  {}};
3437  result = ra_executor.executeRelAlgQuery(co, eo, false, nullptr);
3438  targets = result.getTargetsMeta();
3439 
3440  return result.getRows();
3441 }
double g_running_query_interrupt_freq
Definition: Execute.cpp:129
unsigned g_pending_query_interrupt_freq
Definition: Execute.cpp:128
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:468
QueryState & getQueryState()
Definition: QueryState.h:181
bool g_enable_watchdog
static CompilationOptions defaults(const ExecutorDeviceType device_type=ExecutorDeviceType::GPU)
std::shared_ptr< Catalog_Namespace::SessionInfo const > getConstSessionInfo() const
Definition: QueryState.cpp:88
std::string pg_shim(const std::string &query)
static const ExecutorId UNITARY_EXECUTOR_ID
Definition: Execute.h:376

+ Here is the caller graph for this function:

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

Definition at line 114 of file ParserNode.cpp.

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

115  {
116  std::vector<int> table_chunk_key_prefix;
117  if (td) {
118  if (td->fragmenter) {
119  table_chunk_key_prefix = td->fragmenter->getFragmentsForQuery().chunkKeyPrefix;
120  } else {
121  table_chunk_key_prefix.push_back(catalog.getCurrentDB().dbId);
122  table_chunk_key_prefix.push_back(td->tableId);
123  }
124  }
125  return table_chunk_key_prefix;
126 }
const DBMetadata & getCurrentDB() const
Definition: Catalog.h:242
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 1598 of file ParserNode.h.

References CHECK.

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

1599  {
1600  CHECK(l);
1601  for (auto str : *l) {
1602  v.push_back(*str);
1603  delete str;
1604  }
1605  delete l;
1606 }
#define CHECK(condition)
Definition: Logger.h:222

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

5612  {
5613  static const std::map<std::pair<const std::string, const DBObjectType>,
5614  std::pair<const AccessPrivileges, const DBObjectType>>
5615  privileges_lookup{
5616  {{"ALL"s, DatabaseDBObjectType},
5619  {{"ALL"s, DashboardDBObjectType},
5622  {{"ALL"s, ServerDBObjectType},
5624 
5625  {{"CREATE TABLE"s, DatabaseDBObjectType},
5627  {{"CREATE"s, DatabaseDBObjectType},
5629  {{"SELECT"s, DatabaseDBObjectType},
5631  {{"INSERT"s, DatabaseDBObjectType},
5633  {{"TRUNCATE"s, DatabaseDBObjectType},
5635  {{"UPDATE"s, DatabaseDBObjectType},
5637  {{"DELETE"s, DatabaseDBObjectType},
5639  {{"DROP"s, DatabaseDBObjectType},
5641  {{"ALTER"s, DatabaseDBObjectType},
5643 
5644  {{"SELECT"s, TableDBObjectType},
5646  {{"INSERT"s, TableDBObjectType},
5648  {{"TRUNCATE"s, TableDBObjectType},
5650  {{"UPDATE"s, TableDBObjectType},
5652  {{"DELETE"s, TableDBObjectType},
5654  {{"DROP"s, TableDBObjectType},
5656  {{"ALTER"s, TableDBObjectType},
5658 
5659  {{"CREATE VIEW"s, DatabaseDBObjectType},
5661  {{"SELECT VIEW"s, DatabaseDBObjectType},
5663  {{"DROP VIEW"s, DatabaseDBObjectType},
5665  {{"SELECT"s, ViewDBObjectType},
5668 
5669  {{"CREATE DASHBOARD"s, DatabaseDBObjectType},
5671  {{"EDIT DASHBOARD"s, DatabaseDBObjectType},
5673  {{"VIEW DASHBOARD"s, DatabaseDBObjectType},
5675  {{"DELETE DASHBOARD"s, DatabaseDBObjectType},
5677  {{"VIEW"s, DashboardDBObjectType},
5679  {{"EDIT"s, DashboardDBObjectType},
5681  {{"DELETE"s, DashboardDBObjectType},
5683 
5684  {{"CREATE SERVER"s, DatabaseDBObjectType},
5686  {{"DROP SERVER"s, DatabaseDBObjectType},
5688  {{"DROP"s, ServerDBObjectType},
5690  {{"ALTER SERVER"s, DatabaseDBObjectType},
5692  {{"ALTER"s, ServerDBObjectType},
5694  {{"USAGE"s, ServerDBObjectType},
5696  {{"SERVER USAGE"s, DatabaseDBObjectType},
5698 
5699  {{"VIEW SQL EDITOR"s, DatabaseDBObjectType},
5701  {{"ACCESS"s, DatabaseDBObjectType},
5703 
5704  auto result = privileges_lookup.find(std::make_pair(privs, objectType));
5705  if (result == privileges_lookup.end()) {
5706  throw std::runtime_error("Privileges " + privs + " on DB object " + object_name +
5707  " are not correct.");
5708  }
5709  return result->second;
5710 }
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 6558 of file ParserNode.cpp.

References CHECK.

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

6559  {
6560  CHECK(p);
6561  const std::string* str =
6562  static_cast<const StringLiteral*>(p->get_value())->get_stringval();
6563  if (boost::iequals(*str, "true")) {
6564  return true;
6565  } else if (boost::iequals(*str, "false")) {
6566  return false;
6567  } else {
6568  throw std::runtime_error("Value to " + option_name + " must be TRUE or FALSE.");
6569  }
6570 }
#define CHECK(condition)
Definition: Logger.h:222

+ Here is the caller graph for this function:

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

Definition at line 4632 of file ParserNode.cpp.

References CHECK.

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

4632  {
4633  for (const auto& opt : options) {
4634  if (boost::iequals(*opt->get_name(), "REPAIR_TYPE")) {
4635  const auto repair_type =
4636  static_cast<const StringLiteral*>(opt->get_value())->get_stringval();
4637  CHECK(repair_type);
4638  if (boost::iequals(*repair_type, "REMOVE")) {
4639  return true;
4640  } else {
4641  throw std::runtime_error("REPAIR_TYPE must be REMOVE.");
4642  }
4643  } else {
4644  throw std::runtime_error("The only VALIDATE WITH options is REPAIR_TYPE.");
4645  }
4646  }
4647  return false;
4648 }
bool repair_type(std::list< std::unique_ptr< NameValueAssign >> &options)
#define CHECK(condition)
Definition: Logger.h:222

+ Here is the caller graph for this function:

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

Definition at line 5569 of file ParserNode.cpp.

References split().

Referenced by extractObjectNameFromHierName().

5569  {
5570  std::vector<std::string> componentNames;
5571  boost::split(componentNames, hierName, boost::is_any_of("."));
5572  return componentNames;
5573 }
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:

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

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

5734  {
5735  if (objectType == TableDBObjectType) {
5736  auto td = sessionCatalog.getMetadataForTable(objectName, false);
5737  if (!td || td->isView) {
5738  // expected TABLE, found VIEW
5739  throw std::runtime_error(command + " failed. Object '" + objectName + "' of type " +
5740  DBObjectTypeToString(objectType) + " not found.");
5741  }
5742 
5743  } else if (objectType == ViewDBObjectType) {
5744  auto td = sessionCatalog.getMetadataForTable(objectName, false);
5745  if (!td || !td->isView) {
5746  // expected VIEW, found TABLE
5747  throw std::runtime_error(command + " failed. Object '" + objectName + "' of type " +
5748  DBObjectTypeToString(objectType) + " not found.");
5749  }
5750  }
5751 }
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: