OmniSciDB  c1a53651b2
 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)
 
std::unique_ptr< ColumnDefcolumn_from_json (const rapidjson::Value &element)
 
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 4146 of file ParserNode.cpp.

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

4150  {}) {
4151  auto& sys_catalog = SysCatalog::instance();
4152  auto& calcite_mgr = sys_catalog.getCalciteMgr();
4153  const auto calciteQueryParsingOption =
4154  calcite_mgr.getCalciteQueryParsingOption(true, false, true);
4155  const auto calciteOptimizationOption = calcite_mgr.getCalciteOptimizationOption(
4156  false, g_enable_watchdog, {}, sys_catalog.isAggregator());
4157  const auto result = calcite_mgr.process(query_state_proxy,
4158  pg_shim(query_str),
4159  calciteQueryParsingOption,
4160  calciteOptimizationOption);
4161  // force sort into tableid order in case of name change to guarantee fixed order of
4162  // mutex access
4163  auto comparator = [](const std::vector<std::string>& table_1,
4164  const std::vector<std::string>& table_2) {
4165  return get_table_key(table_1) < get_table_key(table_2);
4166  };
4167  std::set<std::vector<std::string>, decltype(comparator)> tables(comparator);
4168  for (auto& tab : result.resolved_accessed_objects.tables_selected_from) {
4169  tables.emplace(tab);
4170  }
4171  if (insert_table_name.has_value()) {
4172  tables.emplace(
4173  std::vector<std::string>{insert_table_name.value(), insert_table_db_name});
4174  }
4176  for (const auto& table : tables) {
4177  const auto catalog = sys_catalog.getCatalog(table[1]);
4178  CHECK(catalog);
4179  locks.emplace_back(
4182  *catalog, table[0])));
4183  if (insert_table_name.has_value() && table[0] == insert_table_name.value() &&
4184  table[1] == insert_table_db_name) {
4185  locks.emplace_back(
4188  catalog->getDatabaseId(), (*locks.back())())));
4189  } else {
4190  locks.emplace_back(
4193  catalog->getDatabaseId(), (*locks.back())())));
4194  }
4195  }
4196  return locks;
4197 }
std::vector< std::unique_ptr< lockmgr::AbstractLockContainer< const TableDescriptor * >>> LockedTableDescriptors
Definition: LockMgr.h:271
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 1074 of file ParserNode.cpp.

References Parser::StringLiteral::get_stringval().

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

1074  {
1075  const std::string* s = str_literal->get_stringval();
1076  if (*s == "t" || *s == "true" || *s == "T" || *s == "True") {
1077  return true;
1078  } else if (*s == "f" || *s == "false" || *s == "F" || *s == "False") {
1079  return false;
1080  } else {
1081  throw std::runtime_error("Invalid string for boolean " + *s);
1082  }
1083 }
const std::string * get_stringval() const
Definition: ParserNode.h:135

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

References EMPTY_NAME.

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

4895  {
4896  // Substition map should be clean at end of rename:
4897  // all items in map must (map to self) or (map to EMPTY_STRING) by end
4898 
4899  for (auto it : sMap) {
4900  if ((it.second) != EMPTY_NAME && (it.first) != (it.second)) {
4901  throw std::runtime_error(
4902  "Error: Attempted to overwrite and lose data in table: \'" + (it.first) + "\'");
4903  }
4904  }
4905 }
static constexpr char const * EMPTY_NAME

+ Here is the caller graph for this function:

std::unique_ptr<ColumnDef> Parser::anonymous_namespace{ParserNode.cpp}::column_from_json ( const rapidjson::Value &  element)

Definition at line 3057 of file ParserNode.cpp.

References CHECK, json_bool(), json_i64(), json_str(), and to_sql_type().

Referenced by Parser::AlterTableStmt::delegate(), and parse_elements().

