OmniSciDB  a987f07e93
 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)
 
int32_t get_table_id (const Catalog_Namespace::Catalog &catalog, const std::string &table_name)
 
lockmgr::LockedTableDescriptors acquire_query_table_locks (Catalog_Namespace::Catalog &catalog, 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)
 

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 ( Catalog_Namespace::Catalog catalog,
const std::string &  query_str,
const QueryStateProxy query_state_proxy,
const std::optional< std::string > &  insert_table_name = {} 
)

Definition at line 4137 of file ParserNode.cpp.

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

4141  {}) {
4142  auto calcite_mgr = catalog.getCalciteMgr();
4143  const auto calciteQueryParsingOption =
4144  calcite_mgr->getCalciteQueryParsingOption(true, false, true);
4145  const auto calciteOptimizationOption = calcite_mgr->getCalciteOptimizationOption(
4146  false, g_enable_watchdog, {}, SysCatalog::instance().isAggregator());
4147  const auto result = calcite_mgr->process(query_state_proxy,
4148  pg_shim(query_str),
4149  calciteQueryParsingOption,
4150  calciteOptimizationOption);
4151  // force sort into tableid order in case of name change to guarantee fixed order of
4152  // mutex access
4153  auto comparator = [&catalog](const std::string& table_1, const std::string& table_2) {
4154  return get_table_id(catalog, table_1) < get_table_id(catalog, table_2);
4155  };
4156  std::set<std::string, decltype(comparator)> tables(comparator);
4157  for (auto& tab : result.resolved_accessed_objects.tables_selected_from) {
4158  tables.emplace(tab[0]);
4159  }
4160  if (insert_table_name.has_value()) {
4161  tables.emplace(insert_table_name.value());
4162  }
4164  for (const auto& table : tables) {
4165  locks.emplace_back(
4168  catalog, table)));
4169  if (insert_table_name.has_value() && table == insert_table_name.value()) {
4170  locks.emplace_back(
4173  catalog.getDatabaseId(), (*locks.back())())));
4174  } else {
4175  locks.emplace_back(
4178  catalog.getDatabaseId(), (*locks.back())())));
4179  }
4180  }
4181  return locks;
4182 }
int32_t get_table_id(const Catalog_Namespace::Catalog &catalog, const std::string &table_name)
std::vector< std::unique_ptr< lockmgr::AbstractLockContainer< const TableDescriptor * >>> LockedTableDescriptors
Definition: LockMgr.h:271
std::shared_ptr< Calcite > getCalciteMgr() const
Definition: Catalog.h:250
bool g_enable_watchdog
int getDatabaseId() const
Definition: Catalog.h:304
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 1067 of file ParserNode.cpp.

References Parser::StringLiteral::get_stringval().

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

1067  {
1068  const std::string* s = str_literal->get_stringval();
1069  if (*s == "t" || *s == "true" || *s == "T" || *s == "True") {
1070  return true;
1071  } else if (*s == "f" || *s == "false" || *s == "F" || *s == "False") {
1072  return false;
1073  } else {
1074  throw std::runtime_error("Invalid string for boolean " + *s);
1075  }
1076 }
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 4876 of file ParserNode.cpp.

References EMPTY_NAME.

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

4876  {
4877  // Substition map should be clean at end of rename:
4878  // all items in map must (map to self) or (map to EMPTY_STRING) by end
4879 
4880  for (auto it : sMap) {
4881  if ((it.second) != EMPTY_NAME && (it.first) != (it.second)) {
4882  throw std::runtime_error(
4883  "Error: Attempted to overwrite and lose data in table: \'" + (it.first) + "\'");
4884  }
4885  }
4886 }
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 3049 of file ParserNode.cpp.

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

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

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

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

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

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

4890  {
4892  throw std::runtime_error(td->tableName + " is a foreign table. " +
4893  "Use ALTER FOREIGN TABLE.");
4894  }
4895 }
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 1620 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().

1620  {
1621  if (expr->get_type_info().get_type() == kNULLT) {
1622  return true;
1623  }
1624  const auto const_expr = dynamic_cast<const Analyzer::Constant*>(expr);
1625  return const_expr && const_expr->get_is_null();
1626 }
bool get_is_null() const
Definition: Analyzer.h:343
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:380
const SQLTypeInfo & get_type_info() const
Definition: Analyzer.h:83

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

