OmniSciDB  a5dc49c757
 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 4614 of file ParserNode.cpp.

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

4618  {}) {
4619  auto& sys_catalog = SysCatalog::instance();
4620  auto& calcite_mgr = sys_catalog.getCalciteMgr();
4621  const auto calciteQueryParsingOption =
4622  calcite_mgr.getCalciteQueryParsingOption(true, false, true, false);
4623  const auto calciteOptimizationOption = calcite_mgr.getCalciteOptimizationOption(
4624  false, g_enable_watchdog, {}, sys_catalog.isAggregator());
4625  const auto result = calcite_mgr.process(query_state_proxy,
4626  pg_shim(query_str),
4627  calciteQueryParsingOption,
4628  calciteOptimizationOption);
4629  // force sort into tableid order in case of name change to guarantee fixed order of
4630  // mutex access
4631  auto comparator = [](const std::vector<std::string>& table_1,
4632  const std::vector<std::string>& table_2) {
4633  return get_table_key(table_1) < get_table_key(table_2);
4634  };
4635  std::set<std::vector<std::string>, decltype(comparator)> tables(comparator);
4636  for (auto& tab : result.resolved_accessed_objects.tables_selected_from) {
4637  tables.emplace(tab);
4638  }
4639  if (insert_table_name.has_value()) {
4640  tables.emplace(
4641  std::vector<std::string>{insert_table_name.value(), insert_table_db_name});
4642  }
4644  for (const auto& table : tables) {
4645  const auto catalog = sys_catalog.getCatalog(table[1]);
4646  CHECK(catalog);
4647  locks.emplace_back(
4650  *catalog, table[0])));
4651  if (insert_table_name.has_value() && table[0] == insert_table_name.value() &&
4652  table[1] == insert_table_db_name) {
4653  locks.emplace_back(
4656  catalog->getDatabaseId(), (*locks.back())())));
4657  } else {
4658  locks.emplace_back(
4661  catalog->getDatabaseId(), (*locks.back())())));
4662  }
4663  }
4664  return locks;
4665 }
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
T & instance()
Definition: LockMgr.cpp:101
std::string pg_shim(std::string const &query)
#define CHECK(condition)
Definition: Logger.h:291

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

References Parser::StringLiteral::get_stringval().

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

1080  {
1081  const std::string* s = str_literal->get_stringval();
1082  if (*s == "t" || *s == "true" || *s == "T" || *s == "True") {
1083  return true;
1084  } else if (*s == "f" || *s == "false" || *s == "F" || *s == "False") {
1085  return false;
1086  } else {
1087  throw std::runtime_error("Invalid string for boolean " + *s);
1088  }
1089 }
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 5235 of file ParserNode.cpp.

References EMPTY_NAME.

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

5235  {
5236  // Substition map should be clean at end of rename:
5237  // all items in map must (map to self) or (map to EMPTY_STRING) by end
5238 
5239  for (auto it : sMap) {
5240  if ((it.second) != EMPTY_NAME && (it.first) != (it.second)) {
5241  throw std::runtime_error(
5242  "Error: Attempted to overwrite and lose data in table: \'" + (it.first) + "\'");
5243  }
5244  }
5245 }
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 5249 of file ParserNode.cpp.

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

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

5249  {
5251  throw std::runtime_error(td->tableName + " is a foreign table. " +
5252  "Use ALTER FOREIGN TABLE.");
5253  }
5254 }
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 1650 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().

1650  {
1651  if (expr->get_type_info().get_type() == kNULLT) {
1652  return true;
1653  }
1654  auto array_expr = dynamic_cast<const Analyzer::ArrayExpr*>(expr);
1655  if (array_expr && array_expr->isNull()) {
1656  return true;
1657  }
1658  const auto const_expr = dynamic_cast<const Analyzer::Constant*>(expr);
1659  return const_expr && const_expr->get_is_null();
1660 }
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 5200 of file ParserNode.cpp.

References run_benchmark_import::result, and to_string().

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

5200  {
5201  // TODO - is there a "better" way to create a tmp name for the table
5202  std::time_t result = std::time(nullptr);
5203  return name + "_tmp" + std::to_string(result);
5204 }
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 3084 of file ParserNode.cpp.

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