3057  {
3058  CHECK(element.HasMember("name"));
3059  auto col_name = std::make_unique<std::string>(json_str(element["name"]));
3060  CHECK(element.HasMember("sqltype"));
3061  const auto sql_types = to_sql_type(json_str(element["sqltype"]));
3062 
3063  // decimal / numeric precision / scale
3064  int precision = -1;
3065  int scale = -1;
3066  if (element.HasMember("precision")) {
3067  precision = json_i64(element["precision"]);
3068  }
3069  if (element.HasMember("scale")) {
3070  scale = json_i64(element["scale"]);
3071  }
3072 
3073  std::optional<int64_t> array_size;
3074  if (element.HasMember("arraySize")) {
3075  // We do not yet support geo arrays
3076  array_size = json_i64(element["arraySize"]);
3077  }
3078  std::unique_ptr<SQLType> sql_type;
3079  if (element.HasMember("subtype")) {
3080  CHECK(element.HasMember("coordinateSystem"));
3081  const auto subtype_sql_types = to_sql_type(json_str(element["subtype"]));
3082  sql_type =
3083  std::make_unique<SQLType>(subtype_sql_types,
3084  static_cast<int>(sql_types),
3085  static_cast<int>(json_i64(element["coordinateSystem"])),
3086  false);
3087  } else if (precision > 0 && scale > 0) {
3088  sql_type = std::make_unique<SQLType>(sql_types,
3089  precision,
3090  scale,
3091  /*is_array=*/array_size.has_value(),
3092  array_size ? *array_size : -1);
3093  } else if (precision > 0) {
3094  sql_type = std::make_unique<SQLType>(sql_types,
3095  precision,
3096  0,
3097  /*is_array=*/array_size.has_value(),
3098  array_size ? *array_size : -1);
3099  } else {
3100  sql_type = std::make_unique<SQLType>(sql_types,
3101  /*is_array=*/array_size.has_value(),
3102  array_size ? *array_size : -1);
3103  }
3104  CHECK(sql_type);
3105 
3106  CHECK(element.HasMember("nullable"));
3107  const auto nullable = json_bool(element["nullable"]);
3108  std::unique_ptr<ColumnConstraintDef> constraint_def;
3109  StringLiteral* str_literal = nullptr;
3110  if (element.HasMember("default") && !element["default"].IsNull()) {
3111  std::string* defaultval = new std::string(json_str(element["default"]));
3112  boost::algorithm::trim_if(*defaultval, boost::is_any_of(" \"'`"));
3113  str_literal = new StringLiteral(defaultval);
3114  }
3115 
3116  constraint_def = std::make_unique<ColumnConstraintDef>(/*notnull=*/!nullable,
3117  /*unique=*/false,
3118  /*primarykey=*/false,
3119  /*defaultval=*/str_literal);
3120  std::unique_ptr<CompressDef> compress_def;
3121  if (element.HasMember("encodingType") && !element["encodingType"].IsNull()) {
3122  std::string encoding_type = json_str(element["encodingType"]);
3123  CHECK(element.HasMember("encodingSize"));
3124  auto encoding_name = std::make_unique<std::string>(json_str(element["encodingType"]));
3125  compress_def = std::make_unique<CompressDef>(encoding_name.release(),
3126  json_i64(element["encodingSize"]));
3127  }
3128  return std::make_unique<ColumnDef>(col_name.release(),
3129  sql_type.release(),
3130  compress_def ? compress_def.release() : nullptr,
3131  constraint_def ? constraint_def.release() : nullptr);
3132 }
SQLTypes to_sql_type(const std::string &type_name)
const bool json_bool(const rapidjson::Value &obj) noexcept
Definition: JsonAccessors.h:49
const std::string json_str(const rapidjson::Value &obj) noexcept
Definition: JsonAccessors.h:44
const int64_t json_i64(const rapidjson::Value &obj) noexcept
Definition: JsonAccessors.h:39
#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}::disable_foreign_tables ( const TableDescriptor td)

Definition at line 4909 of file ParserNode.cpp.

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

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

4909  {
4911  throw std::runtime_error(td->tableName + " is a foreign table. " +
4912  "Use ALTER FOREIGN TABLE.");
4913  }
4914 }
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 1627 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().

1627  {
1628  if (expr->get_type_info().get_type() == kNULLT) {
1629  return true;
1630  }
1631  const auto const_expr = dynamic_cast<const Analyzer::Constant*>(expr);
1632  return const_expr && const_expr->get_is_null();
1633 }
bool get_is_null() const
Definition: Analyzer.h:347
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:381
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 4860 of file ParserNode.cpp.

References run_benchmark_import::result, and to_string().

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

4860  {
4861  // TODO - is there a "better" way to create a tmp name for the table
4862  std::time_t result = std::time(nullptr);
4863  return name + "_tmp" + std::to_string(result);
4864 }
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 3044 of file ParserNode.cpp.

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