References run_benchmark_import::result, and to_string().

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

4841  {
4842  // TODO - is there a "better" way to create a tmp name for the table
4843  std::time_t result = std::time(nullptr);
4844  return name + "_tmp" + std::to_string(result);
4845 }
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 3036 of file ParserNode.cpp.

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

3038  {
3039  const auto it =
3040  dataframeDefFuncMap.find(boost::to_lower_copy<std::string>(*p->get_name()));
3041  if (it == dataframeDefFuncMap.end()) {
3042  throw std::runtime_error(
3043  "Invalid CREATE DATAFRAME option " + *p->get_name() +
3044  ". Should be FRAGMENT_SIZE, MAX_CHUNK_SIZE, SKIP_ROWS, DELIMITER or HEADER.");
3045  }
3046  return it->second(df_td, p.get(), columns);
3047 }
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 2876 of file ParserNode.cpp.

2878  {
2879  return get_property_value<StringLiteral>(p, [&df_td](const auto val) {
2880  if (val.size() != 1) {
2881  throw std::runtime_error("Length of DELIMITER must be equal to 1.");
2882  }
2883  df_td.delimiter = val;
2884  });
2885 }
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 2854 of file ParserNode.cpp.

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

Definition at line 2847 of file ParserNode.cpp.

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

Definition at line 2887 of file ParserNode.cpp.

2889  {
2890  return get_property_value<StringLiteral>(p, [&df_td](const auto val) {
2891  if (val == "FALSE") {
2892  df_td.hasHeader = false;
2893  } else if (val == "TRUE") {
2894  df_td.hasHeader = true;
2895  } else {
2896  throw std::runtime_error("Option HEADER support only 'true' or 'false' values.");
2897  }
2898  });
2899 }
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 2868 of file ParserNode.cpp.

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

2863  {
2864  return get_property_value<IntLiteral>(p,
2865  [&td](const auto val) { td.maxChunkSize = val; });
2866 }
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 2975 of file ParserNode.cpp.

2977  {
2978  auto assignment = [&td](const auto val) {
2979  td.maxRollbackEpochs =
2980  val < 0 ? -1 : val; // Anything < 0 means unlimited rollbacks. Note that 0
2981  // still means keeping a shadow copy of data/metdata
2982  // between epochs so bad writes can be rolled back
2983  };
2984  return get_property_value<IntLiteral, decltype(assignment), PositiveOrZeroValidate>(
2985  p, assignment);
2986 }
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 2907 of file ParserNode.cpp.

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

Definition at line 2901 of file ParserNode.cpp.

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

Definition at line 2920 of file ParserNode.cpp.

2922  {
2923  return get_property_value<StringLiteral>(p, [&td](const auto partitions_uc) {
2924  if (partitions_uc != "SHARDED" && partitions_uc != "REPLICATED") {
2925  throw std::runtime_error("PARTITIONS must be SHARDED or REPLICATED");
2926  }
2927  if (td.shardedColumnId != 0 && partitions_uc == "REPLICATED") {
2928  throw std::runtime_error(
2929  "A table cannot be sharded and replicated at the same time");
2930  };
2931  td.partitions = partitions_uc;
2932  });
2933 }
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 2832 of file ParserNode.cpp.

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

Definition at line 2934 of file ParserNode.cpp.

References g_leaf_count.

2936  {
2937  if (!td.shardedColumnId) {
2938  throw std::runtime_error("SHARD KEY must be defined.");
2939  }
2940  return get_property_value<IntLiteral>(p, [&td](const auto shard_count) {
2941  if (g_leaf_count && shard_count % g_leaf_count) {
2942  throw std::runtime_error(
2943  "SHARD_COUNT must be a multiple of the number of leaves in the cluster.");
2944  }
2945  td.nShards = g_leaf_count ? shard_count / g_leaf_count : shard_count;
2946  if (!td.shardedColumnId && !td.nShards) {
2947  throw std::runtime_error(
2948  "Must specify the number of shards through the SHARD_COUNT option");
2949  };
2950  });
2951 }
size_t g_leaf_count
Definition: ParserNode.cpp:76
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 2913 of file ParserNode.cpp.

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

Definition at line 2964 of file ParserNode.cpp.

References sort_column_index().

2966  {
2967  return get_property_value<StringLiteral>(p, [&td, &columns](const auto sort_upper) {
2968  td.sortedColumnId = sort_column_index(sort_upper, columns);
2969  if (!td.sortedColumnId) {
2970  throw std::runtime_error("Specified sort column " + sort_upper + " doesn't exist");
2971  }
2972  });
2973 }
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 2839 of file ParserNode.cpp.

2841  {
2842  auto assignment = [&td](const auto val) { td.storageType = val; };
2843  return get_property_value<StringLiteral, decltype(assignment), CaseSensitiveValidate>(
2844  p, assignment);
2845 }
std::string storageType
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 3000 of file ParserNode.cpp.

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

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

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

3016  {
3017  const auto it = tableDefFuncMap.find(boost::to_lower_copy<std::string>(*p->get_name()));
3018  if (it == tableDefFuncMap.end()) {
3019  throw std::runtime_error(
3020  "Invalid CREATE TABLE AS option " + *p->get_name() +
3021  ". Should be FRAGMENT_SIZE, MAX_CHUNK_SIZE, PAGE_SIZE, MAX_ROLLBACK_EPOCHS, "
3022  "MAX_ROWS, "
3023  "PARTITIONS, SHARD_COUNT, VACUUM, SORT_COLUMN, STORAGE_TYPE, "
3024  "USE_SHARED_DICTIONARIES or FORCE_GEO_COMPRESSION.");
3025  }
3026  return it->second(td, p.get(), columns);
3027 }
static const std::map< const std::string, const TableDefFuncPtr > tableDefFuncMap

+ Here is the caller graph for this function:

int32_t Parser::anonymous_namespace{ParserNode.cpp}::get_table_id ( const Catalog_Namespace::Catalog catalog,
const std::string &  table_name 
)

Definition at line 4128 of file ParserNode.cpp.

References Catalog_Namespace::Catalog::getTableId().

4129  {
4130  auto table_id = catalog.getTableId(table_name);
4131  if (!table_id.has_value()) {
4132  throw std::runtime_error{"Table \"" + table_name + "\" does not exist."};
4133  }
4134  return table_id.value();
4135 }
std::optional< int32_t > getTableId(const std::string &table_name) const
Definition: Catalog.cpp:1960

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

2955  {
2956  return get_property_value<StringLiteral>(p, [&td](const auto vacuum_uc) {
2957  if (vacuum_uc != "IMMEDIATE" && vacuum_uc != "DELAYED") {
2958  throw std::runtime_error("VACUUM must be IMMEDIATE or DELAYED");
2959  }
2960  td.hasDeletedCol = boost::iequals(vacuum_uc, "IMMEDIATE") ? false : true;
2961  });
2962 }
bool Parser::anonymous_namespace{ParserNode.cpp}::hasData ( SubstituteMap &  sMap,
std::string  tableName 
)

Definition at line 4871 of file ParserNode.cpp.

References EMPTY_NAME.

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

4871  {
4872  // assumes loadTable has been previously called
4873  return (sMap[tableName] != EMPTY_NAME);
4874 }
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 4851 of file ParserNode.cpp.

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

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

4853  {
4854  if (sMap.find(tableName) != sMap.end()) {
4855  if (sMap[tableName] == EMPTY_NAME) {
4856  return tableName;
4857  }
4858  return sMap[tableName];
4859  } else {
4860  // lookup table in src catalog
4861  const TableDescriptor* td = catalog.getMetadataForTable(tableName);
4862  if (td) {
4863  sMap[tableName] = tableName;
4864  } else {
4865  sMap[tableName] = EMPTY_NAME;
4866  }
4867  }
4868  return tableName;
4869 }
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 1078 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().

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

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

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