3086  {
3087  const auto it =
3088  dataframeDefFuncMap.find(boost::to_lower_copy<std::string>(*p->get_name()));
3089  if (it == dataframeDefFuncMap.end()) {
3090  throw std::runtime_error(
3091  "Invalid CREATE DATAFRAME option " + *p->get_name() +
3092  ". Should be FRAGMENT_SIZE, MAX_CHUNK_SIZE, SKIP_ROWS, DELIMITER or HEADER.");
3093  }
3094  return it->second(df_td, p.get(), columns);
3095 }
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 2918 of file ParserNode.cpp.

2920  {
2921  return get_property_value<StringLiteral>(p, [&df_td](const auto val) {
2922  if (val.size() != 1) {
2923  throw std::runtime_error("Length of DELIMITER must be equal to 1.");
2924  }
2925  df_td.delimiter = val;
2926  });
2927 }
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 2896 of file ParserNode.cpp.

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

Definition at line 2888 of file ParserNode.cpp.

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

2890  {
2891  return get_property_value<IntLiteral>(p, [&td](const auto val) {
2893  });
2894 }
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 2929 of file ParserNode.cpp.

2931  {
2932  return get_property_value<StringLiteral>(p, [&df_td](const auto val) {
2933  if (val == "FALSE") {
2934  df_td.hasHeader = false;
2935  } else if (val == "TRUE") {
2936  df_td.hasHeader = true;
2937  } else {
2938  throw std::runtime_error("Option HEADER support only 'true' or 'false' values.");
2939  }
2940  });
2941 }
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 2910 of file ParserNode.cpp.

2913  {
2914  return get_property_value<IntLiteral>(
2915  p, [&df_td](const auto val) { df_td.maxChunkSize = val; });
2916 }
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 2903 of file ParserNode.cpp.

2905  {
2906  return get_property_value<IntLiteral>(p,
2907  [&td](const auto val) { td.maxChunkSize = val; });
2908 }
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 3023 of file ParserNode.cpp.

3025  {
3026  auto assignment = [&td](const auto val) {
3027  td.maxRollbackEpochs =
3028  val < 0 ? -1 : val; // Anything < 0 means unlimited rollbacks. Note that 0
3029  // still means keeping a shadow copy of data/metdata
3030  // between epochs so bad writes can be rolled back
3031  };
3032  return get_property_value<IntLiteral, decltype(assignment), PositiveOrZeroValidate>(
3033  p, assignment);
3034 }
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 2955 of file ParserNode.cpp.

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

Definition at line 2943 of file ParserNode.cpp.

References File_Namespace::FileBuffer::getMinPageSize(), and to_string().

2945  {
2946  return get_property_value<IntLiteral>(p, [&td](const auto val) {
2947  const auto min_page_size = File_Namespace::FileBuffer::getMinPageSize();
2948  if (val < min_page_size) {
2949  throw std::runtime_error("page_size cannot be less than " +
2950  std::to_string(min_page_size));
2951  }
2952  td.fragPageSize = val;
2953  });
2954 }
std::string to_string(char const *&&v)
static size_t getMinPageSize()
Definition: FileBuffer.cpp:161

+ Here is the call graph for this function:

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

Definition at line 2968 of file ParserNode.cpp.

2970  {
2971  return get_property_value<StringLiteral>(p, [&td](const auto partitions_uc) {
2972  if (partitions_uc != "SHARDED" && partitions_uc != "REPLICATED") {
2973  throw std::runtime_error("PARTITIONS must be SHARDED or REPLICATED");
2974  }
2975  if (td.shardedColumnId != 0 && partitions_uc == "REPLICATED") {
2976  throw std::runtime_error(
2977  "A table cannot be sharded and replicated at the same time");
2978  };
2979  td.partitions = partitions_uc;
2980  });
2981 }
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 2873 of file ParserNode.cpp.

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

Definition at line 2982 of file ParserNode.cpp.

References g_leaf_count.

2984  {
2985  if (!td.shardedColumnId) {
2986  throw std::runtime_error("SHARD KEY must be defined.");
2987  }
2988  return get_property_value<IntLiteral>(p, [&td](const auto shard_count) {
2989  if (g_leaf_count && shard_count % g_leaf_count) {
2990  throw std::runtime_error(
2991  "SHARD_COUNT must be a multiple of the number of leaves in the cluster.");
2992  }
2993  td.nShards = g_leaf_count ? shard_count / g_leaf_count : shard_count;
2994  if (!td.shardedColumnId && !td.nShards) {
2995  throw std::runtime_error(
2996  "Must specify the number of shards through the SHARD_COUNT option");
2997  };
2998  });
2999 }
size_t g_leaf_count
Definition: ParserNode.cpp:79
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 2961 of file ParserNode.cpp.

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