3046  {
3047  const auto it =
3048  dataframeDefFuncMap.find(boost::to_lower_copy<std::string>(*p->get_name()));
3049  if (it == dataframeDefFuncMap.end()) {
3050  throw std::runtime_error(
3051  "Invalid CREATE DATAFRAME option " + *p->get_name() +
3052  ". Should be FRAGMENT_SIZE, MAX_CHUNK_SIZE, SKIP_ROWS, DELIMITER or HEADER.");
3053  }
3054  return it->second(df_td, p.get(), columns);
3055 }
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 2884 of file ParserNode.cpp.

2886  {
2887  return get_property_value<StringLiteral>(p, [&df_td](const auto val) {
2888  if (val.size() != 1) {
2889  throw std::runtime_error("Length of DELIMITER must be equal to 1.");
2890  }
2891  df_td.delimiter = val;
2892  });
2893 }
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 2862 of file ParserNode.cpp.

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

Definition at line 2855 of file ParserNode.cpp.

2857  {
2858  return get_property_value<IntLiteral>(p,
2859  [&td](const auto val) { td.maxFragRows = val; });
2860 }
decltype(auto) Parser::anonymous_namespace{ParserNode.cpp}::get_header_def ( DataframeTableDescriptor df_td,
const NameValueAssign *  p,
const std::list< ColumnDescriptor > &  columns 
)

Definition at line 2895 of file ParserNode.cpp.

2897  {
2898  return get_property_value<StringLiteral>(p, [&df_td](const auto val) {
2899  if (val == "FALSE") {
2900  df_td.hasHeader = false;
2901  } else if (val == "TRUE") {
2902  df_td.hasHeader = true;
2903  } else {
2904  throw std::runtime_error("Option HEADER support only 'true' or 'false' values.");
2905  }
2906  });
2907 }
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 2876 of file ParserNode.cpp.

2879  {
2880  return get_property_value<IntLiteral>(
2881  p, [&df_td](const auto val) { df_td.maxChunkSize = val; });
2882 }
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 2869 of file ParserNode.cpp.

2871  {
2872  return get_property_value<IntLiteral>(p,
2873  [&td](const auto val) { td.maxChunkSize = val; });
2874 }
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 2983 of file ParserNode.cpp.

2985  {
2986  auto assignment = [&td](const auto val) {
2987  td.maxRollbackEpochs =
2988  val < 0 ? -1 : val; // Anything < 0 means unlimited rollbacks. Note that 0
2989  // still means keeping a shadow copy of data/metdata
2990  // between epochs so bad writes can be rolled back
2991  };
2992  return get_property_value<IntLiteral, decltype(assignment), PositiveOrZeroValidate>(
2993  p, assignment);
2994 }
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 2915 of file ParserNode.cpp.

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

Definition at line 2909 of file ParserNode.cpp.

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

Definition at line 2928 of file ParserNode.cpp.

2930  {
2931  return get_property_value<StringLiteral>(p, [&td](const auto partitions_uc) {
2932  if (partitions_uc != "SHARDED" && partitions_uc != "REPLICATED") {
2933  throw std::runtime_error("PARTITIONS must be SHARDED or REPLICATED");
2934  }
2935  if (td.shardedColumnId != 0 && partitions_uc == "REPLICATED") {
2936  throw std::runtime_error(
2937  "A table cannot be sharded and replicated at the same time");
2938  };
2939  td.partitions = partitions_uc;
2940  });
2941 }
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 2840 of file ParserNode.cpp.

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

Definition at line 2942 of file ParserNode.cpp.

References g_leaf_count.

2944  {
2945  if (!td.shardedColumnId) {
2946  throw std::runtime_error("SHARD KEY must be defined.");
2947  }
2948  return get_property_value<IntLiteral>(p, [&td](const auto shard_count) {
2949  if (g_leaf_count && shard_count % g_leaf_count) {
2950  throw std::runtime_error(
2951  "SHARD_COUNT must be a multiple of the number of leaves in the cluster.");
2952  }
2953  td.nShards = g_leaf_count ? shard_count / g_leaf_count : shard_count;
2954  if (!td.shardedColumnId && !td.nShards) {
2955  throw std::runtime_error(
2956  "Must specify the number of shards through the SHARD_COUNT option");
2957  };
2958  });
2959 }
size_t g_leaf_count
Definition: ParserNode.cpp:77
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 2921 of file ParserNode.cpp.

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