3129  {
3130  const auto elements = payload[element_name].GetArray();
3131  for (const auto& element : elements) {
3132  CHECK(element.IsObject());
3133  CHECK(element.HasMember("type"));
3134  if (json_str(element["type"]) == "SQL_COLUMN_DECLARATION") {
3135  auto col_def = column_from_json(element);
3136  table_element_list.emplace_back(std::move(col_def));
3137  } else if (json_str(element["type"]) == "SQL_COLUMN_CONSTRAINT") {
3138  CHECK(element.HasMember("name"));
3139  if (json_str(element["name"]) == "SHARD_KEY") {
3140  CHECK(element.HasMember("columns"));
3141  CHECK(element["columns"].IsArray());
3142  const auto& columns = element["columns"].GetArray();
3143  if (columns.Size() != size_t(1)) {
3144  throw std::runtime_error("Only one shard column is currently supported.");
3145  }
3146  auto shard_key_def = std::make_unique<ShardKeyDef>(json_str(columns[0]));
3147  table_element_list.emplace_back(std::move(shard_key_def));
3148  } else if (json_str(element["name"]) == "SHARED_DICT") {
3149  CHECK(element.HasMember("columns"));
3150  CHECK(element["columns"].IsArray());
3151  const auto& columns = element["columns"].GetArray();
3152  if (columns.Size() != size_t(1)) {
3153  throw std::runtime_error(
3154  R"(Only one column per shared dictionary entry is currently supported. Use multiple SHARED DICT statements to share dictionaries from multiple columns.)");
3155  }
3156  CHECK(element.HasMember("references") && element["references"].IsObject());
3157  const auto& references = element["references"].GetObject();
3158  std::string references_table_name;
3159  if (references.HasMember("table")) {
3160  references_table_name = json_str(references["table"]);
3161  } else {
3162  references_table_name = table_name;
3163  }
3164  CHECK(references.HasMember("column"));
3165 
3166  auto shared_dict_def = std::make_unique<SharedDictionaryDef>(
3167  json_str(columns[0]), references_table_name, json_str(references["column"]));
3168  table_element_list.emplace_back(std::move(shared_dict_def));
3169 
3170  } else {
3171  LOG(FATAL) << "Unsupported type for SQL_COLUMN_CONSTRAINT: "
3172  << json_str(element["name"]);
3173  }
3174  } else {
3175  LOG(FATAL) << "Unsupported element type for CREATE TABLE: "
3176  << element["type"].GetString();
3177  }
3178  }
3179 }
#define LOG(tag)
Definition: Logger.h:283
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:289

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

References CHECK, and parse_insert_literal().

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

2404  {
2405  CHECK(array.IsArray());
2406  auto json_elements = array.GetArray();
2407  auto* elements = new std::list<Expr*>();
2408  for (const auto& e : json_elements) {
2409  elements->push_back(parse_insert_literal(e));
2410  }
2411  return new ArrayLiteral(elements);
2412 }
Literal * parse_insert_literal(const rapidjson::Value &literal)
#define CHECK(condition)
Definition: Logger.h:289

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

2370  {
2371  CHECK(literal.IsObject());
2372  CHECK(literal.HasMember("literal"));
2373  CHECK(literal.HasMember("type"));
2374  auto type = json_str(literal["type"]);
2375  if (type == "NULL") {
2376  return new NullLiteral();
2377  } else if (type == "CHAR" || type == "BOOLEAN") {
2378  auto* val = new std::string(json_str(literal["literal"]));
2379  return new StringLiteral(val);
2380  } else if (type == "DECIMAL") {
2381  CHECK(literal.HasMember("scale"));
2382  CHECK(literal.HasMember("precision"));
2383  auto scale = json_i64(literal["scale"]);
2384  auto precision = json_i64(literal["precision"]);
2385  if (scale == 0) {
2386  auto int_val = std::stol(json_str(literal["literal"]));
2387  return new IntLiteral(int_val);
2388  } else if (precision > sql_constants::kMaxNumericPrecision) {
2389  auto dbl_val = std::stod(json_str(literal["literal"]));
2390  return new DoubleLiteral(dbl_val);
2391  } else {
2392  auto* val = new std::string(json_str(literal["literal"]));
2393  return new FixedPtLiteral(val);
2394  }
2395  } else if (type == "DOUBLE") {
2396  auto dbl_val = std::stod(json_str(literal["literal"]));
2397  return new DoubleLiteral(dbl_val);
2398  } else {
2399  CHECK(false) << "Unexpected calcite data type: " << type;
2400  }
2401  return nullptr;
2402 }
static constexpr int32_t kMaxNumericPrecision
Definition: sqltypes.h:46
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:289

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

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

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

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

4847  {
4848  sMap[oldName] = newName;
4849 }

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

2801  {
2802  rapidjson::Document document;
2803  auto& allocator = document.GetAllocator();
2804  rapidjson::Value arr(rapidjson::kArrayType);
2805  if (shard_key_def) {
2806  rapidjson::Value shard_key_obj(rapidjson::kObjectType);
2807  set_string_field(shard_key_obj, "type", "SHARD KEY", document);
2808  set_string_field(shard_key_obj, "name", shard_key_def->get_column(), document);
2809  arr.PushBack(shard_key_obj, allocator);
2810  }
2811  for (const auto& shared_dict_def : shared_dict_defs) {
2812  rapidjson::Value shared_dict_obj(rapidjson::kObjectType);
2813  set_string_field(shared_dict_obj, "type", "SHARED DICTIONARY", document);
2814  set_string_field(shared_dict_obj, "name", shared_dict_def.get_column(), document);
2816  shared_dict_obj, "foreign_table", shared_dict_def.get_foreign_table(), document);
2817  set_string_field(shared_dict_obj,
2818  "foreign_column",
2819  shared_dict_def.get_foreign_column(),
2820  document);
2821  arr.PushBack(shared_dict_obj, allocator);
2822  }
2823  rapidjson::StringBuffer buffer;
2824  rapidjson::Writer<rapidjson::StringBuffer> writer(buffer);
2825  arr.Accept(writer);
2826  return buffer.GetString();
2827 }
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 2786 of file ParserNode.cpp.

Referenced by serialize_key_metainfo().

2789  {
2790  rapidjson::Value field_name_json_str;
2791  field_name_json_str.SetString(
2792  field_name.c_str(), field_name.size(), document.GetAllocator());
2793  rapidjson::Value field_value_json_str;
2794  field_value_json_str.SetString(
2795  field_value.c_str(), field_value.size(), document.GetAllocator());
2796  obj.AddMember(field_name_json_str, field_value_json_str, document.GetAllocator());
2797 }

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

References validate_shard_column_type().

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

2754  {
2755  size_t index = 1;
2756  for (const auto& cd : columns) {
2757  if (cd.columnName == name) {
2759  return index;
2760  }
2761  ++index;
2762  if (cd.columnType.is_geometry()) {
2763  index += cd.columnType.get_physical_cols();
2764  }
2765  }
2766  // Not found, return 0
2767  return 0;
2768 }
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 2770 of file ParserNode.cpp.

Referenced by get_sort_column_def().

2771  {
2772  size_t index = 1;
2773  for (const auto& cd : columns) {
2774  if (boost::to_upper_copy<std::string>(cd.columnName) == name) {
2775  return index;
2776  }
2777  ++index;
2778  if (cd.columnType.is_geometry()) {
2779  index += cd.columnType.get_physical_cols();
2780  }
2781  }
2782  // Not found, return 0
2783  return 0;
2784 }
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 1959 of file ParserNode.cpp.

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

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

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

4641  {
4642  CHECK(td);
4643  auto& cat = session_info.getCatalog();
4644  std::vector<DBObject> privObjects;
4645  DBObject dbObject(td->tableName, TableDBObjectType);
4646  dbObject.loadKey(cat);
4647  dbObject.setPrivileges(access_priv);
4648  privObjects.push_back(dbObject);
4649  return SysCatalog::instance().checkPrivileges(session_info.get_currentUser(),
4650  privObjects);
4651 };
std::string cat(Ts &&...args)
std::string tableName
Catalog & getCatalog() const
Definition: SessionInfo.h:75
#define CHECK(condition)
Definition: Logger.h:289
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 2744 of file ParserNode.cpp.

References ColumnDescriptor::columnType, and kENCODING_DICT.

Referenced by shard_column_index().

2744  {
2745  const auto& col_ti = cd.columnType;
2746  if (!col_ti.is_integer() && !col_ti.is_time() &&
2747  !(col_ti.is_string() && col_ti.get_compression() == kENCODING_DICT)) {
2748  throw std::runtime_error("Cannot shard on type " + col_ti.get_type_name() +
2749  ", encoding " + col_ti.get_compression_name());
2750  }
2751 }
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 3029 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 2988 of file ParserNode.cpp.