Definition at line 3012 of file ParserNode.cpp.

References sort_column_index().

3014  {
3015  return get_property_value<StringLiteral>(p, [&td, &columns](const auto sort_upper) {
3016  td.sortedColumnId = sort_column_index(sort_upper, columns);
3017  if (!td.sortedColumnId) {
3018  throw std::runtime_error("Specified sort column " + sort_upper + " doesn't exist");
3019  }
3020  });
3021 }
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 2880 of file ParserNode.cpp.

2882  {
2883  auto assignment = [&td](const auto val) { td.storageType = val; };
2884  return get_property_value<StringLiteral, decltype(assignment), CaseSensitiveValidate>(
2885  p, assignment);
2886 }
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 7086 of file ParserNode.cpp.

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

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

7087  {
7088  CHECK(option);
7089  if (boost::iequals(*option->get_name(), option_name)) {
7090  if (const auto str_literal =
7091  dynamic_cast<const StringLiteral*>(option->get_value())) {
7092  return *str_literal->get_stringval();
7093  } else {
7094  throw std::runtime_error("\"" + option_name + "\" option must be a string.");
7095  }
7096  }
7097  return {};
7098 }
#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 3048 of file ParserNode.cpp.

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

3050  {
3051  const auto it = tableDefFuncMap.find(boost::to_lower_copy<std::string>(*p->get_name()));
3052  if (it == tableDefFuncMap.end()) {
3053  throw std::runtime_error(
3054  "Invalid CREATE TABLE option " + *p->get_name() +
3055  ". Should be FRAGMENT_SIZE, MAX_CHUNK_SIZE, PAGE_SIZE, MAX_ROLLBACK_EPOCHS, "
3056  "MAX_ROWS, "
3057  "PARTITIONS, SHARD_COUNT, VACUUM, SORT_COLUMN, STORAGE_TYPE.");
3058  }
3059  return it->second(td, p.get(), columns);
3060 }
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 3062 of file ParserNode.cpp.

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

3064  {
3065  const auto it = tableDefFuncMap.find(boost::to_lower_copy<std::string>(*p->get_name()));
3066  if (it == tableDefFuncMap.end()) {
3067  throw std::runtime_error(
3068  "Invalid CREATE TABLE AS option " + *p->get_name() +
3069  ". Should be FRAGMENT_SIZE, MAX_CHUNK_SIZE, PAGE_SIZE, MAX_ROLLBACK_EPOCHS, "
3070  "MAX_ROWS, "
3071  "PARTITIONS, SHARD_COUNT, VACUUM, SORT_COLUMN, STORAGE_TYPE, "
3072  "USE_SHARED_DICTIONARIES or FORCE_GEO_COMPRESSION.");
3073  }
3074  return it->second(td, p.get(), columns);
3075 }
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 4603 of file ParserNode.cpp.

References CHECK, and lockmgr::instance().

4603  {
4604  const auto catalog = SysCatalog::instance().getCatalog(table[1]);
4605  CHECK(catalog);
4606  const auto table_id = catalog->getTableId(table[0]);
4607  if (!table_id.has_value()) {
4608  throw std::runtime_error{"Table \"" + table[0] +
4609  "\" does not exist in catalog: " + table[1] + "."};
4610  }
4611  return {catalog->getDatabaseId(), table_id.value()};
4612 }
T & instance()
Definition: LockMgr.cpp:101
#define CHECK(condition)
Definition: Logger.h:291

+ Here is the call graph for this function:

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

Definition at line 3001 of file ParserNode.cpp.

3003  {
3004  return get_property_value<StringLiteral>(p, [&td](const auto vacuum_uc) {
3005  if (vacuum_uc != "IMMEDIATE" && vacuum_uc != "DELAYED") {
3006  throw std::runtime_error("VACUUM must be IMMEDIATE or DELAYED");
3007  }
3008  td.hasDeletedCol = boost::iequals(vacuum_uc, "IMMEDIATE") ? false : true;
3009  });
3010 }
bool Parser::anonymous_namespace{ParserNode.cpp}::hasData ( SubstituteMap &  sMap,
std::string  tableName 
)