Definition at line 2972 of file ParserNode.cpp.

References sort_column_index().

2974  {
2975  return get_property_value<StringLiteral>(p, [&td, &columns](const auto sort_upper) {
2976  td.sortedColumnId = sort_column_index(sort_upper, columns);
2977  if (!td.sortedColumnId) {
2978  throw std::runtime_error("Specified sort column " + sort_upper + " doesn't exist");
2979  }
2980  });
2981 }
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 2847 of file ParserNode.cpp.

2849  {
2850  auto assignment = [&td](const auto val) { td.storageType = val; };
2851  return get_property_value<StringLiteral, decltype(assignment), CaseSensitiveValidate>(
2852  p, assignment);
2853 }
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 6782 of file ParserNode.cpp.

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

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

6783  {
6784  CHECK(option);
6785  if (boost::iequals(*option->get_name(), option_name)) {
6786  if (const auto str_literal =
6787  dynamic_cast<const StringLiteral*>(option->get_value())) {
6788  return *str_literal->get_stringval();
6789  } else {
6790  throw std::runtime_error("\"" + option_name + "\" option must be a string.");
6791  }
6792  }
6793  return {};
6794 }
#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 3008 of file ParserNode.cpp.

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

3010  {
3011  const auto it = tableDefFuncMap.find(boost::to_lower_copy<std::string>(*p->get_name()));
3012  if (it == tableDefFuncMap.end()) {
3013  throw std::runtime_error(
3014  "Invalid CREATE TABLE option " + *p->get_name() +
3015  ". Should be FRAGMENT_SIZE, MAX_CHUNK_SIZE, PAGE_SIZE, MAX_ROLLBACK_EPOCHS, "
3016  "MAX_ROWS, "
3017  "PARTITIONS, SHARD_COUNT, VACUUM, SORT_COLUMN, STORAGE_TYPE.");
3018  }
3019  return it->second(td, p.get(), columns);
3020 }
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 3022 of file ParserNode.cpp.

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

3024  {
3025  const auto it = tableDefFuncMap.find(boost::to_lower_copy<std::string>(*p->get_name()));
3026  if (it == tableDefFuncMap.end()) {
3027  throw std::runtime_error(
3028  "Invalid CREATE TABLE AS option " + *p->get_name() +
3029  ". Should be FRAGMENT_SIZE, MAX_CHUNK_SIZE, PAGE_SIZE, MAX_ROLLBACK_EPOCHS, "
3030  "MAX_ROWS, "
3031  "PARTITIONS, SHARD_COUNT, VACUUM, SORT_COLUMN, STORAGE_TYPE, "
3032  "USE_SHARED_DICTIONARIES or FORCE_GEO_COMPRESSION.");
3033  }
3034  return it->second(td, p.get(), columns);
3035 }
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 4135 of file ParserNode.cpp.

References CHECK.

4135  {
4136  const auto catalog = SysCatalog::instance().getCatalog(table[1]);
4137  CHECK(catalog);
4138  const auto table_id = catalog->getTableId(table[0]);
4139  if (!table_id.has_value()) {
4140  throw std::runtime_error{"Table \"" + table[0] +
4141  "\" does not exist in catalog: " + table[1] + "."};
4142  }
4143  return {catalog->getDatabaseId(), table_id.value()};
4144 }
#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 2961 of file ParserNode.cpp.

2963  {
2964  return get_property_value<StringLiteral>(p, [&td](const auto vacuum_uc) {
2965  if (vacuum_uc != "IMMEDIATE" && vacuum_uc != "DELAYED") {
2966  throw std::runtime_error("VACUUM must be IMMEDIATE or DELAYED");
2967  }
2968  td.hasDeletedCol = boost::iequals(vacuum_uc, "IMMEDIATE") ? false : true;
2969  });
2970 }
bool Parser::anonymous_namespace{ParserNode.cpp}::hasData ( SubstituteMap &  sMap,
std::string  tableName 
)

Definition at line 4890 of file ParserNode.cpp.

References EMPTY_NAME.

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

4890  {
4891  // assumes loadTable has been previously called
4892  return (sMap[tableName] != EMPTY_NAME);
4893 }
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 4870 of file ParserNode.cpp.

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

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

