OmniSciDB  72c90bc290
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Parser::anonymous_namespace{ParserNode.cpp} Namespace Reference

Functions

bool bool_from_string_literal (const Parser::StringLiteral *str_literal)
 
void parse_copy_params (const std::list< std::unique_ptr< NameValueAssign >> &options_, import_export::CopyParams &copy_params, std::vector< std::string > &warnings, std::string &deferred_copy_from_partitions_)
 
bool expr_is_null (const Analyzer::Expr *expr)
 
std::string unescape (std::string s)
 
void parse_options (const rapidjson::Value &payload, std::list< std::unique_ptr< NameValueAssign >> &nameValueList, bool stringToNull=false, bool stringToInteger=false)
 
Literalparse_insert_literal (const rapidjson::Value &literal)
 
ArrayLiteralparse_insert_array_literal (const rapidjson::Value &array)
 
void validate_shard_column_type (const ColumnDescriptor &cd)
 
size_t shard_column_index (const std::string &name, const std::list< ColumnDescriptor > &columns)
 
size_t sort_column_index (const std::string &name, const std::list< ColumnDescriptor > &columns)
 
void set_string_field (rapidjson::Value &obj, const std::string &field_name, const std::string &field_value, rapidjson::Document &document)
 
std::string serialize_key_metainfo (const ShardKeyDef *shard_key_def, const std::vector< SharedDictionaryDef > &shared_dict_defs)
 
template<typename LITERAL_TYPE , typename ASSIGNMENT , typename VALIDATE = DefaultValidate<LITERAL_TYPE>>
decltype(auto) get_property_value (const NameValueAssign *p, ASSIGNMENT op, VALIDATE validate=VALIDATE())
 
decltype(auto) get_storage_type (TableDescriptor &td, const NameValueAssign *p, const std::list< ColumnDescriptor > &columns)
 
decltype(auto) get_frag_size_def (TableDescriptor &td, const NameValueAssign *p, const std::list< ColumnDescriptor > &columns)
 
decltype(auto) get_frag_size_dataframe_def (DataframeTableDescriptor &df_td, const NameValueAssign *p, const std::list< ColumnDescriptor > &columns)
 
decltype(auto) get_max_chunk_size_def (TableDescriptor &td, const NameValueAssign *p, const std::list< ColumnDescriptor > &columns)
 
decltype(auto) get_max_chunk_size_dataframe_def (DataframeTableDescriptor &df_td, const NameValueAssign *p, const std::list< ColumnDescriptor > &columns)
 
decltype(auto) get_delimiter_def (DataframeTableDescriptor &df_td, const NameValueAssign *p, const std::list< ColumnDescriptor > &columns)
 
decltype(auto) get_header_def (DataframeTableDescriptor &df_td, const NameValueAssign *p, const std::list< ColumnDescriptor > &columns)
 
decltype(auto) get_page_size_def (TableDescriptor &td, const NameValueAssign *p, const std::list< ColumnDescriptor > &columns)
 
decltype(auto) get_max_rows_def (TableDescriptor &td, const NameValueAssign *p, const std::list< ColumnDescriptor > &columns)
 
decltype(auto) get_skip_rows_def (DataframeTableDescriptor &df_td, const NameValueAssign *p, const std::list< ColumnDescriptor > &columns)
 
decltype(auto) get_partions_def (TableDescriptor &td, const NameValueAssign *p, const std::list< ColumnDescriptor > &columns)
 
decltype(auto) get_shard_count_def (TableDescriptor &td, const NameValueAssign *p, const std::list< ColumnDescriptor > &columns)
 
decltype(auto) get_vacuum_def (TableDescriptor &td, const NameValueAssign *p, const std::list< ColumnDescriptor > &columns)
 
decltype(auto) get_sort_column_def (TableDescriptor &td, const NameValueAssign *p, const std::list< ColumnDescriptor > &columns)
 
decltype(auto) get_max_rollback_epochs_def (TableDescriptor &td, const NameValueAssign *p, const std::list< ColumnDescriptor > &columns)
 
void get_table_definitions (TableDescriptor &td, const std::unique_ptr< NameValueAssign > &p, const std::list< ColumnDescriptor > &columns)
 
void get_table_definitions_for_ctas (TableDescriptor &td, const std::unique_ptr< NameValueAssign > &p, const std::list< ColumnDescriptor > &columns)
 
void get_dataframe_definitions (DataframeTableDescriptor &df_td, const std::unique_ptr< NameValueAssign > &p, const std::list< ColumnDescriptor > &columns)
 
void parse_elements (const rapidjson::Value &payload, std::string element_name, std::string &table_name, std::list< std::unique_ptr< TableElement >> &table_element_list)
 
shared::TableKey get_table_key (const std::vector< std::string > &table)
 
lockmgr::LockedTableDescriptors acquire_query_table_locks (const std::string &insert_table_db_name, const std::string &query_str, const QueryStateProxy &query_state_proxy, const std::optional< std::string > &insert_table_name={})
 
bool user_can_access_table (const Catalog_Namespace::SessionInfo &session_info, const TableDescriptor *td, const AccessPrivileges access_priv)
 
std::string generateUniqueTableName (std::string name)
 
void recordRename (SubstituteMap &sMap, std::string oldName, std::string newName)
 
std::string loadTable (Catalog_Namespace::Catalog &catalog, SubstituteMap &sMap, std::string tableName)
 
bool hasData (SubstituteMap &sMap, std::string tableName)
 
void checkNameSubstition (SubstituteMap &sMap)
 
void disable_foreign_tables (const TableDescriptor *td)
 
std::optional< std::string > get_string_option (const NameValueAssign *option, const std::string &option_name)
 

Variables

static const std::map< const
std::string, const
TableDefFuncPtr
tableDefFuncMap
 
static const std::map< const
std::string, const
DataframeDefFuncPtr
dataframeDefFuncMap
 
static constexpr char const * EMPTY_NAME {""}
 

Function Documentation

lockmgr::LockedTableDescriptors Parser::anonymous_namespace{ParserNode.cpp}::acquire_query_table_locks ( const std::string &  insert_table_db_name,
const std::string &  query_str,
const QueryStateProxy query_state_proxy,
const std::optional< std::string > &  insert_table_name = {} 
)

Definition at line 4597 of file ParserNode.cpp.

Referenced by Parser::InsertIntoTableAsSelectStmt::execute(), Parser::CreateTableAsSelectStmt::execute(), and Parser::ExportQueryStmt::execute().

4601  {}) {
4602  auto& sys_catalog = SysCatalog::instance();
4603  auto& calcite_mgr = sys_catalog.getCalciteMgr();
4604  const auto calciteQueryParsingOption =
4605  calcite_mgr.getCalciteQueryParsingOption(true, false, true, false);
4606  const auto calciteOptimizationOption = calcite_mgr.getCalciteOptimizationOption(
4607  false, g_enable_watchdog, {}, sys_catalog.isAggregator());
4608  const auto result = calcite_mgr.process(query_state_proxy,
4609  pg_shim(query_str),
4610  calciteQueryParsingOption,
4611  calciteOptimizationOption);
4612  // force sort into tableid order in case of name change to guarantee fixed order of
4613  // mutex access
4614  auto comparator = [](const std::vector<std::string>& table_1,
4615  const std::vector<std::string>& table_2) {
4616  return get_table_key(table_1) < get_table_key(table_2);
4617  };
4618  std::set<std::vector<std::string>, decltype(comparator)> tables(comparator);
4619  for (auto& tab : result.resolved_accessed_objects.tables_selected_from) {
4620  tables.emplace(tab);
4621  }
4622  if (insert_table_name.has_value()) {
4623  tables.emplace(
4624  std::vector<std::string>{insert_table_name.value(), insert_table_db_name});
4625  }
4627  for (const auto& table : tables) {
4628  const auto catalog = sys_catalog.getCatalog(table[1]);
4629  CHECK(catalog);
4630  locks.emplace_back(
4633  *catalog, table[0])));
4634  if (insert_table_name.has_value() && table[0] == insert_table_name.value() &&
4635  table[1] == insert_table_db_name) {
4636  locks.emplace_back(
4639  catalog->getDatabaseId(), (*locks.back())())));
4640  } else {
4641  locks.emplace_back(
4644  catalog->getDatabaseId(), (*locks.back())())));
4645  }
4646  }
4647  return locks;
4648 }
std::vector< std::unique_ptr< lockmgr::AbstractLockContainer< const TableDescriptor * >>> LockedTableDescriptors
Definition: LockMgr.h:272
ChunkKey get_table_key(const ChunkKey &key)
Definition: types.h:57
bool g_enable_watchdog
#define CHECK(condition)
Definition: Logger.h:291
std::string pg_shim(const std::string &query)

+ Here is the caller graph for this function:

bool Parser::anonymous_namespace{ParserNode.cpp}::bool_from_string_literal ( const Parser::StringLiteral str_literal)

Definition at line 1079 of file ParserNode.cpp.

References Parser::StringLiteral::get_stringval().

Referenced by parse_copy_params(), and Parser::ExportQueryStmt::parseOptions().

1079  {
1080  const std::string* s = str_literal->get_stringval();
1081  if (*s == "t" || *s == "true" || *s == "T" || *s == "True") {
1082  return true;
1083  } else if (*s == "f" || *s == "false" || *s == "F" || *s == "False") {
1084  return false;
1085  } else {
1086  throw std::runtime_error("Invalid string for boolean " + *s);
1087  }
1088 }
const std::string * get_stringval() const
Definition: ParserNode.h:136

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Parser::anonymous_namespace{ParserNode.cpp}::checkNameSubstition ( SubstituteMap &  sMap)

Definition at line 5214 of file ParserNode.cpp.

References EMPTY_NAME.

Referenced by Parser::RenameTableStmt::execute().

5214  {
5215  // Substition map should be clean at end of rename:
5216  // all items in map must (map to self) or (map to EMPTY_STRING) by end
5217 
5218  for (auto it : sMap) {
5219  if ((it.second) != EMPTY_NAME && (it.first) != (it.second)) {
5220  throw std::runtime_error(
5221  "Error: Attempted to overwrite and lose data in table: \'" + (it.first) + "\'");
5222  }
5223  }
5224 }
static constexpr char const * EMPTY_NAME

+ Here is the caller graph for this function:

void Parser::anonymous_namespace{ParserNode.cpp}::disable_foreign_tables ( const TableDescriptor td)

Definition at line 5228 of file ParserNode.cpp.

References StorageType::FOREIGN_TABLE, TableDescriptor::storageType, and TableDescriptor::tableName.

Referenced by Parser::RenameTableStmt::execute().

5228  {
5230  throw std::runtime_error(td->tableName + " is a foreign table. " +
5231  "Use ALTER FOREIGN TABLE.");
5232  }
5233 }
std::string tableName
std::string storageType
static constexpr char const * FOREIGN_TABLE

+ Here is the caller graph for this function:

bool Parser::anonymous_namespace{ParserNode.cpp}::expr_is_null ( const Analyzer::Expr expr)

Definition at line 1640 of file ParserNode.cpp.

References Analyzer::Constant::get_is_null(), SQLTypeInfo::get_type(), Analyzer::Expr::get_type_info(), and kNULLT.

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

1640  {
1641  if (expr->get_type_info().get_type() == kNULLT) {
1642  return true;
1643  }
1644  auto array_expr = dynamic_cast<const Analyzer::ArrayExpr*>(expr);
1645  if (array_expr && array_expr->isNull()) {
1646  return true;
1647  }
1648  const auto const_expr = dynamic_cast<const Analyzer::Constant*>(expr);
1649  return const_expr && const_expr->get_is_null();
1650 }
bool get_is_null() const
Definition: Analyzer.h:347
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:391
const SQLTypeInfo & get_type_info() const
Definition: Analyzer.h:79

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

std::string Parser::anonymous_namespace{ParserNode.cpp}::generateUniqueTableName ( std::string  name)

Definition at line 5179 of file ParserNode.cpp.

References run_benchmark_import::result, and to_string().

Referenced by Parser::RenameTableStmt::execute().

5179  {
5180  // TODO - is there a "better" way to create a tmp name for the table
5181  std::time_t result = std::time(nullptr);
5182  return name + "_tmp" + std::to_string(result);
5183 }
std::string to_string(char const *&&v)
string name
Definition: setup.in.py:72

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Parser::anonymous_namespace{ParserNode.cpp}::get_dataframe_definitions ( DataframeTableDescriptor df_td,
const std::unique_ptr< NameValueAssign > &  p,
const std::list< ColumnDescriptor > &  columns 
)

Definition at line 3068 of file ParserNode.cpp.

Referenced by Parser::CreateDataframeStmt::execute().

3070  {
3071  const auto it =
3072  dataframeDefFuncMap.find(boost::to_lower_copy<std::string>(*p->get_name()));
3073  if (it == dataframeDefFuncMap.end()) {
3074  throw std::runtime_error(
3075  "Invalid CREATE DATAFRAME option " + *p->get_name() +
3076  ". Should be FRAGMENT_SIZE, MAX_CHUNK_SIZE, SKIP_ROWS, DELIMITER or HEADER.");
3077  }
3078  return it->second(df_td, p.get(), columns);
3079 }
static const std::map< const std::string, const DataframeDefFuncPtr > dataframeDefFuncMap

+ Here is the caller graph for this function:

decltype(auto) Parser::anonymous_namespace{ParserNode.cpp}::get_delimiter_def ( DataframeTableDescriptor df_td,
const NameValueAssign *  p,
const std::list< ColumnDescriptor > &  columns 
)

Definition at line 2908 of file ParserNode.cpp.

2910  {
2911  return get_property_value<StringLiteral>(p, [&df_td](const auto val) {
2912  if (val.size() != 1) {
2913  throw std::runtime_error("Length of DELIMITER must be equal to 1.");
2914  }
2915  df_td.delimiter = val;
2916  });
2917 }
decltype(auto) Parser::anonymous_namespace{ParserNode.cpp}::get_frag_size_dataframe_def ( DataframeTableDescriptor df_td,
const NameValueAssign *  p,
const std::list< ColumnDescriptor > &  columns 
)

Definition at line 2886 of file ParserNode.cpp.

2888  {
2889  return get_property_value<IntLiteral>(
2890  p, [&df_td](const auto val) { df_td.maxFragRows = val; });
2891 }
decltype(auto) Parser::anonymous_namespace{ParserNode.cpp}::get_frag_size_def ( TableDescriptor td,
const NameValueAssign *  p,
const std::list< ColumnDescriptor > &  columns 
)

Definition at line 2878 of file ParserNode.cpp.

References to_string(), and Parser::validate_and_get_fragment_size().

2880  {
2881  return get_property_value<IntLiteral>(p, [&td](const auto val) {
2883  });
2884 }
std::string to_string(char const *&&v)
int32_t validate_and_get_fragment_size(const std::string &fragment_size_str)

+ Here is the call graph for this function:

decltype(auto) Parser::anonymous_namespace{ParserNode.cpp}::get_header_def ( DataframeTableDescriptor df_td,
const NameValueAssign *  p,
const std::list< ColumnDescriptor > &  columns 
)

Definition at line 2919 of file ParserNode.cpp.

2921  {
2922  return get_property_value<StringLiteral>(p, [&df_td](const auto val) {
2923  if (val == "FALSE") {
2924  df_td.hasHeader = false;
2925  } else if (val == "TRUE") {
2926  df_td.hasHeader = true;
2927  } else {
2928  throw std::runtime_error("Option HEADER support only 'true' or 'false' values.");
2929  }
2930  });
2931 }
decltype(auto) Parser::anonymous_namespace{ParserNode.cpp}::get_max_chunk_size_dataframe_def ( DataframeTableDescriptor df_td,
const NameValueAssign *  p,
const std::list< ColumnDescriptor > &  columns 
)

Definition at line 2900 of file ParserNode.cpp.

2903  {
2904  return get_property_value<IntLiteral>(
2905  p, [&df_td](const auto val) { df_td.maxChunkSize = val; });
2906 }
decltype(auto) Parser::anonymous_namespace{ParserNode.cpp}::get_max_chunk_size_def ( TableDescriptor td,
const NameValueAssign *  p,
const std::list< ColumnDescriptor > &  columns 
)

Definition at line 2893 of file ParserNode.cpp.

2895  {
2896  return get_property_value<IntLiteral>(p,
2897  [&td](const auto val) { td.maxChunkSize = val; });
2898 }
decltype(auto) Parser::anonymous_namespace{ParserNode.cpp}::get_max_rollback_epochs_def ( TableDescriptor td,
const NameValueAssign *  p,
const std::list< ColumnDescriptor > &  columns 
)

Definition at line 3007 of file ParserNode.cpp.

3009  {
3010  auto assignment = [&td](const auto val) {
3011  td.maxRollbackEpochs =
3012  val < 0 ? -1 : val; // Anything < 0 means unlimited rollbacks. Note that 0
3013  // still means keeping a shadow copy of data/metdata
3014  // between epochs so bad writes can be rolled back
3015  };
3016  return get_property_value<IntLiteral, decltype(assignment), PositiveOrZeroValidate>(
3017  p, assignment);
3018 }
int32_t maxRollbackEpochs
decltype(auto) Parser::anonymous_namespace{ParserNode.cpp}::get_max_rows_def ( TableDescriptor td,
const NameValueAssign *  p,
const std::list< ColumnDescriptor > &  columns 
)

Definition at line 2939 of file ParserNode.cpp.

2941  {
2942  return get_property_value<IntLiteral>(p, [&td](const auto val) { td.maxRows = val; });
2943 }
decltype(auto) Parser::anonymous_namespace{ParserNode.cpp}::get_page_size_def ( TableDescriptor td,
const NameValueAssign *  p,
const std::list< ColumnDescriptor > &  columns 
)

Definition at line 2933 of file ParserNode.cpp.

2935  {
2936  return get_property_value<IntLiteral>(p,
2937  [&td](const auto val) { td.fragPageSize = val; });
2938 }
decltype(auto) Parser::anonymous_namespace{ParserNode.cpp}::get_partions_def ( TableDescriptor td,
const NameValueAssign *  p,
const std::list< ColumnDescriptor > &  columns 
)

Definition at line 2952 of file ParserNode.cpp.

2954  {
2955  return get_property_value<StringLiteral>(p, [&td](const auto partitions_uc) {
2956  if (partitions_uc != "SHARDED" && partitions_uc != "REPLICATED") {
2957  throw std::runtime_error("PARTITIONS must be SHARDED or REPLICATED");
2958  }
2959  if (td.shardedColumnId != 0 && partitions_uc == "REPLICATED") {
2960  throw std::runtime_error(
2961  "A table cannot be sharded and replicated at the same time");
2962  };
2963  td.partitions = partitions_uc;
2964  });
2965 }
std::string partitions
template<typename LITERAL_TYPE , typename ASSIGNMENT , typename VALIDATE = DefaultValidate<LITERAL_TYPE>>
decltype(auto) Parser::anonymous_namespace{ParserNode.cpp}::get_property_value ( const NameValueAssign *  p,
ASSIGNMENT  op,
VALIDATE  validate = VALIDATE() 
)

Definition at line 2863 of file ParserNode.cpp.

2865  {
2866  const auto val = validate(p);
2867  return op(val);
2868 }
decltype(auto) Parser::anonymous_namespace{ParserNode.cpp}::get_shard_count_def ( TableDescriptor td,
const NameValueAssign *  p,
const std::list< ColumnDescriptor > &  columns 
)

Definition at line 2966 of file ParserNode.cpp.

References g_leaf_count.

2968  {
2969  if (!td.shardedColumnId) {
2970  throw std::runtime_error("SHARD KEY must be defined.");
2971  }
2972  return get_property_value<IntLiteral>(p, [&td](const auto shard_count) {
2973  if (g_leaf_count && shard_count % g_leaf_count) {
2974  throw std::runtime_error(
2975  "SHARD_COUNT must be a multiple of the number of leaves in the cluster.");
2976  }
2977  td.nShards = g_leaf_count ? shard_count / g_leaf_count : shard_count;
2978  if (!td.shardedColumnId && !td.nShards) {
2979  throw std::runtime_error(
2980  "Must specify the number of shards through the SHARD_COUNT option");
2981  };
2982  });
2983 }
size_t g_leaf_count
Definition: ParserNode.cpp:78
decltype(auto) Parser::anonymous_namespace{ParserNode.cpp}::get_skip_rows_def ( DataframeTableDescriptor df_td,
const NameValueAssign *  p,
const std::list< ColumnDescriptor > &  columns 
)

Definition at line 2945 of file ParserNode.cpp.

2947  {
2948  return get_property_value<IntLiteral>(
2949  p, [&df_td](const auto val) { df_td.skipRows = val; });
2950 }
decltype(auto) Parser::anonymous_namespace{ParserNode.cpp}::get_sort_column_def ( TableDescriptor td,
const NameValueAssign *  p,
const std::list< ColumnDescriptor > &  columns 
)

Definition at line 2996 of file ParserNode.cpp.

References sort_column_index().

2998  {
2999  return get_property_value<StringLiteral>(p, [&td, &columns](const auto sort_upper) {
3000  td.sortedColumnId = sort_column_index(sort_upper, columns);
3001  if (!td.sortedColumnId) {
3002  throw std::runtime_error("Specified sort column " + sort_upper + " doesn't exist");
3003  }
3004  });
3005 }
size_t sort_column_index(const std::string &name, const std::list< ColumnDescriptor > &columns)

+ Here is the call graph for this function:

decltype(auto) Parser::anonymous_namespace{ParserNode.cpp}::get_storage_type ( TableDescriptor td,
const NameValueAssign *  p,
const std::list< ColumnDescriptor > &  columns 
)

Definition at line 2870 of file ParserNode.cpp.

2872  {
2873  auto assignment = [&td](const auto val) { td.storageType = val; };
2874  return get_property_value<StringLiteral, decltype(assignment), CaseSensitiveValidate>(
2875  p, assignment);
2876 }
std::string storageType
std::optional<std::string> Parser::anonymous_namespace{ParserNode.cpp}::get_string_option ( const NameValueAssign *  option,
const std::string &  option_name 
)

Definition at line 7065 of file ParserNode.cpp.

References CHECK, Parser::NameValueAssign::get_name(), and Parser::NameValueAssign::get_value().

Referenced by Parser::DumpRestoreTableStmtBase::DumpRestoreTableStmtBase().

7066  {
7067  CHECK(option);
7068  if (boost::iequals(*option->get_name(), option_name)) {
7069  if (const auto str_literal =
7070  dynamic_cast<const StringLiteral*>(option->get_value())) {
7071  return *str_literal->get_stringval();
7072  } else {
7073  throw std::runtime_error("\"" + option_name + "\" option must be a string.");
7074  }
7075  }
7076  return {};
7077 }
#define CHECK(condition)
Definition: Logger.h:291

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Parser::anonymous_namespace{ParserNode.cpp}::get_table_definitions ( TableDescriptor td,
const std::unique_ptr< NameValueAssign > &  p,
const std::list< ColumnDescriptor > &  columns 
)

Definition at line 3032 of file ParserNode.cpp.

Referenced by Parser::CreateTableStmt::executeDryRun().

3034  {
3035  const auto it = tableDefFuncMap.find(boost::to_lower_copy<std::string>(*p->get_name()));
3036  if (it == tableDefFuncMap.end()) {
3037  throw std::runtime_error(
3038  "Invalid CREATE TABLE option " + *p->get_name() +
3039  ". Should be FRAGMENT_SIZE, MAX_CHUNK_SIZE, PAGE_SIZE, MAX_ROLLBACK_EPOCHS, "
3040  "MAX_ROWS, "
3041  "PARTITIONS, SHARD_COUNT, VACUUM, SORT_COLUMN, STORAGE_TYPE.");
3042  }
3043  return it->second(td, p.get(), columns);
3044 }
static const std::map< const std::string, const TableDefFuncPtr > tableDefFuncMap

+ Here is the caller graph for this function:

void Parser::anonymous_namespace{ParserNode.cpp}::get_table_definitions_for_ctas ( TableDescriptor td,
const std::unique_ptr< NameValueAssign > &  p,
const std::list< ColumnDescriptor > &  columns 
)

Definition at line 3046 of file ParserNode.cpp.

Referenced by Parser::CreateTableAsSelectStmt::execute().

3048  {
3049  const auto it = tableDefFuncMap.find(boost::to_lower_copy<std::string>(*p->get_name()));
3050  if (it == tableDefFuncMap.end()) {
3051  throw std::runtime_error(
3052  "Invalid CREATE TABLE AS option " + *p->get_name() +
3053  ". Should be FRAGMENT_SIZE, MAX_CHUNK_SIZE, PAGE_SIZE, MAX_ROLLBACK_EPOCHS, "
3054  "MAX_ROWS, "
3055  "PARTITIONS, SHARD_COUNT, VACUUM, SORT_COLUMN, STORAGE_TYPE, "
3056  "USE_SHARED_DICTIONARIES or FORCE_GEO_COMPRESSION.");
3057  }
3058  return it->second(td, p.get(), columns);
3059 }
static const std::map< const std::string, const TableDefFuncPtr > tableDefFuncMap

+ Here is the caller graph for this function:

shared::TableKey Parser::anonymous_namespace{ParserNode.cpp}::get_table_key ( const std::vector< std::string > &  table)

Definition at line 4586 of file ParserNode.cpp.

References CHECK.

4586  {
4587  const auto catalog = SysCatalog::instance().getCatalog(table[1]);
4588  CHECK(catalog);
4589  const auto table_id = catalog->getTableId(table[0]);
4590  if (!table_id.has_value()) {
4591  throw std::runtime_error{"Table \"" + table[0] +
4592  "\" does not exist in catalog: " + table[1] + "."};
4593  }
4594  return {catalog->getDatabaseId(), table_id.value()};
4595 }
#define CHECK(condition)
Definition: Logger.h:291
decltype(auto) Parser::anonymous_namespace{ParserNode.cpp}::get_vacuum_def ( TableDescriptor td,
const NameValueAssign *  p,
const std::list< ColumnDescriptor > &  columns 
)

Definition at line 2985 of file ParserNode.cpp.

2987  {
2988  return get_property_value<StringLiteral>(p, [&td](const auto vacuum_uc) {
2989  if (vacuum_uc != "IMMEDIATE" && vacuum_uc != "DELAYED") {
2990  throw std::runtime_error("VACUUM must be IMMEDIATE or DELAYED");
2991  }
2992  td.hasDeletedCol = boost::iequals(vacuum_uc, "IMMEDIATE") ? false : true;
2993  });
2994 }
bool Parser::anonymous_namespace{ParserNode.cpp}::hasData ( SubstituteMap &  sMap,
std::string  tableName 
)

Definition at line 5209 of file ParserNode.cpp.

References EMPTY_NAME.

Referenced by Parser::RenameTableStmt::execute().

5209  {
5210  // assumes loadTable has been previously called
5211  return (sMap[tableName] != EMPTY_NAME);
5212 }
static constexpr char const * EMPTY_NAME

+ Here is the caller graph for this function:

std::string Parser::anonymous_namespace{ParserNode.cpp}::loadTable ( Catalog_Namespace::Catalog catalog,
SubstituteMap &  sMap,
std::string  tableName 
)

Definition at line 5189 of file ParserNode.cpp.

References EMPTY_NAME, and Catalog_Namespace::Catalog::getMetadataForTable().

Referenced by Parser::RenameTableStmt::execute().

5191  {
5192  if (sMap.find(tableName) != sMap.end()) {
5193  if (sMap[tableName] == EMPTY_NAME) {
5194  return tableName;
5195  }
5196  return sMap[tableName];
5197  } else {
5198  // lookup table in src catalog
5199  const TableDescriptor* td = catalog.getMetadataForTable(tableName);
5200  if (td) {
5201  sMap[tableName] = tableName;
5202  } else {
5203  sMap[tableName] = EMPTY_NAME;
5204  }
5205  }
5206  return tableName;
5207 }
const TableDescriptor * getMetadataForTable(const std::string &tableName, const bool populateFragmenter=true) const
Returns a pointer to a const TableDescriptor struct matching the provided tableName.
static constexpr char const * EMPTY_NAME

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Parser::anonymous_namespace{ParserNode.cpp}::parse_copy_params ( const std::list< std::unique_ptr< NameValueAssign >> &  options_,
import_export::CopyParams copy_params,
std::vector< std::string > &  warnings,
std::string &  deferred_copy_from_partitions_ 
)

Definition at line 1090 of file ParserNode.cpp.

References import_export::CopyParams::add_metadata_columns, import_export::CopyParams::array_begin, import_export::CopyParams::array_delim, import_export::CopyParams::array_end, bool_from_string_literal(), import_export::CopyParams::buffer_size, CHECK, import_export::CopyParams::connection_string, import_export::CopyParams::credential_string, import_export::CopyParams::delimiter, import_export::CopyParams::dsn, import_export::CopyParams::escape, import_export::CopyParams::file_sort_order_by, import_export::CopyParams::file_sort_regex, g_enable_add_metadata_columns, import_export::CopyParams::geo_coords_comp_param, import_export::CopyParams::geo_coords_encoding, import_export::CopyParams::geo_coords_srid, import_export::CopyParams::geo_coords_type, import_export::CopyParams::geo_explode_collections, import_export::CopyParams::geo_layer_name, import_export::CopyParams::geo_validate_geometry, Geospatial::geos_validation_available(), Parser::IntLiteral::get_intval(), Parser::StringLiteral::get_stringval(), import_export::CopyParams::has_header, import_export::kAuto, import_export::kDelimitedFile, import_export::kDouble, kENCODING_GEOINT, kENCODING_NONE, import_export::kFile, import_export::kFloat, import_export::kGeoFile, kGEOMETRY, import_export::kHasHeader, import_export::kInt, import_export::kNoHeader, import_export::kNone, import_export::kParquetFile, import_export::kPoint, import_export::kRasterFile, import_export::kRegexParsedFile, import_export::kSmallInt, import_export::kWorld, import_export::CopyParams::line_delim, import_export::CopyParams::line_regex, import_export::CopyParams::line_start_regex, import_export::CopyParams::lonlat, import_export::CopyParams::max_import_batch_row_count, import_export::CopyParams::max_reject, import_export::CopyParams::null_str, import_export::CopyParams::password, import_export::CopyParams::plain_text, import_export::CopyParams::quote, import_export::CopyParams::quoted, import_export::CopyParams::raster_import_bands, import_export::CopyParams::raster_import_dimensions, import_export::CopyParams::raster_point_compute_angle, import_export::CopyParams::raster_point_transform, import_export::CopyParams::raster_point_type, import_export::CopyParams::raster_scanlines_per_thread, import_export::CopyParams::regex_path_filter, import_export::CopyParams::s3_access_key, import_export::CopyParams::s3_endpoint, import_export::CopyParams::s3_max_concurrent_downloads, import_export::CopyParams::s3_region, import_export::CopyParams::s3_secret_key, import_export::CopyParams::s3_session_token, import_export::CopyParams::source_srid, import_export::CopyParams::source_type, import_export::CopyParams::sql_order_by, import_export::CopyParams::threads, to_string(), import_export::CopyParams::trim_spaces, and import_export::CopyParams::username.

Referenced by Parser::CopyTableStmt::execute().

1093  {
1094  if (!options_.empty()) {
1095  for (auto& p : options_) {
1096  if (boost::iequals(*p->get_name(), "max_reject")) {
1097  const IntLiteral* int_literal = dynamic_cast<const IntLiteral*>(p->get_value());
1098  if (int_literal == nullptr) {
1099  throw std::runtime_error("max_reject option must be an integer.");
1100  }
1101  copy_params.max_reject = int_literal->get_intval();
1102  } else if (boost::iequals(*p->get_name(), "max_import_batch_row_count")) {
1103  const IntLiteral* int_literal = dynamic_cast<const IntLiteral*>(p->get_value());
1104  if (int_literal == nullptr) {
1105  throw std::runtime_error(
1106  "max_import_batch_row_count option must be an integer.");
1107  }
1108  if (int_literal->get_intval() <= 0) {
1109  throw std::runtime_error(
1110  "max_import_batch_row_count option must be a positive integer (greater "
1111  "than 0).");
1112  }
1113  copy_params.max_import_batch_row_count = int_literal->get_intval();
1114  } else if (boost::iequals(*p->get_name(), "buffer_size")) {
1115  const IntLiteral* int_literal = dynamic_cast<const IntLiteral*>(p->get_value());
1116  if (int_literal == nullptr) {
1117  throw std::runtime_error("buffer_size option must be an integer.");
1118  }
1119  copy_params.buffer_size = int_literal->get_intval();
1120  } else if (boost::iequals(*p->get_name(), "threads")) {
1121  const IntLiteral* int_literal = dynamic_cast<const IntLiteral*>(p->get_value());
1122  if (int_literal == nullptr) {
1123  throw std::runtime_error("Threads option must be an integer.");
1124  }
1125  copy_params.threads = int_literal->get_intval();
1126  } else if (boost::iequals(*p->get_name(), "delimiter")) {
1127  const StringLiteral* str_literal =
1128  dynamic_cast<const StringLiteral*>(p->get_value());
1129  if (str_literal == nullptr) {
1130  throw std::runtime_error("Delimiter option must be a string.");
1131  } else if (str_literal->get_stringval()->length() != 1) {
1132  throw std::runtime_error("Delimiter must be a single character string.");
1133  }
1134  copy_params.delimiter = (*str_literal->get_stringval())[0];
1135  } else if (boost::iequals(*p->get_name(), "nulls")) {
1136  const StringLiteral* str_literal =
1137  dynamic_cast<const StringLiteral*>(p->get_value());
1138  if (str_literal == nullptr) {
1139  throw std::runtime_error("Nulls option must be a string.");
1140  }
1141  copy_params.null_str = *str_literal->get_stringval();
1142  } else if (boost::iequals(*p->get_name(), "header")) {
1143  const StringLiteral* str_literal =
1144  dynamic_cast<const StringLiteral*>(p->get_value());
1145  if (str_literal == nullptr) {
1146  throw std::runtime_error("Header option must be a boolean.");
1147  }
1148  copy_params.has_header = bool_from_string_literal(str_literal)
1151 #ifdef ENABLE_IMPORT_PARQUET
1152  } else if (boost::iequals(*p->get_name(), "parquet")) {
1153  warnings.emplace_back(
1154  "Deprecation Warning: COPY FROM WITH (parquet='true') is deprecated. Use "
1155  "WITH (source_type='parquet_file') instead.");
1156  const StringLiteral* str_literal =
1157  dynamic_cast<const StringLiteral*>(p->get_value());
1158  if (str_literal == nullptr) {
1159  throw std::runtime_error("'parquet' option must be a boolean.");
1160  }
1161  if (bool_from_string_literal(str_literal)) {
1162  // not sure a parquet "table" type is proper, but to make code
1163  // look consistent in some places, let's set "table" type too
1165  }
1166 #endif // ENABLE_IMPORT_PARQUET
1167  } else if (boost::iequals(*p->get_name(), "s3_access_key")) {
1168  const StringLiteral* str_literal =
1169  dynamic_cast<const StringLiteral*>(p->get_value());
1170  if (str_literal == nullptr) {
1171  throw std::runtime_error("Option s3_access_key must be a string.");
1172  }
1173  copy_params.s3_access_key = *str_literal->get_stringval();
1174  } else if (boost::iequals(*p->get_name(), "s3_secret_key")) {
1175  const StringLiteral* str_literal =
1176  dynamic_cast<const StringLiteral*>(p->get_value());
1177  if (str_literal == nullptr) {
1178  throw std::runtime_error("Option s3_secret_key must be a string.");
1179  }
1180  copy_params.s3_secret_key = *str_literal->get_stringval();
1181  } else if (boost::iequals(*p->get_name(), "s3_session_token")) {
1182  const StringLiteral* str_literal =
1183  dynamic_cast<const StringLiteral*>(p->get_value());
1184  if (str_literal == nullptr) {
1185  throw std::runtime_error("Option s3_session_token must be a string.");
1186  }
1187  copy_params.s3_session_token = *str_literal->get_stringval();
1188  } else if (boost::iequals(*p->get_name(), "s3_region")) {
1189  const StringLiteral* str_literal =
1190  dynamic_cast<const StringLiteral*>(p->get_value());
1191  if (str_literal == nullptr) {
1192  throw std::runtime_error("Option s3_region must be a string.");
1193  }
1194  copy_params.s3_region = *str_literal->get_stringval();
1195  } else if (boost::iequals(*p->get_name(), "s3_endpoint")) {
1196  const StringLiteral* str_literal =
1197  dynamic_cast<const StringLiteral*>(p->get_value());
1198  if (str_literal == nullptr) {
1199  throw std::runtime_error("Option s3_endpoint must be a string.");
1200  }
1201  copy_params.s3_endpoint = *str_literal->get_stringval();
1202  } else if (boost::iequals(*p->get_name(), "s3_max_concurrent_downloads")) {
1203  const IntLiteral* int_literal = dynamic_cast<const IntLiteral*>(p->get_value());
1204  if (int_literal == nullptr) {
1205  throw std::runtime_error(
1206  "'s3_max_concurrent_downloads' option must be an integer");
1207  }
1208  const int s3_max_concurrent_downloads = int_literal->get_intval();
1209  if (s3_max_concurrent_downloads > 0) {
1210  copy_params.s3_max_concurrent_downloads = s3_max_concurrent_downloads;
1211  } else {
1212  throw std::runtime_error(
1213  "Invalid value for 's3_max_concurrent_downloads' option (must be > 0): " +
1214  std::to_string(s3_max_concurrent_downloads));
1215  }
1216  } else if (boost::iequals(*p->get_name(), "quote")) {
1217  const StringLiteral* str_literal =
1218  dynamic_cast<const StringLiteral*>(p->get_value());
1219  if (str_literal == nullptr) {
1220  throw std::runtime_error("Quote option must be a string.");
1221  } else if (str_literal->get_stringval()->length() != 1) {
1222  throw std::runtime_error("Quote must be a single character string.");
1223  }
1224  copy_params.quote = (*str_literal->get_stringval())[0];
1225  } else if (boost::iequals(*p->get_name(), "escape")) {
1226  const StringLiteral* str_literal =
1227  dynamic_cast<const StringLiteral*>(p->get_value());
1228  if (str_literal == nullptr) {
1229  throw std::runtime_error("Escape option must be a string.");
1230  } else if (str_literal->get_stringval()->length() != 1) {
1231  throw std::runtime_error("Escape must be a single character string.");
1232  }
1233  copy_params.escape = (*str_literal->get_stringval())[0];
1234  } else if (boost::iequals(*p->get_name(), "line_delimiter")) {
1235  const StringLiteral* str_literal =
1236  dynamic_cast<const StringLiteral*>(p->get_value());
1237  if (str_literal == nullptr) {
1238  throw std::runtime_error("Line_delimiter option must be a string.");
1239  } else if (str_literal->get_stringval()->length() != 1) {
1240  throw std::runtime_error("Line_delimiter must be a single character string.");
1241  }
1242  copy_params.line_delim = (*str_literal->get_stringval())[0];
1243  } else if (boost::iequals(*p->get_name(), "quoted")) {
1244  const StringLiteral* str_literal =
1245  dynamic_cast<const StringLiteral*>(p->get_value());
1246  if (str_literal == nullptr) {
1247  throw std::runtime_error("Quoted option must be a boolean.");
1248  }
1249  copy_params.quoted = bool_from_string_literal(str_literal);
1250  } else if (boost::iequals(*p->get_name(), "plain_text")) {
1251  const StringLiteral* str_literal =
1252  dynamic_cast<const StringLiteral*>(p->get_value());
1253  if (str_literal == nullptr) {
1254  throw std::runtime_error("plain_text option must be a boolean.");
1255  }
1256  copy_params.plain_text = bool_from_string_literal(str_literal);
1257  } else if (boost::iequals(*p->get_name(), "trim_spaces")) {
1258  const StringLiteral* str_literal =
1259  dynamic_cast<const StringLiteral*>(p->get_value());
1260  if (str_literal == nullptr) {
1261  throw std::runtime_error("trim_spaces option must be a boolean.");
1262  }
1263  copy_params.trim_spaces = bool_from_string_literal(str_literal);
1264  } else if (boost::iequals(*p->get_name(), "array_marker")) {
1265  const StringLiteral* str_literal =
1266  dynamic_cast<const StringLiteral*>(p->get_value());
1267  if (str_literal == nullptr) {
1268  throw std::runtime_error("Array Marker option must be a string.");
1269  } else if (str_literal->get_stringval()->length() != 2) {
1270  throw std::runtime_error(
1271  "Array Marker option must be exactly two characters. Default is {}.");
1272  }
1273  copy_params.array_begin = (*str_literal->get_stringval())[0];
1274  copy_params.array_end = (*str_literal->get_stringval())[1];
1275  } else if (boost::iequals(*p->get_name(), "array_delimiter")) {
1276  const StringLiteral* str_literal =
1277  dynamic_cast<const StringLiteral*>(p->get_value());
1278  if (str_literal == nullptr) {
1279  throw std::runtime_error("Array Delimiter option must be a string.");
1280  } else if (str_literal->get_stringval()->length() != 1) {
1281  throw std::runtime_error("Array Delimiter must be a single character string.");
1282  }
1283  copy_params.array_delim = (*str_literal->get_stringval())[0];
1284  } else if (boost::iequals(*p->get_name(), "lonlat")) {
1285  const StringLiteral* str_literal =
1286  dynamic_cast<const StringLiteral*>(p->get_value());
1287  if (str_literal == nullptr) {
1288  throw std::runtime_error("Lonlat option must be a boolean.");
1289  }
1290  copy_params.lonlat = bool_from_string_literal(str_literal);
1291  } else if (boost::iequals(*p->get_name(), "geo")) {
1292  warnings.emplace_back(
1293  "Deprecation Warning: COPY FROM WITH (geo='true') is deprecated. Use WITH "
1294  "(source_type='geo_file') instead.");
1295  const StringLiteral* str_literal =
1296  dynamic_cast<const StringLiteral*>(p->get_value());
1297  if (str_literal == nullptr) {
1298  throw std::runtime_error("'geo' option must be a boolean.");
1299  }
1300  if (bool_from_string_literal(str_literal)) {
1302  }
1303  } else if (boost::iequals(*p->get_name(), "source_type")) {
1304  const StringLiteral* str_literal =
1305  dynamic_cast<const StringLiteral*>(p->get_value());
1306  if (str_literal == nullptr) {
1307  throw std::runtime_error("'source_type' option must be a string.");
1308  }
1309  const std::string* s = str_literal->get_stringval();
1310  if (boost::iequals(*s, "delimited_file")) {
1312  } else if (boost::iequals(*s, "geo_file")) {
1314 #if ENABLE_IMPORT_PARQUET
1315  } else if (boost::iequals(*s, "parquet_file")) {
1317 #endif
1318  } else if (boost::iequals(*s, "raster_file")) {
1320  } else if (boost::iequals(*s, "regex_parsed_file")) {
1322  } else {
1323  throw std::runtime_error(
1324  "Invalid string for 'source_type' option (must be 'GEO_FILE', 'RASTER_FILE'"
1325 #if ENABLE_IMPORT_PARQUET
1326  ", 'PARQUET_FILE'"
1327 #endif
1328  ", 'REGEX_PARSED_FILE'"
1329  " or 'DELIMITED_FILE'): " +
1330  *s);
1331  }
1332  } else if (boost::iequals(*p->get_name(), "geo_coords_type")) {
1333  const StringLiteral* str_literal =
1334  dynamic_cast<const StringLiteral*>(p->get_value());
1335  if (str_literal == nullptr) {
1336  throw std::runtime_error("'geo_coords_type' option must be a string");
1337  }
1338  const std::string* s = str_literal->get_stringval();
1339  if (boost::iequals(*s, "geography")) {
1340  throw std::runtime_error(
1341  "GEOGRAPHY coords type not yet supported. Please use GEOMETRY.");
1342  // copy_params.geo_coords_type = kGEOGRAPHY;
1343  } else if (boost::iequals(*s, "geometry")) {
1344  copy_params.geo_coords_type = kGEOMETRY;
1345  } else {
1346  throw std::runtime_error(
1347  "Invalid string for 'geo_coords_type' option (must be 'GEOGRAPHY' or "
1348  "'GEOMETRY'): " +
1349  *s);
1350  }
1351  } else if (boost::iequals(*p->get_name(), "raster_point_type")) {
1352  const StringLiteral* str_literal =
1353  dynamic_cast<const StringLiteral*>(p->get_value());
1354  if (str_literal == nullptr) {
1355  throw std::runtime_error("'raster_point_type' option must be a string");
1356  }
1357  const std::string* s = str_literal->get_stringval();
1358  if (boost::iequals(*s, "none")) {
1360  } else if (boost::iequals(*s, "auto")) {
1362  } else if (boost::iequals(*s, "smallint")) {
1364  } else if (boost::iequals(*s, "int")) {
1366  } else if (boost::iequals(*s, "float")) {
1368  } else if (boost::iequals(*s, "double")) {
1370  } else if (boost::iequals(*s, "point")) {
1372  } else {
1373  throw std::runtime_error(
1374  "Invalid string for 'raster_point_type' option (must be 'NONE', 'AUTO', "
1375  "'SMALLINT', 'INT', 'FLOAT', 'DOUBLE' or 'POINT'): " +
1376  *s);
1377  }
1378  } else if (boost::iequals(*p->get_name(), "raster_point_transform")) {
1379  const StringLiteral* str_literal =
1380  dynamic_cast<const StringLiteral*>(p->get_value());
1381  if (str_literal == nullptr) {
1382  throw std::runtime_error("'raster_point_transform' option must be a string");
1383  }
1384  const std::string* s = str_literal->get_stringval();
1385  if (boost::iequals(*s, "none")) {
1387  } else if (boost::iequals(*s, "auto")) {
1389  } else if (boost::iequals(*s, "file")) {
1391  } else if (boost::iequals(*s, "world")) {
1392  copy_params.raster_point_transform =
1394  } else {
1395  throw std::runtime_error(
1396  "Invalid string for 'raster_point_transform' option (must be 'NONE', "
1397  "'AUTO', 'FILE' or 'WORLD'): " +
1398  *s);
1399  }
1400  } else if (boost::iequals(*p->get_name(), "raster_import_bands")) {
1401  const StringLiteral* str_literal =
1402  dynamic_cast<const StringLiteral*>(p->get_value());
1403  if (str_literal == nullptr) {
1404  throw std::runtime_error("'raster_import_bands' option must be a string");
1405  }
1406  const std::string* raster_import_bands = str_literal->get_stringval();
1407  if (raster_import_bands) {
1408  copy_params.raster_import_bands = *raster_import_bands;
1409  } else {
1410  throw std::runtime_error("Invalid value for 'raster_import_bands' option");
1411  }
1412  } else if (boost::iequals(*p->get_name(), "raster_import_dimensions")) {
1413  const StringLiteral* str_literal =
1414  dynamic_cast<const StringLiteral*>(p->get_value());
1415  if (str_literal == nullptr) {
1416  throw std::runtime_error("'raster_import_dimensions' option must be a string");
1417  }
1418  const std::string* raster_import_dimensions = str_literal->get_stringval();
1419  if (raster_import_dimensions) {
1420  copy_params.raster_import_dimensions = *raster_import_dimensions;
1421  } else {
1422  throw std::runtime_error("Invalid value for 'raster_import_dimensions' option");
1423  }
1424  } else if (boost::iequals(*p->get_name(), "geo_coords_encoding")) {
1425  const StringLiteral* str_literal =
1426  dynamic_cast<const StringLiteral*>(p->get_value());
1427  if (str_literal == nullptr) {
1428  throw std::runtime_error("'geo_coords_encoding' option must be a string");
1429  }
1430  const std::string* s = str_literal->get_stringval();
1431  if (boost::iequals(*s, "none")) {
1432  copy_params.geo_coords_encoding = kENCODING_NONE;
1433  copy_params.geo_coords_comp_param = 0;
1434  } else if (boost::iequals(*s, "compressed(32)")) {
1435  copy_params.geo_coords_encoding = kENCODING_GEOINT;
1436  copy_params.geo_coords_comp_param = 32;
1437  } else {
1438  throw std::runtime_error(
1439  "Invalid string for 'geo_coords_encoding' option (must be 'NONE' or "
1440  "'COMPRESSED(32)'): " +
1441  *s);
1442  }
1443  } else if (boost::iequals(*p->get_name(), "raster_scanlines_per_thread")) {
1444  const IntLiteral* int_literal = dynamic_cast<const IntLiteral*>(p->get_value());
1445  if (int_literal == nullptr) {
1446  throw std::runtime_error(
1447  "'raster_scanlines_per_thread' option must be an integer");
1448  }
1449  const int raster_scanlines_per_thread = int_literal->get_intval();
1450  if (raster_scanlines_per_thread < 0) {
1451  throw std::runtime_error(
1452  "'raster_scanlines_per_thread' option must be >= 0, with 0 denoting auto "
1453  "sizing");
1454  }
1455  copy_params.raster_scanlines_per_thread = raster_scanlines_per_thread;
1456  } else if (boost::iequals(*p->get_name(), "geo_coords_srid")) {
1457  const IntLiteral* int_literal = dynamic_cast<const IntLiteral*>(p->get_value());
1458  if (int_literal == nullptr) {
1459  throw std::runtime_error("'geo_coords_srid' option must be an integer");
1460  }
1461  const int srid = int_literal->get_intval();
1462  if (srid == 4326 || srid == 3857 || srid == 900913) {
1463  copy_params.geo_coords_srid = srid;
1464  } else {
1465  throw std::runtime_error(
1466  "Invalid value for 'geo_coords_srid' option (must be 4326, 3857, or "
1467  "900913): " +
1468  std::to_string(srid));
1469  }
1470  } else if (boost::iequals(*p->get_name(), "geo_layer_name")) {
1471  const StringLiteral* str_literal =
1472  dynamic_cast<const StringLiteral*>(p->get_value());
1473  if (str_literal == nullptr) {
1474  throw std::runtime_error("'geo_layer_name' option must be a string");
1475  }
1476  const std::string* layer_name = str_literal->get_stringval();
1477  if (layer_name) {
1478  copy_params.geo_layer_name = *layer_name;
1479  } else {
1480  throw std::runtime_error("Invalid value for 'geo_layer_name' option");
1481  }
1482  } else if (boost::iequals(*p->get_name(), "partitions")) {
1483  const auto partitions =
1484  static_cast<const StringLiteral*>(p->get_value())->get_stringval();
1485  CHECK(partitions);
1486  const auto partitions_uc = boost::to_upper_copy<std::string>(*partitions);
1487  if (partitions_uc != "REPLICATED") {
1488  throw std::runtime_error(
1489  "Invalid value for 'partitions' option. Must be 'REPLICATED'.");
1490  }
1491  deferred_copy_from_partitions_ = partitions_uc;
1492  } else if (boost::iequals(*p->get_name(), "geo_explode_collections")) {
1493  const StringLiteral* str_literal =
1494  dynamic_cast<const StringLiteral*>(p->get_value());
1495  if (str_literal == nullptr) {
1496  throw std::runtime_error("geo_explode_collections option must be a boolean.");
1497  }
1498  copy_params.geo_explode_collections = bool_from_string_literal(str_literal);
1499  } else if (boost::iequals(*p->get_name(), "geo_validate_geometry")) {
1500  const StringLiteral* str_literal =
1501  dynamic_cast<const StringLiteral*>(p->get_value());
1502  if (str_literal == nullptr) {
1503  throw std::runtime_error("geo_validate_geometry option must be a boolean.");
1504  }
1505  copy_params.geo_validate_geometry = false;
1506  auto const value = bool_from_string_literal(str_literal);
1507  if (value) {
1509  copy_params.geo_validate_geometry = true;
1510  } else {
1511  throw std::runtime_error("GEOS geometry validation is not available.");
1512  }
1513  }
1514  } else if (boost::iequals(*p->get_name(), "source_srid")) {
1515  const IntLiteral* int_literal = dynamic_cast<const IntLiteral*>(p->get_value());
1516  if (int_literal == nullptr) {
1517  throw std::runtime_error("'source_srid' option must be an integer");
1518  }
1519  const int srid = int_literal->get_intval();
1521  copy_params.source_srid = srid;
1522  } else {
1523  throw std::runtime_error(
1524  "'source_srid' option can only be used on csv/tsv files");
1525  }
1526  } else if (boost::iequals(*p->get_name(), "regex_path_filter")) {
1527  const StringLiteral* str_literal =
1528  dynamic_cast<const StringLiteral*>(p->get_value());
1529  if (str_literal == nullptr) {
1530  throw std::runtime_error("Option regex_path_filter must be a string.");
1531  }
1532  const auto string_val = *str_literal->get_stringval();
1533  copy_params.regex_path_filter =
1534  string_val.empty() ? std::nullopt : std::optional<std::string>{string_val};
1535  } else if (boost::iequals(*p->get_name(), "file_sort_order_by")) {
1536  const StringLiteral* str_literal =
1537  dynamic_cast<const StringLiteral*>(p->get_value());
1538  if (str_literal == nullptr) {
1539  throw std::runtime_error("Option file_sort_order_by must be a string.");
1540  }
1541  const auto string_val = *str_literal->get_stringval();
1542  copy_params.file_sort_order_by =
1543  string_val.empty() ? std::nullopt : std::optional<std::string>{string_val};
1544  } else if (boost::iequals(*p->get_name(), "file_sort_regex")) {
1545  const StringLiteral* str_literal =
1546  dynamic_cast<const StringLiteral*>(p->get_value());
1547  if (str_literal == nullptr) {
1548  throw std::runtime_error("Option file_sort_regex must be a string.");
1549  }
1550  const auto string_val = *str_literal->get_stringval();
1551  copy_params.file_sort_regex =
1552  string_val.empty() ? std::nullopt : std::optional<std::string>{string_val};
1553  } else if (boost::iequals(*p->get_name(), "raster_point_compute_angle")) {
1554  const StringLiteral* str_literal =
1555  dynamic_cast<const StringLiteral*>(p->get_value());
1556  if (str_literal == nullptr) {
1557  throw std::runtime_error(
1558  "'raster_point_compute_angle' option must be a boolean.");
1559  }
1560  if (bool_from_string_literal(str_literal)) {
1561  copy_params.raster_point_compute_angle = true;
1562  }
1563  } else if (boost::iequals(*p->get_name(), "sql_order_by")) {
1564  if (auto str_literal = dynamic_cast<const StringLiteral*>(p->get_value())) {
1565  copy_params.sql_order_by = *str_literal->get_stringval();
1566  } else {
1567  throw std::runtime_error("Option sql_order_by must be a string.");
1568  }
1569  } else if (boost::iequals(*p->get_name(), "username")) {
1570  const StringLiteral* str_literal =
1571  dynamic_cast<const StringLiteral*>(p->get_value());
1572  if (str_literal == nullptr) {
1573  throw std::runtime_error("Option username must be a string.");
1574  }
1575  const auto string_val = *str_literal->get_stringval();
1576  copy_params.username = string_val;
1577  } else if (boost::iequals(*p->get_name(), "password")) {
1578  const StringLiteral* str_literal =
1579  dynamic_cast<const StringLiteral*>(p->get_value());
1580  if (str_literal == nullptr) {
1581  throw std::runtime_error("Option password must be a string.");
1582  }
1583  const auto string_val = *str_literal->get_stringval();
1584  copy_params.password = string_val;
1585  } else if (boost::iequals(*p->get_name(), "credential_string")) {
1586  const StringLiteral* str_literal =
1587  dynamic_cast<const StringLiteral*>(p->get_value());
1588  if (str_literal == nullptr) {
1589  throw std::runtime_error("Option credential_string must be a string.");
1590  }
1591  const auto string_val = *str_literal->get_stringval();
1592  copy_params.credential_string = string_val;
1593  } else if (boost::iequals(*p->get_name(), "data_source_name")) {
1594  const StringLiteral* str_literal =
1595  dynamic_cast<const StringLiteral*>(p->get_value());
1596  if (str_literal == nullptr) {
1597  throw std::runtime_error("Option data_source_name must be a string.");
1598  }
1599  const auto string_val = *str_literal->get_stringval();
1600  copy_params.dsn = string_val;
1601  } else if (boost::iequals(*p->get_name(), "connection_string")) {
1602  const StringLiteral* str_literal =
1603  dynamic_cast<const StringLiteral*>(p->get_value());
1604  if (str_literal == nullptr) {
1605  throw std::runtime_error("Option connection_string must be a string.");
1606  }
1607  const auto string_val = *str_literal->get_stringval();
1608  copy_params.connection_string = string_val;
1609  } else if (boost::iequals(*p->get_name(), "line_start_regex")) {
1610  const StringLiteral* str_literal =
1611  dynamic_cast<const StringLiteral*>(p->get_value());
1612  if (str_literal == nullptr) {
1613  throw std::runtime_error("Option line_start_regex must be a string.");
1614  }
1615  const auto string_val = *str_literal->get_stringval();
1616  copy_params.line_start_regex = string_val;
1617  } else if (boost::iequals(*p->get_name(), "line_regex")) {
1618  const StringLiteral* str_literal =
1619  dynamic_cast<const StringLiteral*>(p->get_value());
1620  if (str_literal == nullptr) {
1621  throw std::runtime_error("Option line_regex must be a string.");
1622  }
1623  const auto string_val = *str_literal->get_stringval();
1624  copy_params.line_regex = string_val;
1625  } else if (boost::iequals(*p->get_name(), "add_metadata_columns") &&
1627  const StringLiteral* str_literal =
1628  dynamic_cast<const StringLiteral*>(p->get_value());
1629  if (str_literal == nullptr) {
1630  throw std::runtime_error("'add_metadata_columns' option must be a string.");
1631  }
1632  copy_params.add_metadata_columns = *str_literal->get_stringval();
1633  } else {
1634  throw std::runtime_error("Invalid option for COPY: " + *p->get_name());
1635  }
1636  }
1637  }
1638 }
std::string s3_secret_key
Definition: CopyParams.h:62
int32_t raster_scanlines_per_thread
Definition: CopyParams.h:90
std::string connection_string
Definition: CopyParams.h:104
std::string raster_import_dimensions
Definition: CopyParams.h:93
bool bool_from_string_literal(const Parser::StringLiteral *str_literal)
std::string to_string(char const *&&v)
std::string add_metadata_columns
Definition: CopyParams.h:94
ImportHeaderRow has_header
Definition: CopyParams.h:46
bool geos_validation_available()
std::optional< std::string > regex_path_filter
Definition: CopyParams.h:85
RasterPointType raster_point_type
Definition: CopyParams.h:88
int32_t s3_max_concurrent_downloads
Definition: CopyParams.h:66
std::string sql_order_by
Definition: CopyParams.h:97
import_export::SourceType source_type
Definition: CopyParams.h:57
std::string geo_layer_name
Definition: CopyParams.h:81
std::string line_start_regex
Definition: CopyParams.h:106
std::string s3_session_token
Definition: CopyParams.h:63
std::string raster_import_bands
Definition: CopyParams.h:89
#define CHECK(condition)
Definition: Logger.h:291
std::string s3_access_key
Definition: CopyParams.h:61
RasterPointTransform raster_point_transform
Definition: CopyParams.h:91
bool g_enable_add_metadata_columns
Definition: ParserNode.cpp:89
std::optional< std::string > file_sort_order_by
Definition: CopyParams.h:86
std::string credential_string
Definition: CopyParams.h:101
std::optional< std::string > file_sort_regex
Definition: CopyParams.h:87
EncodingType geo_coords_encoding
Definition: CopyParams.h:76

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Parser::anonymous_namespace{ParserNode.cpp}::parse_elements ( const rapidjson::Value &  payload,
std::string  element_name,
std::string &  table_name,
std::list< std::unique_ptr< TableElement >> &  table_element_list 
)

Definition at line 3081 of file ParserNode.cpp.

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

Referenced by Parser::CreateDataframeStmt::CreateDataframeStmt(), and Parser::CreateTableStmt::CreateTableStmt().

3084  {
3085  const auto elements = payload[element_name].GetArray();
3086  for (const auto& element : elements) {
3087  CHECK(element.IsObject());
3088  CHECK(element.HasMember("type"));
3089  if (json_str(element["type"]) == "SQL_COLUMN_DECLARATION") {
3090  auto col_def = column_from_json(element);
3091  table_element_list.emplace_back(std::move(col_def));
3092  } else if (json_str(element["type"]) == "SQL_COLUMN_CONSTRAINT") {
3093  CHECK(element.HasMember("name"));
3094  if (json_str(element["name"]) == "SHARD_KEY") {
3095  CHECK(element.HasMember("columns"));
3096  CHECK(element["columns"].IsArray());
3097  const auto& columns = element["columns"].GetArray();
3098  if (columns.Size() != size_t(1)) {
3099  throw std::runtime_error("Only one shard column is currently supported.");
3100  }
3101  auto shard_key_def = std::make_unique<ShardKeyDef>(json_str(columns[0]));
3102  table_element_list.emplace_back(std::move(shard_key_def));
3103  } else if (json_str(element["name"]) == "SHARED_DICT") {
3104  CHECK(element.HasMember("columns"));
3105  CHECK(element["columns"].IsArray());
3106  const auto& columns = element["columns"].GetArray();
3107  if (columns.Size() != size_t(1)) {
3108  throw std::runtime_error(
3109  R"(Only one column per shared dictionary entry is currently supported. Use multiple SHARED DICT statements to share dictionaries from multiple columns.)");
3110  }
3111  CHECK(element.HasMember("references") && element["references"].IsObject());
3112  const auto& references = element["references"].GetObject();
3113  std::string references_table_name;
3114  if (references.HasMember("table")) {
3115  references_table_name = json_str(references["table"]);
3116  } else {
3117  references_table_name = table_name;
3118  }
3119  CHECK(references.HasMember("column"));
3120 
3121  auto shared_dict_def = std::make_unique<SharedDictionaryDef>(
3122  json_str(columns[0]), references_table_name, json_str(references["column"]));
3123  table_element_list.emplace_back(std::move(shared_dict_def));
3124 
3125  } else {
3126  LOG(FATAL) << "Unsupported type for SQL_COLUMN_CONSTRAINT: "
3127  << json_str(element["name"]);
3128  }
3129  } else {
3130  LOG(FATAL) << "Unsupported element type for CREATE TABLE: "
3131  << element["type"].GetString();
3132  }
3133  }
3134 }
#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:

ArrayLiteral* Parser::anonymous_namespace{ParserNode.cpp}::parse_insert_array_literal ( const rapidjson::Value &  array)

Definition at line 2434 of file ParserNode.cpp.

References CHECK, and parse_insert_literal().

Referenced by Parser::InsertValuesStmt::InsertValuesStmt().

2434  {
2435  CHECK(array.IsArray());
2436  auto json_elements = array.GetArray();
2437  auto* elements = new std::list<Expr*>();
2438  for (const auto& e : json_elements) {
2439  elements->push_back(parse_insert_literal(e));
2440  }
2441  return new ArrayLiteral(elements);
2442 }
Literal * parse_insert_literal(const rapidjson::Value &literal)
#define CHECK(condition)
Definition: Logger.h:291

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Literal* Parser::anonymous_namespace{ParserNode.cpp}::parse_insert_literal ( const rapidjson::Value &  literal)

Definition at line 2400 of file ParserNode.cpp.

References CHECK, json_i64(), json_str(), sql_constants::kMaxNumericPrecision, and run_benchmark_import::type.

Referenced by Parser::InsertValuesStmt::InsertValuesStmt(), and parse_insert_array_literal().

2400  {
2401  CHECK(literal.IsObject());
2402  CHECK(literal.HasMember("literal"));
2403  CHECK(literal.HasMember("type"));
2404  auto type = json_str(literal["type"]);
2405  if (type == "NULL") {
2406  return new NullLiteral();
2407  } else if (type == "CHAR" || type == "BOOLEAN") {
2408  auto* val = new std::string(json_str(literal["literal"]));
2409  return new StringLiteral(val);
2410  } else if (type == "DECIMAL") {
2411  CHECK(literal.HasMember("scale"));
2412  CHECK(literal.HasMember("precision"));
2413  auto scale = json_i64(literal["scale"]);
2414  auto precision = json_i64(literal["precision"]);
2415  if (scale == 0) {
2416  auto int_val = std::stol(json_str(literal["literal"]));
2417  return new IntLiteral(int_val);
2418  } else if (precision > sql_constants::kMaxNumericPrecision) {
2419  auto dbl_val = std::stod(json_str(literal["literal"]));
2420  return new DoubleLiteral(dbl_val);
2421  } else {
2422  auto* val = new std::string(json_str(literal["literal"]));
2423  return new FixedPtLiteral(val);
2424  }
2425  } else if (type == "DOUBLE") {
2426  auto dbl_val = std::stod(json_str(literal["literal"]));
2427  return new DoubleLiteral(dbl_val);
2428  } else {
2429  CHECK(false) << "Unexpected calcite data type: " << type;
2430  }
2431  return nullptr;
2432 }
static constexpr int32_t kMaxNumericPrecision
Definition: sqltypes.h:58
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:

void Parser::anonymous_namespace{ParserNode.cpp}::parse_options ( const rapidjson::Value &  payload,
std::list< std::unique_ptr< NameValueAssign >> &  nameValueList,
bool  stringToNull = false,
bool  stringToInteger = false 
)

Definition at line 2019 of file ParserNode.cpp.

References CHECK, json_double(), json_i64(), and unescape().

Referenced by Parser::AlterUserStmt::AlterUserStmt(), Parser::CopyTableStmt::CopyTableStmt(), Parser::CreateDataframeStmt::CreateDataframeStmt(), Parser::CreateDBStmt::CreateDBStmt(), Parser::CreateModelStmt::CreateModelStmt(), Parser::CreateTableAsSelectStmt::CreateTableAsSelectStmt(), Parser::CreateTableStmt::CreateTableStmt(), Parser::CreateUserStmt::CreateUserStmt(), Parser::DumpRestoreTableStmtBase::DumpRestoreTableStmtBase(), Parser::ExportQueryStmt::ExportQueryStmt(), Parser::OptimizeTableStmt::OptimizeTableStmt(), and Parser::ValidateStmt::ValidateStmt().

2022  {
2023  if (payload.HasMember("options") && payload["options"].IsObject()) {
2024  const auto& options = payload["options"];
2025  for (auto itr = options.MemberBegin(); itr != options.MemberEnd(); ++itr) {
2026  auto option_name = std::make_unique<std::string>(itr->name.GetString());
2027  std::unique_ptr<Literal> literal_value;
2028  if (itr->value.IsString()) {
2029  std::string str = itr->value.GetString();
2030  if (stringToNull && str == "") {
2031  literal_value = std::make_unique<NullLiteral>();
2032  } else if (stringToInteger && std::all_of(str.begin(), str.end(), ::isdigit)) {
2033  int iVal = std::stoi(str);
2034  literal_value = std::make_unique<IntLiteral>(iVal);
2035  } else {
2036  // Rapidjson will deliberately provide escape'd strings when accessed
2037  // ... but the literal should have a copy of the raw unescaped string
2038  auto unique_literal_string = std::make_unique<std::string>(unescape(str));
2039  literal_value =
2040  std::make_unique<StringLiteral>(unique_literal_string.release());
2041  }
2042  } else if (itr->value.IsInt() || itr->value.IsInt64()) {
2043  literal_value = std::make_unique<IntLiteral>(json_i64(itr->value));
2044  } else if (itr->value.IsDouble()) {
2045  literal_value = std::make_unique<DoubleLiteral>(json_double(itr->value));
2046  } else if (itr->value.IsNull()) {
2047  literal_value = std::make_unique<NullLiteral>();
2048  } else {
2049  throw std::runtime_error("Unable to handle literal for " + *option_name);
2050  }
2051  CHECK(literal_value);
2052 
2053  nameValueList.emplace_back(std::make_unique<NameValueAssign>(
2054  option_name.release(), literal_value.release()));
2055  }
2056  }
2057 }
const int64_t json_i64(const rapidjson::Value &obj) noexcept
Definition: JsonAccessors.h:41
const double json_double(const rapidjson::Value &obj) noexcept
Definition: JsonAccessors.h:56
#define CHECK(condition)
Definition: Logger.h:291

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Parser::anonymous_namespace{ParserNode.cpp}::recordRename ( SubstituteMap &  sMap,
std::string  oldName,
std::string  newName 
)

Definition at line 5185 of file ParserNode.cpp.

Referenced by Parser::RenameTableStmt::execute().

5185  {
5186  sMap[oldName] = newName;
5187 }

+ Here is the caller graph for this function:

std::string Parser::anonymous_namespace{ParserNode.cpp}::serialize_key_metainfo ( const ShardKeyDef *  shard_key_def,
const std::vector< SharedDictionaryDef > &  shared_dict_defs 
)

Definition at line 2830 of file ParserNode.cpp.

References Parser::ShardKeyDef::get_column(), and set_string_field().

Referenced by Parser::CreateDataframeStmt::execute(), Parser::CreateTableAsSelectStmt::execute(), and Parser::CreateTableStmt::executeDryRun().

2832  {
2833  rapidjson::Document document;
2834  auto& allocator = document.GetAllocator();
2835  rapidjson::Value arr(rapidjson::kArrayType);
2836  if (shard_key_def) {
2837  rapidjson::Value shard_key_obj(rapidjson::kObjectType);
2838  set_string_field(shard_key_obj, "type", "SHARD KEY", document);
2839  set_string_field(shard_key_obj, "name", shard_key_def->get_column(), document);
2840  arr.PushBack(shard_key_obj, allocator);
2841  }
2842  for (const auto& shared_dict_def : shared_dict_defs) {
2843  rapidjson::Value shared_dict_obj(rapidjson::kObjectType);
2844  set_string_field(shared_dict_obj, "type", "SHARED DICTIONARY", document);
2845  set_string_field(shared_dict_obj, "name", shared_dict_def.get_column(), document);
2847  shared_dict_obj, "foreign_table", shared_dict_def.get_foreign_table(), document);
2848  set_string_field(shared_dict_obj,
2849  "foreign_column",
2850  shared_dict_def.get_foreign_column(),
2851  document);
2852  arr.PushBack(shared_dict_obj, allocator);
2853  }
2854  rapidjson::StringBuffer buffer;
2855  rapidjson::Writer<rapidjson::StringBuffer> writer(buffer);
2856  arr.Accept(writer);
2857  return buffer.GetString();
2858 }
void set_string_field(rapidjson::Value &obj, const std::string &field_name, const std::string &field_value, rapidjson::Document &document)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Parser::anonymous_namespace{ParserNode.cpp}::set_string_field ( rapidjson::Value &  obj,
const std::string &  field_name,
const std::string &  field_value,
rapidjson::Document &  document 
)

Definition at line 2817 of file ParserNode.cpp.

Referenced by serialize_key_metainfo().

2820  {
2821  rapidjson::Value field_name_json_str;
2822  field_name_json_str.SetString(
2823  field_name.c_str(), field_name.size(), document.GetAllocator());
2824  rapidjson::Value field_value_json_str;
2825  field_value_json_str.SetString(
2826  field_value.c_str(), field_value.size(), document.GetAllocator());
2827  obj.AddMember(field_name_json_str, field_value_json_str, document.GetAllocator());
2828 }

+ Here is the caller graph for this function:

size_t Parser::anonymous_namespace{ParserNode.cpp}::shard_column_index ( const std::string &  name,
const std::list< ColumnDescriptor > &  columns 
)

Definition at line 2784 of file ParserNode.cpp.

References validate_shard_column_type().

Referenced by Parser::CreateTableStmt::executeDryRun().

2785  {
2786  size_t index = 1;
2787  for (const auto& cd : columns) {
2788  if (cd.columnName == name) {
2790  return index;
2791  }
2792  ++index;
2793  if (cd.columnType.is_geometry()) {
2794  index += cd.columnType.get_physical_cols();
2795  }
2796  }
2797  // Not found, return 0
2798  return 0;
2799 }
void validate_shard_column_type(const ColumnDescriptor &cd)
string name
Definition: setup.in.py:72

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

size_t Parser::anonymous_namespace{ParserNode.cpp}::sort_column_index ( const std::string &  name,
const std::list< ColumnDescriptor > &  columns 
)

Definition at line 2801 of file ParserNode.cpp.

Referenced by get_sort_column_def().

2802  {
2803  size_t index = 1;
2804  for (const auto& cd : columns) {
2805  if (boost::to_upper_copy<std::string>(cd.columnName) == name) {
2806  return index;
2807  }
2808  ++index;
2809  if (cd.columnType.is_geometry()) {
2810  index += cd.columnType.get_physical_cols();
2811  }
2812  }
2813  // Not found, return 0
2814  return 0;
2815 }
string name
Definition: setup.in.py:72

+ Here is the caller graph for this function:

std::string Parser::anonymous_namespace{ParserNode.cpp}::unescape ( std::string  s)

Definition at line 1987 of file ParserNode.cpp.

Referenced by heavydb._samlutils::get_saml_response(), and parse_options().

1987  {
1988  boost::replace_all(s, "\\\\t", "\t");
1989  boost::replace_all(s, "\\t", "\t");
1990  boost::replace_all(s, "\\\\n", "\n");
1991  boost::replace_all(s, "\\n", "\n");
1992 
1993  // handle numerics
1994  std::smatch m;
1995 
1996  // "\x00"
1997  std::regex e1("(\\\\x[0-9A-Fa-f][0-9A-Fa-f])");
1998  while (std::regex_search(s, m, e1)) {
1999  std::string original(m[0].first, m[0].second);
2000  std::string replacement;
2001  long val = strtol(original.substr(2, 2).c_str(), NULL, 16);
2002  replacement.push_back(val);
2003  boost::replace_all(s, original, replacement);
2004  }
2005 
2006  // "\u0000"
2007  std::regex e2("(\\\\u[0-9A-Fa-f][0-9A-Fa-f][0-9A-Fa-f][0-9A-Fa-f])");
2008  while (std::regex_search(s, m, e2)) {
2009  std::string original(m[0].first, m[0].second);
2010  std::string replacement;
2011  long val = strtol(original.substr(2, 4).c_str(), NULL, 16);
2012  replacement.push_back(val);
2013  boost::replace_all(s, original, replacement);
2014  }
2015 
2016  return s;
2017 }

+ Here is the caller graph for this function:

bool Parser::anonymous_namespace{ParserNode.cpp}::user_can_access_table ( const Catalog_Namespace::SessionInfo session_info,
const TableDescriptor td,
const AccessPrivileges  access_priv 
)

Definition at line 4984 of file ParserNode.cpp.

References cat(), CHECK, Catalog_Namespace::SessionInfo::get_currentUser(), Catalog_Namespace::SessionInfo::getCatalog(), DBObject::loadKey(), DBObject::setPrivileges(), TableDBObjectType, and TableDescriptor::tableName.

Referenced by Parser::OptimizeTableStmt::execute().

4986  {
4987  CHECK(td);
4988  auto& cat = session_info.getCatalog();
4989  std::vector<DBObject> privObjects;
4990  DBObject dbObject(td->tableName, TableDBObjectType);
4991  dbObject.loadKey(cat);
4992  dbObject.setPrivileges(access_priv);
4993  privObjects.push_back(dbObject);
4994  return SysCatalog::instance().checkPrivileges(session_info.get_currentUser(),
4995  privObjects);
4996 };
std::string cat(Ts &&...args)
std::string tableName
Catalog & getCatalog() const
Definition: SessionInfo.h:75
#define CHECK(condition)
Definition: Logger.h:291
const UserMetadata & get_currentUser() const
Definition: SessionInfo.h:88

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Parser::anonymous_namespace{ParserNode.cpp}::validate_shard_column_type ( const ColumnDescriptor cd)

Definition at line 2775 of file ParserNode.cpp.

References ColumnDescriptor::columnType, and kENCODING_DICT.

Referenced by shard_column_index().

2775  {
2776  const auto& col_ti = cd.columnType;
2777  if (!col_ti.is_integer() && !col_ti.is_time() &&
2778  !(col_ti.is_string() && col_ti.get_compression() == kENCODING_DICT)) {
2779  throw std::runtime_error("Cannot shard on type " + col_ti.get_type_name() +
2780  ", encoding " + col_ti.get_compression_name());
2781  }
2782 }
SQLTypeInfo columnType

+ Here is the caller graph for this function:

Variable Documentation

const std::map<const std::string, const DataframeDefFuncPtr> Parser::anonymous_namespace{ParserNode.cpp}::dataframeDefFuncMap
static
Initial value:
=
{{"fragment_size"s, get_frag_size_dataframe_def},
{"max_chunk_size"s, get_max_chunk_size_dataframe_def},
{"skip_rows"s, get_skip_rows_def},
{"delimiter"s, get_delimiter_def},
{"header"s, get_header_def}}
decltype(auto) get_skip_rows_def(DataframeTableDescriptor &df_td, const NameValueAssign *p, const std::list< ColumnDescriptor > &columns)
decltype(auto) get_header_def(DataframeTableDescriptor &df_td, const NameValueAssign *p, const std::list< ColumnDescriptor > &columns)
decltype(auto) get_max_chunk_size_dataframe_def(DataframeTableDescriptor &df_td, const NameValueAssign *p, const std::list< ColumnDescriptor > &columns)
decltype(auto) get_frag_size_dataframe_def(DataframeTableDescriptor &df_td, const NameValueAssign *p, const std::list< ColumnDescriptor > &columns)
decltype(auto) get_delimiter_def(DataframeTableDescriptor &df_td, const NameValueAssign *p, const std::list< ColumnDescriptor > &columns)

Definition at line 3061 of file ParserNode.cpp.

constexpr char const* Parser::anonymous_namespace{ParserNode.cpp}::EMPTY_NAME {""}
static
const std::map<const std::string, const TableDefFuncPtr> Parser::anonymous_namespace{ParserNode.cpp}::tableDefFuncMap
static
Initial value:
= {
{"fragment_size"s, get_frag_size_def},
{"max_chunk_size"s, get_max_chunk_size_def},
{"page_size"s, get_page_size_def},
{"max_rows"s, get_max_rows_def},
{"partitions"s, get_partions_def},
{"shard_count"s, get_shard_count_def},
{"vacuum"s, get_vacuum_def},
{"sort_column"s, get_sort_column_def},
{"storage_type"s, get_storage_type},
{"max_rollback_epochs", get_max_rollback_epochs_def}}
decltype(auto) get_max_rows_def(TableDescriptor &td, const NameValueAssign *p, const std::list< ColumnDescriptor > &columns)
decltype(auto) get_max_chunk_size_def(TableDescriptor &td, const NameValueAssign *p, const std::list< ColumnDescriptor > &columns)
decltype(auto) get_vacuum_def(TableDescriptor &td, const NameValueAssign *p, const std::list< ColumnDescriptor > &columns)
decltype(auto) get_shard_count_def(TableDescriptor &td, const NameValueAssign *p, const std::list< ColumnDescriptor > &columns)
decltype(auto) get_sort_column_def(TableDescriptor &td, const NameValueAssign *p, const std::list< ColumnDescriptor > &columns)
decltype(auto) get_frag_size_def(TableDescriptor &td, const NameValueAssign *p, const std::list< ColumnDescriptor > &columns)
decltype(auto) get_partions_def(TableDescriptor &td, const NameValueAssign *p, const std::list< ColumnDescriptor > &columns)
decltype(auto) get_page_size_def(TableDescriptor &td, const NameValueAssign *p, const std::list< ColumnDescriptor > &columns)
decltype(auto) get_max_rollback_epochs_def(TableDescriptor &td, const NameValueAssign *p, const std::list< ColumnDescriptor > &columns)
decltype(auto) get_storage_type(TableDescriptor &td, const NameValueAssign *p, const std::list< ColumnDescriptor > &columns)

Definition at line 3020 of file ParserNode.cpp.