Definition at line 5230 of file ParserNode.cpp.

References EMPTY_NAME.

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

5230  {
5231  // assumes loadTable has been previously called
5232  return (sMap[tableName] != EMPTY_NAME);
5233 }
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 5210 of file ParserNode.cpp.

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

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

5212  {
5213  if (sMap.find(tableName) != sMap.end()) {
5214  if (sMap[tableName] == EMPTY_NAME) {
5215  return tableName;
5216  }
5217  return sMap[tableName];
5218  } else {
5219  // lookup table in src catalog
5220  const TableDescriptor* td = catalog.getMetadataForTable(tableName);
5221  if (td) {
5222  sMap[tableName] = tableName;
5223  } else {
5224  sMap[tableName] = EMPTY_NAME;
5225  }
5226  }
5227  return tableName;
5228 }
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 1091 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_drop_if_all_null, 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().

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

3100  {
3101  const auto elements = payload[element_name].GetArray();
3102  for (const auto& element : elements) {
3103  CHECK(element.IsObject());
3104  CHECK(element.HasMember("type"));
3105  if (json_str(element["type"]) == "SQL_COLUMN_DECLARATION") {
3106  auto col_def = column_from_json(element);
3107  table_element_list.emplace_back(std::move(col_def));
3108  } else if (json_str(element["type"]) == "SQL_COLUMN_CONSTRAINT") {
3109  CHECK(element.HasMember("name"));
3110  if (json_str(element["name"]) == "SHARD_KEY") {
3111  CHECK(element.HasMember("columns"));
3112  CHECK(element["columns"].IsArray());
3113  const auto& columns = element["columns"].GetArray();
3114  if (columns.Size() != size_t(1)) {
3115  throw std::runtime_error("Only one shard column is currently supported.");
3116  }
3117  auto shard_key_def = std::make_unique<ShardKeyDef>(json_str(columns[0]));
3118  table_element_list.emplace_back(std::move(shard_key_def));
3119  } else if (json_str(element["name"]) == "SHARED_DICT") {
3120  CHECK(element.HasMember("columns"));
3121  CHECK(element["columns"].IsArray());
3122  const auto& columns = element["columns"].GetArray();
3123  if (columns.Size() != size_t(1)) {
3124  throw std::runtime_error(
3125  R"(Only one column per shared dictionary entry is currently supported. Use multiple SHARED DICT statements to share dictionaries from multiple columns.)");
3126  }
3127  CHECK(element.HasMember("references") && element["references"].IsObject());
3128  const auto& references = element["references"].GetObject();
3129  std::string references_table_name;
3130  if (references.HasMember("table")) {
3131  references_table_name = json_str(references["table"]);
3132  } else {
3133  references_table_name = table_name;
3134  }
3135  CHECK(references.HasMember("column"));
3136 
3137  auto shared_dict_def = std::make_unique<SharedDictionaryDef>(
3138  json_str(columns[0]), references_table_name, json_str(references["column"]));
3139  table_element_list.emplace_back(std::move(shared_dict_def));
3140 
3141  } else {
3142  LOG(FATAL) << "Unsupported type for SQL_COLUMN_CONSTRAINT: "
3143  << json_str(element["name"]);
3144  }
3145  } else {
3146  LOG(FATAL) << "Unsupported element type for CREATE TABLE: "
3147  << element["type"].GetString();
3148  }
3149  }
3150 }
#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 2444 of file ParserNode.cpp.

References CHECK, and parse_insert_literal().

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

2444  {
2445  CHECK(array.IsArray());
2446  auto json_elements = array.GetArray();
2447  auto* elements = new std::list<Expr*>();
2448  for (const auto& e : json_elements) {
2449  elements->push_back(parse_insert_literal(e));
2450  }
2451  return new ArrayLiteral(elements);
2452 }
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 2410 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().

2410  {
2411  CHECK(literal.IsObject());
2412  CHECK(literal.HasMember("literal"));
2413  CHECK(literal.HasMember("type"));
2414  auto type = json_str(literal["type"]);
2415  if (type == "NULL") {
2416  return new NullLiteral();
2417  } else if (type == "CHAR" || type == "BOOLEAN") {
2418  auto* val = new std::string(json_str(literal["literal"]));
2419  return new StringLiteral(val);
2420  } else if (type == "DECIMAL") {
2421  CHECK(literal.HasMember("scale"));
2422  CHECK(literal.HasMember("precision"));
2423  auto scale = json_i64(literal["scale"]);
2424  auto precision = json_i64(literal["precision"]);
2425  if (scale == 0) {
2426  auto int_val = std::stol(json_str(literal["literal"]));
2427  return new IntLiteral(int_val);
2428  } else if (precision > sql_constants::kMaxNumericPrecision) {
2429  auto dbl_val = std::stod(json_str(literal["literal"]));
2430  return new DoubleLiteral(dbl_val);
2431  } else {
2432  auto* val = new std::string(json_str(literal["literal"]));
2433  return new FixedPtLiteral(val);
2434  }
2435  } else if (type == "DOUBLE") {
2436  auto dbl_val = std::stod(json_str(literal["literal"]));
2437  return new DoubleLiteral(dbl_val);
2438  } else {
2439  CHECK(false) << "Unexpected calcite data type: " << type;
2440  }
2441  return nullptr;
2442 }
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 2029 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().

2032  {
2033  if (payload.HasMember("options") && payload["options"].IsObject()) {
2034  const auto& options = payload["options"];
2035  for (auto itr = options.MemberBegin(); itr != options.MemberEnd(); ++itr) {
2036  auto option_name = std::make_unique<std::string>(itr->name.GetString());
2037  std::unique_ptr<Literal> literal_value;
2038  if (itr->value.IsString()) {
2039  std::string str = itr->value.GetString();
2040  if (stringToNull && str == "") {
2041  literal_value = std::make_unique<NullLiteral>();
2042  } else if (stringToInteger && std::all_of(str.begin(), str.end(), ::isdigit)) {
2043  int iVal = std::stoi(str);
2044  literal_value = std::make_unique<IntLiteral>(iVal);
2045  } else {
2046  // Rapidjson will deliberately provide escape'd strings when accessed
2047  // ... but the literal should have a copy of the raw unescaped string
2048  auto unique_literal_string = std::make_unique<std::string>(unescape(str));
2049  literal_value =
2050  std::make_unique<StringLiteral>(unique_literal_string.release());
2051  }
2052  } else if (itr->value.IsInt() || itr->value.IsInt64()) {
2053  literal_value = std::make_unique<IntLiteral>(json_i64(itr->value));
2054  } else if (itr->value.IsDouble()) {
2055  literal_value = std::make_unique<DoubleLiteral>(json_double(itr->value));
2056  } else if (itr->value.IsNull()) {
2057  literal_value = std::make_unique<NullLiteral>();
2058  } else {
2059  throw std::runtime_error("Unable to handle literal for " + *option_name);
2060  }
2061  CHECK(literal_value);
2062 
2063  nameValueList.emplace_back(std::make_unique<NameValueAssign>(
2064  option_name.release(), literal_value.release()));
2065  }
2066  }
2067 }
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 5206 of file ParserNode.cpp.

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

5206  {
5207  sMap[oldName] = newName;
5208 }

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

2842  {
2843  rapidjson::Document document;
2844  auto& allocator = document.GetAllocator();
2845  rapidjson::Value arr(rapidjson::kArrayType);
2846  if (shard_key_def) {
2847  rapidjson::Value shard_key_obj(rapidjson::kObjectType);
2848  set_string_field(shard_key_obj, "type", "SHARD KEY", document);
2849  set_string_field(shard_key_obj, "name", shard_key_def->get_column(), document);
2850  arr.PushBack(shard_key_obj, allocator);
2851  }
2852  for (const auto& shared_dict_def : shared_dict_defs) {
2853  rapidjson::Value shared_dict_obj(rapidjson::kObjectType);
2854  set_string_field(shared_dict_obj, "type", "SHARED DICTIONARY", document);
2855  set_string_field(shared_dict_obj, "name", shared_dict_def.get_column(), document);
2857  shared_dict_obj, "foreign_table", shared_dict_def.get_foreign_table(), document);
2858  set_string_field(shared_dict_obj,
2859  "foreign_column",
2860  shared_dict_def.get_foreign_column(),
2861  document);
2862  arr.PushBack(shared_dict_obj, allocator);
2863  }
2864  rapidjson::StringBuffer buffer;
2865  rapidjson::Writer<rapidjson::StringBuffer> writer(buffer);
2866  arr.Accept(writer);
2867  return buffer.GetString();
2868 }
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 2827 of file ParserNode.cpp.

