OmniSciDB  b28c0d5765
 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
 

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

Function Documentation

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

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

4736  {
4737  if (session.get_currentUser().isSuper ||
4738  session.get_currentUser().userId == td->userId) {
4739  return;
4740  }
4741  std::vector<DBObject> privObjects;
4742  DBObject dbObject(td->tableName, TableDBObjectType);
4743  dbObject.loadKey(session.getCatalog());
4744  dbObject.setPrivileges(AccessPrivileges::ALTER_TABLE);
4745  privObjects.push_back(dbObject);
4746  if (!SysCatalog::instance().checkPrivileges(session.get_currentUser(), privObjects)) {
4747  throw std::runtime_error("Current user does not have the privilege to alter table: " +
4748  td->tableName);
4749  }
4750 }
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 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 6518 of file ParserNode.cpp.

References CHECK.

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

6519  {
6520  CHECK(p);
6521  if (!dynamic_cast<const StringLiteral*>(p->get_value())) {
6522  throw std::runtime_error(option_name + " option must be a string literal.");
6523  }
6524 }
#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:492
bool is_none_encoded_string() const
Definition: sqltypes.h:632
HOST DEVICE int get_dimension() const
Definition: sqltypes.h:382
HOST DEVICE int get_comp_param() const
Definition: sqltypes.h:389
#define CHECK(condition)
Definition: Logger.h:222
bool is_dict_encoded_string() const
Definition: sqltypes.h:628
bool is_string() const
Definition: sqltypes.h:576
#define TRANSIENT_DICT(ID)
Definition: sqltypes.h:311
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 6939 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().

6939  {
6940  CHECK(!query_json.empty());
6941  VLOG(2) << "Parsing JSON DDL from Calcite: " << query_json;
6942  rapidjson::Document ddl_query;
6943  ddl_query.Parse(query_json);
6944  CHECK(ddl_query.IsObject());
6945  CHECK(ddl_query.HasMember("payload"));
6946  CHECK(ddl_query["payload"].IsObject());
6947  const auto& payload = ddl_query["payload"].GetObject();
6948  CHECK(payload.HasMember("command"));
6949  CHECK(payload["command"].IsString());
6950 
6951  const auto& ddl_command = std::string_view(payload["command"].GetString());
6952 
6953  Parser::Stmt* stmt = nullptr;
6954  if (ddl_command == "CREATE_TABLE") {
6955  stmt = new Parser::CreateTableStmt(payload);
6956  } else if (ddl_command == "DROP_TABLE") {
6957  stmt = new Parser::DropTableStmt(payload);
6958  } else if (ddl_command == "RENAME_TABLE") {
6959  stmt = new Parser::RenameTableStmt(payload);
6960  } else if (ddl_command == "ALTER_TABLE") {
6961  std::unique_ptr<Parser::DDLStmt> ddlStmt;
6962  ddlStmt = Parser::AlterTableStmt::delegate(payload);
6963  if (ddlStmt != nullptr) {
6964  stmt = ddlStmt.get();
6965  ddlStmt.release();
6966  }
6967  } else if (ddl_command == "TRUNCATE_TABLE") {
6968  stmt = new Parser::TruncateTableStmt(payload);
6969  } else if (ddl_command == "DUMP_TABLE") {
6970  stmt = new Parser::DumpTableStmt(payload);
6971  } else if (ddl_command == "RESTORE_TABLE") {
6972  stmt = new Parser::RestoreTableStmt(payload);
6973  } else if (ddl_command == "OPTIMIZE_TABLE") {
6974  stmt = new Parser::OptimizeTableStmt(payload);
6975  } else if (ddl_command == "COPY_TABLE") {
6976  stmt = new Parser::CopyTableStmt(payload);
6977  } else if (ddl_command == "EXPORT_QUERY") {
6978  stmt = new Parser::ExportQueryStmt(payload);
6979  } else if (ddl_command == "CREATE_VIEW") {
6980  stmt = new Parser::CreateViewStmt(payload);
6981  } else if (ddl_command == "DROP_VIEW") {
6982  stmt = new Parser::DropViewStmt(payload);
6983  } else if (ddl_command == "CREATE_DB") {
6984  stmt = new Parser::CreateDBStmt(payload);
6985  } else if (ddl_command == "DROP_DB") {
6986  stmt = new Parser::DropDBStmt(payload);
6987  } else if (ddl_command == "RENAME_DB") {
6988  stmt = new Parser::RenameDBStmt(payload);
6989  } else if (ddl_command == "CREATE_USER") {
6990  stmt = new Parser::CreateUserStmt(payload);
6991  } else if (ddl_command == "DROP_USER") {
6992  stmt = new Parser::DropUserStmt(payload);
6993  } else if (ddl_command == "ALTER_USER") {
6994  stmt = new Parser::AlterUserStmt(payload);
6995  } else if (ddl_command == "RENAME_USER") {
6996  stmt = new Parser::RenameUserStmt(payload);
6997  } else if (ddl_command == "CREATE_ROLE") {
6998  stmt = new Parser::CreateRoleStmt(payload);
6999  } else if (ddl_command == "DROP_ROLE") {
7000  stmt = new Parser::DropRoleStmt(payload);
7001  } else if (ddl_command == "GRANT_ROLE") {
7002  stmt = new Parser::GrantRoleStmt(payload);
7003  } else if (ddl_command == "REVOKE_ROLE") {
7004  stmt = new Parser::RevokeRoleStmt(payload);
7005  } else if (ddl_command == "GRANT_PRIVILEGE") {
7006  stmt = new Parser::GrantPrivilegesStmt(payload);
7007  } else if (ddl_command == "REVOKE_PRIVILEGE") {
7008  stmt = new Parser::RevokePrivilegesStmt(payload);
7009  } else if (ddl_command == "CREATE_DATAFRAME") {
7010  stmt = new Parser::CreateDataframeStmt(payload);
7011  } else if (ddl_command == "VALIDATE_SYSTEM") {
7012  // VALIDATE should have been excuted in outer context before it reaches here
7013  UNREACHABLE(); // not-implemented alterType
7014  } else {
7015  throw std::runtime_error("Unsupported DDL command");
7016  }
7017  return std::unique_ptr<Parser::Stmt>(stmt);
7018 }
#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 6914 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().