4872  {
4873  if (sMap.find(tableName) != sMap.end()) {
4874  if (sMap[tableName] == EMPTY_NAME) {
4875  return tableName;
4876  }
4877  return sMap[tableName];
4878  } else {
4879  // lookup table in src catalog
4880  const TableDescriptor* td = catalog.getMetadataForTable(tableName);
4881  if (td) {
4882  sMap[tableName] = tableName;
4883  } else {
4884  sMap[tableName] = EMPTY_NAME;
4885  }
4886  }
4887  return tableName;
4888 }
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 1085 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_assign_render_groups, 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, 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().

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

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

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

3137  {
3138  const auto elements = payload[element_name].GetArray();
3139  for (const auto& element : elements) {
3140  CHECK(element.IsObject());
3141  CHECK(element.HasMember("type"));
3142  if (json_str(element["type"]) == "SQL_COLUMN_DECLARATION") {
3143  auto col_def = column_from_json(element);
3144  table_element_list.emplace_back(std::move(col_def));
3145  } else if (json_str(element["type"]) == "SQL_COLUMN_CONSTRAINT") {
3146  CHECK(element.HasMember("name"));
3147  if (json_str(element["name"]) == "SHARD_KEY") {
3148  CHECK(element.HasMember("columns"));
3149  CHECK(element["columns"].IsArray());
3150  const auto& columns = element["columns"].GetArray();
3151  if (columns.Size() != size_t(1)) {
3152  throw std::runtime_error("Only one shard column is currently supported.");
3153  }
3154  auto shard_key_def = std::make_unique<ShardKeyDef>(json_str(columns[0]));
3155  table_element_list.emplace_back(std::move(shard_key_def));
3156  } else if (json_str(element["name"]) == "SHARED_DICT") {
3157  CHECK(element.HasMember("columns"));
3158  CHECK(element["columns"].IsArray());
3159  const auto& columns = element["columns"].GetArray();
3160  if (columns.Size() != size_t(1)) {
3161  throw std::runtime_error(
3162  R"(Only one column per shared dictionary entry is currently supported. Use multiple SHARED DICT statements to share dictionaries from multiple columns.)");
3163  }
3164  CHECK(element.HasMember("references") && element["references"].IsObject());
3165  const auto& references = element["references"].GetObject();
3166  std::string references_table_name;
3167  if (references.HasMember("table")) {
3168  references_table_name = json_str(references["table"]);
3169  } else {
3170  references_table_name = table_name;
3171  }
3172  CHECK(references.HasMember("column"));
3173 
3174  auto shared_dict_def = std::make_unique<SharedDictionaryDef>(
3175  json_str(columns[0]), references_table_name, json_str(references["column"]));
3176  table_element_list.emplace_back(std::move(shared_dict_def));
3177 
3178  } else {
3179  LOG(FATAL) << "Unsupported type for SQL_COLUMN_CONSTRAINT: "
3180  << json_str(element["name"]);
3181  }
3182  } else {
3183  LOG(FATAL) << "Unsupported element type for CREATE TABLE: "
3184  << element["type"].GetString();
3185  }
3186  }
3187 }
#define LOG(tag)
Definition: Logger.h:285
const std::string json_str(const rapidjson::Value &obj) noexcept
Definition: JsonAccessors.h:44
std::unique_ptr< ColumnDef > column_from_json(const rapidjson::Value &element)
#define CHECK(condition)
Definition: Logger.h:291

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

References CHECK, and parse_insert_literal().

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

2412  {
2413  CHECK(array.IsArray());
2414  auto json_elements = array.GetArray();
2415  auto* elements = new std::list<Expr*>();
2416  for (const auto& e : json_elements) {
2417  elements->push_back(parse_insert_literal(e));
2418  }
2419  return new ArrayLiteral(elements);
2420 }
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 2378 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().

2378  {
2379  CHECK(literal.IsObject());
2380  CHECK(literal.HasMember("literal"));
2381  CHECK(literal.HasMember("type"));
2382  auto type = json_str(literal["type"]);
2383  if (type == "NULL") {
2384  return new NullLiteral();
2385  } else if (type == "CHAR" || type == "BOOLEAN") {
2386  auto* val = new std::string(json_str(literal["literal"]));
2387  return new StringLiteral(val);
2388  } else if (type == "DECIMAL") {
2389  CHECK(literal.HasMember("scale"));
2390  CHECK(literal.HasMember("precision"));
2391  auto scale = json_i64(literal["scale"]);
2392  auto precision = json_i64(literal["precision"]);
2393  if (scale == 0) {
2394  auto int_val = std::stol(json_str(literal["literal"]));
2395  return new IntLiteral(int_val);
2396  } else if (precision > sql_constants::kMaxNumericPrecision) {
2397  auto dbl_val = std::stod(json_str(literal["literal"]));
2398  return new DoubleLiteral(dbl_val);
2399  } else {
2400  auto* val = new std::string(json_str(literal["literal"]));
2401  return new FixedPtLiteral(val);
2402  }
2403  } else if (type == "DOUBLE") {
2404  auto dbl_val = std::stod(json_str(literal["literal"]));
2405  return new DoubleLiteral(dbl_val);
2406  } else {
2407  CHECK(false) << "Unexpected calcite data type: " << type;
2408  }
2409  return nullptr;
2410 }
static constexpr int32_t kMaxNumericPrecision
Definition: sqltypes.h:48
const std::string json_str(const rapidjson::Value &obj) noexcept
Definition: JsonAccessors.h:44
const int64_t json_i64(const rapidjson::Value &obj) noexcept
Definition: JsonAccessors.h:39
#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 1999 of file ParserNode.cpp.

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

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

2002  {
2003  if (payload.HasMember("options") && payload["options"].IsObject()) {
2004  const auto& options = payload["options"];
2005  for (auto itr = options.MemberBegin(); itr != options.MemberEnd(); ++itr) {
2006  auto option_name = std::make_unique<std::string>(itr->name.GetString());
2007  std::unique_ptr<Literal> literal_value;
2008  if (itr->value.IsString()) {
2009  std::string str = itr->value.GetString();
2010  if (stringToNull && str == "") {
2011  literal_value = std::make_unique<NullLiteral>();
2012  } else if (stringToInteger && std::all_of(str.begin(), str.end(), ::isdigit)) {
2013  int iVal = std::stoi(str);
2014  literal_value = std::make_unique<IntLiteral>(iVal);
2015  } else {
2016  // Rapidjson will deliberately provide escape'd strings when accessed
2017  // ... but the literal should have a copy of the raw unescaped string
2018  auto unique_literal_string = std::make_unique<std::string>(unescape(str));
2019  literal_value =
2020  std::make_unique<StringLiteral>(unique_literal_string.release());
2021  }
2022  } else if (itr->value.IsInt() || itr->value.IsInt64()) {
2023  literal_value = std::make_unique<IntLiteral>(json_i64(itr->value));
2024  } else if (itr->value.IsNull()) {
2025  literal_value = std::make_unique<NullLiteral>();
2026  } else {
2027  throw std::runtime_error("Unable to handle literal for " + *option_name);
2028  }
2029  CHECK(literal_value);
2030 
2031  nameValueList.emplace_back(std::make_unique<NameValueAssign>(
2032  option_name.release(), literal_value.release()));
2033  }
2034  }
2035 }
const int64_t json_i64(const rapidjson::Value &obj) noexcept
Definition: JsonAccessors.h:39
#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 4866 of file ParserNode.cpp.

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

4866  {
4867  sMap[oldName] = newName;
4868 }

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

2809  {
2810  rapidjson::Document document;
2811  auto& allocator = document.GetAllocator();
2812  rapidjson::Value arr(rapidjson::kArrayType);
2813  if (shard_key_def) {
2814  rapidjson::Value shard_key_obj(rapidjson::kObjectType);
2815  set_string_field(shard_key_obj, "type", "SHARD KEY", document);
2816  set_string_field(shard_key_obj, "name", shard_key_def->get_column(), document);
2817  arr.PushBack(shard_key_obj, allocator);
2818  }
2819  for (const auto& shared_dict_def : shared_dict_defs) {
2820  rapidjson::Value shared_dict_obj(rapidjson::kObjectType);
2821  set_string_field(shared_dict_obj, "type", "SHARED DICTIONARY", document);
2822  set_string_field(shared_dict_obj, "name", shared_dict_def.get_column(), document);
2824  shared_dict_obj, "foreign_table", shared_dict_def.get_foreign_table(), document);
2825  set_string_field(shared_dict_obj,
2826  "foreign_column",
2827  shared_dict_def.get_foreign_column(),
2828  document);
2829  arr.PushBack(shared_dict_obj, allocator);
2830  }
2831  rapidjson::StringBuffer buffer;
2832  rapidjson::Writer<rapidjson::StringBuffer> writer(buffer);
2833  arr.Accept(writer);
2834  return buffer.GetString();
2835 }
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 2794 of file ParserNode.cpp.

Referenced by serialize_key_metainfo().

2797  {
2798  rapidjson::Value field_name_json_str;
2799  field_name_json_str.SetString(
2800  field_name.c_str(), field_name.size(), document.GetAllocator());
2801  rapidjson::Value field_value_json_str;
2802  field_value_json_str.SetString(
2803  field_value.c_str(), field_value.size(), document.GetAllocator());
2804  obj.AddMember(field_name_json_str, field_value_json_str, document.GetAllocator());
2805 }

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

References validate_shard_column_type().

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

2762  {
2763  size_t index = 1;
2764  for (const auto& cd : columns) {
2765  if (cd.columnName == name) {
2767  return index;
2768  }
2769  ++index;
2770  if (cd.columnType.is_geometry()) {
2771  index += cd.columnType.get_physical_cols();
2772  }
2773  }
2774  // Not found, return 0
2775  return 0;
2776 }
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 2778 of file ParserNode.cpp.

Referenced by get_sort_column_def().

2779  {
2780  size_t index = 1;
2781  for (const auto& cd : columns) {
2782  if (boost::to_upper_copy<std::string>(cd.columnName) == name) {
2783  return index;
2784  }
2785  ++index;
2786  if (cd.columnType.is_geometry()) {
2787  index += cd.columnType.get_physical_cols();
2788  }
2789  }
2790  // Not found, return 0
2791  return 0;
2792 }
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 1967 of file ParserNode.cpp.

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

1967  {
1968  boost::replace_all(s, "\\\\t", "\t");
1969  boost::replace_all(s, "\\t", "\t");
1970  boost::replace_all(s, "\\\\n", "\n");
1971  boost::replace_all(s, "\\n", "\n");
1972 
1973  // handle numerics
1974  std::smatch m;
1975 
1976  // "\x00"
1977  std::regex e1("(\\\\x[0-9A-Fa-f][0-9A-Fa-f])");
1978  while (std::regex_search(s, m, e1)) {
1979  std::string original(m[0].first, m[0].second);
1980  std::string replacement;
1981  long val = strtol(original.substr(2, 2).c_str(), NULL, 16);
1982  replacement.push_back(val);
1983  boost::replace_all(s, original, replacement);
1984  }
1985 
1986  // "\u0000"
1987  std::regex e2("(\\\\u[0-9A-Fa-f][0-9A-Fa-f][0-9A-Fa-f][0-9A-Fa-f])");
1988  while (std::regex_search(s, m, e2)) {
1989  std::string original(m[0].first, m[0].second);
1990  std::string replacement;
1991  long val = strtol(original.substr(2, 4).c_str(), NULL, 16);
1992  replacement.push_back(val);
1993  boost::replace_all(s, original, replacement);
1994  }
1995 
1996  return s;
1997 }

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

4660  {
4661  CHECK(td);
4662  auto& cat = session_info.getCatalog();
4663  std::vector<DBObject> privObjects;
4664  DBObject dbObject(td->tableName, TableDBObjectType);
4665  dbObject.loadKey(cat);
4666  dbObject.setPrivileges(access_priv);
4667  privObjects.push_back(dbObject);
4668  return SysCatalog::instance().checkPrivileges(session_info.get_currentUser(),
4669  privObjects);
4670 };
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 2752 of file ParserNode.cpp.

References ColumnDescriptor::columnType, and kENCODING_DICT.

Referenced by shard_column_index().

2752  {
2753  const auto& col_ti = cd.columnType;
2754  if (!col_ti.is_integer() && !col_ti.is_time() &&
2755  !(col_ti.is_string() && col_ti.get_compression() == kENCODING_DICT)) {
2756  throw std::runtime_error("Cannot shard on type " + col_ti.get_type_name() +
2757  ", encoding " + col_ti.get_compression_name());
2758  }
2759 }
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 3037 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 2996 of file ParserNode.cpp.