Referenced by serialize_key_metainfo().

2830  {
2831  rapidjson::Value field_name_json_str;
2832  field_name_json_str.SetString(
2833  field_name.c_str(), field_name.size(), document.GetAllocator());
2834  rapidjson::Value field_value_json_str;
2835  field_value_json_str.SetString(
2836  field_value.c_str(), field_value.size(), document.GetAllocator());
2837  obj.AddMember(field_name_json_str, field_value_json_str, document.GetAllocator());
2838 }

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

References validate_shard_column_type().

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

2795  {
2796  size_t index = 1;
2797  for (const auto& cd : columns) {
2798  if (cd.columnName == name) {
2800  return index;
2801  }
2802  ++index;
2803  if (cd.columnType.is_geometry()) {
2804  index += cd.columnType.get_physical_cols();
2805  }
2806  }
2807  // Not found, return 0
2808  return 0;
2809 }
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 2811 of file ParserNode.cpp.

Referenced by get_sort_column_def().

2812  {
2813  size_t index = 1;
2814  for (const auto& cd : columns) {
2815  if (boost::to_upper_copy<std::string>(cd.columnName) == name) {
2816  return index;
2817  }
2818  ++index;
2819  if (cd.columnType.is_geometry()) {
2820  index += cd.columnType.get_physical_cols();
2821  }
2822  }
2823  // Not found, return 0
2824  return 0;
2825 }
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 1997 of file ParserNode.cpp.

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

1997  {
1998  boost::replace_all(s, "\\\\t", "\t");
1999  boost::replace_all(s, "\\t", "\t");
2000  boost::replace_all(s, "\\\\n", "\n");
2001  boost::replace_all(s, "\\n", "\n");
2002 
2003  // handle numerics
2004  std::smatch m;
2005 
2006  // "\x00"
2007  std::regex e1("(\\\\x[0-9A-Fa-f][0-9A-Fa-f])");
2008  while (std::regex_search(s, m, e1)) {
2009  std::string original(m[0].first, m[0].second);
2010  std::string replacement;
2011  long val = strtol(original.substr(2, 2).c_str(), NULL, 16);
2012  replacement.push_back(val);
2013  boost::replace_all(s, original, replacement);
2014  }
2015 
2016  // "\u0000"
2017  std::regex e2("(\\\\u[0-9A-Fa-f][0-9A-Fa-f][0-9A-Fa-f][0-9A-Fa-f])");
2018  while (std::regex_search(s, m, e2)) {
2019  std::string original(m[0].first, m[0].second);
2020  std::string replacement;
2021  long val = strtol(original.substr(2, 4).c_str(), NULL, 16);
2022  replacement.push_back(val);
2023  boost::replace_all(s, original, replacement);
2024  }
2025 
2026  return s;
2027 }

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

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

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

5007  {
5008  CHECK(td);
5009  auto& cat = session_info.getCatalog();
5010  std::vector<DBObject> privObjects;
5011  DBObject dbObject(td->tableName, TableDBObjectType);
5012  dbObject.loadKey(cat);
5013  dbObject.setPrivileges(access_priv);
5014  privObjects.push_back(dbObject);
5015  return SysCatalog::instance().checkPrivileges(session_info.get_currentUser(),
5016  privObjects);
5017 };
std::string cat(Ts &&...args)
std::string tableName
Catalog & getCatalog() const
Definition: SessionInfo.h:75
T & instance()
Definition: LockMgr.cpp:101
#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 2785 of file ParserNode.cpp.

References ColumnDescriptor::columnType, and kENCODING_DICT.

Referenced by shard_column_index().

2785  {
2786  const auto& col_ti = cd.columnType;
2787  if (!col_ti.is_integer() && !col_ti.is_time() &&
2788  !(col_ti.is_string() && col_ti.get_compression() == kENCODING_DICT)) {
2789  throw std::runtime_error("Cannot shard on type " + col_ti.get_type_name() +
2790  ", encoding " + col_ti.get_compression_name());
2791  }
2792 }
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 3077 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 3036 of file ParserNode.cpp.