6916  {
6917  auto session_copy = session_info;
6918  auto session_ptr = std::shared_ptr<Catalog_Namespace::SessionInfo>(
6919  &session_copy, boost::null_deleter());
6920  auto query_state = query_state::QueryState::create(session_ptr, queryStr);
6921  const auto& cat = session_info.getCatalog();
6922  auto calcite_mgr = cat.getCalciteMgr();
6923  const auto calciteQueryParsingOption =
6924  calcite_mgr->getCalciteQueryParsingOption(true, false, true);
6925  const auto calciteOptimizationOption = calcite_mgr->getCalciteOptimizationOption(
6926  false,
6928  {},
6930  const auto query_json = calcite_mgr
6931  ->process(query_state->createQueryStateProxy(),
6932  pg_shim(queryStr),
6933  calciteQueryParsingOption,
6934  calciteOptimizationOption)
6935  .plan_result;
6936  return create_stmt_for_json(query_json);
6937 }
std::string cat(Ts &&...args)
static std::shared_ptr< QueryState > create(ARGS &&...args)
Definition: QueryState.h:145
static SysCatalog & instance()
Definition: SysCatalog.h:341
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 5771 of file ParserNode.cpp.

References DashboardDBObjectType.

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

5771  {
5772  if (objectType == DashboardDBObjectType) {
5773  int32_t dashboard_id = -1;
5774  if (!objectName.empty()) {
5775  try {
5776  dashboard_id = stoi(objectName);
5777  } catch (const std::exception&) {
5778  throw std::runtime_error(
5779  "Privileges on dashboards should be changed via integer dashboard ID");
5780  }
5781  }
5782  return DBObject(dashboard_id, objectType);
5783  } else {
5784  return DBObject(objectName, objectType);
5785  }
5786 }

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

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

7023  {
7024  std::unique_ptr<Parser::Stmt> stmt = create_stmt_for_json(query_json);
7025  auto ddl = dynamic_cast<Parser::DDLStmt*>(stmt.get());
7026  if (ddl != nullptr) {
7027  (*ddl).execute(*session_ptr, read_only_mode);
7028  }
7029 }
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 5634 of file ParserNode.cpp.

References splitObjectHierName().

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

5636  {
5637  std::string objectName;
5638  std::vector<std::string> componentNames = splitObjectHierName(objectHierName);
5639  if (objectType.compare("DATABASE") == 0) {
5640  if (componentNames.size() == 1) {
5641  objectName = componentNames[0];
5642  } else {
5643  throw std::runtime_error("DB object name is not correct " + objectHierName);
5644  }
5645  } else {
5646  if (objectType.compare("TABLE") == 0 || objectType.compare("DASHBOARD") == 0 ||
5647  objectType.compare("VIEW") == 0 || objectType.compare("SERVER") == 0) {
5648  switch (componentNames.size()) {
5649  case (1): {
5650  objectName = componentNames[0];
5651  break;
5652  }
5653  case (2): {
5654  objectName = componentNames[1];
5655  break;
5656  }
5657  default: {
5658  throw std::runtime_error("DB object name is not correct " + objectHierName);
5659  }
5660  }
5661  } else {
5662  throw std::runtime_error("DB object type " + objectType + " is not supported.");
5663  }
5664  }
5665  return objectName;
5666 }
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:310
HOST DEVICE EncodingType get_compression() const
Definition: sqltypes.h:388
HOST DEVICE int get_comp_param() const
Definition: sqltypes.h:389
#define CHECK(condition)
Definition: Logger.h:222
bool is_string() const
Definition: sqltypes.h:576

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

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

3397  {},
3398  bool allow_interrupt = false) {
3399  auto const session = query_state_proxy->getConstSessionInfo();
3400  auto& catalog = session->getCatalog();
3401 
3403 #ifdef HAVE_CUDA
3404  const auto device_type = session->get_executor_device_type();
3405 #else
3406  const auto device_type = ExecutorDeviceType::CPU;
3407 #endif // HAVE_CUDA
3408  auto calcite_mgr = catalog.getCalciteMgr();
3409 
3410  // TODO MAT this should actually get the global or the session parameter for
3411  // view optimization
3412  const auto calciteQueryParsingOption =
3413  calcite_mgr->getCalciteQueryParsingOption(true, false, true);
3414  const auto calciteOptimizationOption = calcite_mgr->getCalciteOptimizationOption(
3415  false,
3417  {},
3419  const auto query_ra = calcite_mgr
3420  ->process(query_state_proxy,
3421  pg_shim(select_stmt),
3422  calciteQueryParsingOption,
3423  calciteOptimizationOption)
3424  .plan_result;
3425  RelAlgExecutor ra_executor(
3426  executor.get(), catalog, query_ra, query_state_proxy->shared_from_this());
3428  // TODO(adb): Need a better method of dropping constants into this ExecutionOptions
3429  // struct
3430  ExecutionOptions eo = {false,
3431  false,
3432  true,
3433  false,
3434  true,
3435  false,
3436  false,
3437  validate_only,
3438  false,
3439  10000,
3440  false,
3441  false,
3442  1000,
3443  allow_interrupt,
3447  std::numeric_limits<size_t>::max(),
3449  outer_fragment_indices};
3450 
3451  ExecutionResult result{std::make_shared<ResultSet>(std::vector<TargetInfo>{},
3454  nullptr,
3455  nullptr,
3456  0,
3457  0),
3458  {}};
3459  result = ra_executor.executeRelAlgQuery(co, eo, false, nullptr);
3460  targets = result.getTargetsMeta();
3461 
3462  return result.getRows();
3463 }
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:478
static SysCatalog & instance()
Definition: SysCatalog.h:341
bool g_enable_watchdog
bool g_optimize_cuda_block_and_grid_sizes
Definition: Execute.cpp:157
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 5668 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().

5671  {
5672  static const std::map<std::pair<const std::string, const DBObjectType>,
5673  std::pair<const AccessPrivileges, const DBObjectType>>
5674  privileges_lookup{
5675  {{"ALL"s, DatabaseDBObjectType},
5678  {{"ALL"s, DashboardDBObjectType},
5681  {{"ALL"s, ServerDBObjectType},
5683 
5684  {{"CREATE TABLE"s, DatabaseDBObjectType},
5686  {{"CREATE"s, DatabaseDBObjectType},
5688  {{"SELECT"s, DatabaseDBObjectType},
5690  {{"INSERT"s, DatabaseDBObjectType},
5692  {{"TRUNCATE"s, DatabaseDBObjectType},
5694  {{"UPDATE"s, DatabaseDBObjectType},
5696  {{"DELETE"s, DatabaseDBObjectType},
5698  {{"DROP"s, DatabaseDBObjectType},
5700  {{"ALTER"s, DatabaseDBObjectType},
5702 
5703  {{"SELECT"s, TableDBObjectType},
5705  {{"INSERT"s, TableDBObjectType},
5707  {{"TRUNCATE"s, TableDBObjectType},
5709  {{"UPDATE"s, TableDBObjectType},
5711  {{"DELETE"s, TableDBObjectType},
5713  {{"DROP"s, TableDBObjectType},
5715  {{"ALTER"s, TableDBObjectType},
5717 
5718  {{"CREATE VIEW"s, DatabaseDBObjectType},
5720  {{"SELECT VIEW"s, DatabaseDBObjectType},
5722  {{"DROP VIEW"s, DatabaseDBObjectType},
5724  {{"SELECT"s, ViewDBObjectType},
5727 
5728  {{"CREATE DASHBOARD"s, DatabaseDBObjectType},
5730  {{"EDIT DASHBOARD"s, DatabaseDBObjectType},
5732  {{"VIEW DASHBOARD"s, DatabaseDBObjectType},
5734  {{"DELETE DASHBOARD"s, DatabaseDBObjectType},
5736  {{"VIEW"s, DashboardDBObjectType},
5738  {{"EDIT"s, DashboardDBObjectType},
5740  {{"DELETE"s, DashboardDBObjectType},
5742 
5743  {{"CREATE SERVER"s, DatabaseDBObjectType},
5745  {{"DROP SERVER"s, DatabaseDBObjectType},
5747  {{"DROP"s, ServerDBObjectType},
5749  {{"ALTER SERVER"s, DatabaseDBObjectType},
5751  {{"ALTER"s, ServerDBObjectType},
5753  {{"USAGE"s, ServerDBObjectType},
5755  {{"SERVER USAGE"s, DatabaseDBObjectType},
5757 
5758  {{"VIEW SQL EDITOR"s, DatabaseDBObjectType},
5760  {{"ACCESS"s, DatabaseDBObjectType},
5762 
5763  auto result = privileges_lookup.find(std::make_pair(privs, objectType));
5764  if (result == privileges_lookup.end()) {
5765  throw std::runtime_error("Privileges " + privs + " on DB object " + object_name +
5766  " are not correct.");
5767  }
5768  return result->second;
5769 }
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 6616 of file ParserNode.cpp.

References CHECK.

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

6617  {
6618  CHECK(p);
6619  const std::string* str =
6620  static_cast<const StringLiteral*>(p->get_value())->get_stringval();
6621  if (boost::iequals(*str, "true")) {
6622  return true;
6623  } else if (boost::iequals(*str, "false")) {
6624  return false;
6625  } else {
6626  throw std::runtime_error("Value to " + option_name + " must be TRUE or FALSE.");
6627  }
6628 }
#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 4691 of file ParserNode.cpp.

References CHECK.

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

4691  {
4692  for (const auto& opt : options) {
4693  if (boost::iequals(*opt->get_name(), "REPAIR_TYPE")) {
4694  const auto repair_type =
4695  static_cast<const StringLiteral*>(opt->get_value())->get_stringval();
4696  CHECK(repair_type);
4697  if (boost::iequals(*repair_type, "REMOVE")) {
4698  return true;
4699  } else {
4700  throw std::runtime_error("REPAIR_TYPE must be REMOVE.");
4701  }
4702  } else {
4703  throw std::runtime_error("The only VALIDATE WITH options is REPAIR_TYPE.");
4704  }
4705  }
4706  return false;
4707 }
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 5628 of file ParserNode.cpp.

References split().

Referenced by extractObjectNameFromHierName().

5628  {
5629  std::vector<std::string> componentNames;
5630  boost::split(componentNames, hierName, boost::is_any_of("."));
5631  return componentNames;
5632 }
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 5790 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().

5793  {
5794  if (objectType == TableDBObjectType) {
5795  auto td = sessionCatalog.getMetadataForTable(objectName, false);
5796  if (!td || td->isView) {
5797  // expected TABLE, found VIEW
5798  throw std::runtime_error(command + " failed. Object '" + objectName + "' of type " +
5799  DBObjectTypeToString(objectType) + " not found.");
5800  }
5801 
5802  } else if (objectType == ViewDBObjectType) {
5803  auto td = sessionCatalog.getMetadataForTable(objectName, false);
5804  if (!td || !td->isView) {
5805  // expected VIEW, found TABLE
5806  throw std::runtime_error(command + " failed. Object '" + objectName + "' of type " +
5807  DBObjectTypeToString(objectType) + " not found.");
5808  }
5809  }
5810 }
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: