OmniSciDB  ca0c39ec8f
 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 4132 of file ParserNode.cpp.

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

4136  {}) {
4137  auto calcite_mgr = catalog.getCalciteMgr();
4138  const auto calciteQueryParsingOption =
4139  calcite_mgr->getCalciteQueryParsingOption(true, false, true);
4140  const auto calciteOptimizationOption = calcite_mgr->getCalciteOptimizationOption(
4141  false, g_enable_watchdog, {}, SysCatalog::instance().isAggregator());
4142  const auto result = calcite_mgr->process(query_state_proxy,
4143  pg_shim(query_str),
4144  calciteQueryParsingOption,
4145  calciteOptimizationOption);
4146  // force sort into tableid order in case of name change to guarantee fixed order of
4147  // mutex access
4148  auto comparator = [&catalog](const std::string& table_1, const std::string& table_2) {
4149  return get_table_id(catalog, table_1) < get_table_id(catalog, table_2);
4150  };
4151  std::set<std::string, decltype(comparator)> tables(comparator);
4152  for (auto& tab : result.resolved_accessed_objects.tables_selected_from) {
4153  tables.emplace(tab[0]);
4154  }
4155  if (insert_table_name.has_value()) {
4156  tables.emplace(insert_table_name.value());
4157  }
4159  for (const auto& table : tables) {
4160  locks.emplace_back(
4163  catalog, table)));
4164  if (insert_table_name.has_value() && table == insert_table_name.value()) {
4165  locks.emplace_back(
4168  catalog.getDatabaseId(), (*locks.back())())));
4169  } else {
4170  locks.emplace_back(
4173  catalog.getDatabaseId(), (*locks.back())())));
4174  }
4175  }
4176  return locks;
4177 }
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:244
bool g_enable_watchdog
int getDatabaseId() const
Definition: Catalog.h:298
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 4868 of file ParserNode.cpp.

References EMPTY_NAME.

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

4868  {
4869  // Substition map should be clean at end of rename:
4870  // all items in map must (map to self) or (map to EMPTY_STRING) by end
4871 
4872  for (auto it : sMap) {
4873  if ((it.second) != EMPTY_NAME && (it.first) != (it.second)) {
4874  throw std::runtime_error(
4875  "Error: Attempted to overwrite and lose data in table: \'" + (it.first) + "\'");
4876  }
4877  }
4878 }
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 3048 of file ParserNode.cpp.

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

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

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

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

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

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

4882  {
4884  throw std::runtime_error(td->tableName + " is a foreign table. " +
4885  "Use ALTER FOREIGN TABLE.");
4886  }
4887 }
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:342
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:379
const SQLTypeInfo & get_type_info() const
Definition: Analyzer.h:82

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

References run_benchmark_import::result, and to_string().

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

4833  {
4834  // TODO - is there a "better" way to create a tmp name for the table
4835  std::time_t result = std::time(nullptr);
4836  return name + "_tmp" + std::to_string(result);
4837 }
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 3035 of file ParserNode.cpp.

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

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

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

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

Definition at line 2846 of file ParserNode.cpp.

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

Definition at line 2886 of file ParserNode.cpp.

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

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

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

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

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

Definition at line 2900 of file ParserNode.cpp.

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

Definition at line 2919 of file ParserNode.cpp.

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

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

Definition at line 2933 of file ParserNode.cpp.

References g_leaf_count.

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

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

Definition at line 2963 of file ParserNode.cpp.

References sort_column_index().

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

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

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

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

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

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

References Catalog_Namespace::Catalog::getTableId().

4124  {
4125  auto table_id = catalog.getTableId(table_name);
4126  if (!table_id.has_value()) {
4127  throw std::runtime_error{"Table \"" + table_name + "\" does not exist."};
4128  }
4129  return table_id.value();
4130 }
std::optional< int32_t > getTableId(const std::string &table_name) const
Definition: Catalog.cpp:1934

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

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

Definition at line 4863 of file ParserNode.cpp.

References EMPTY_NAME.

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

4863  {
4864  // assumes loadTable has been previously called
4865  return (sMap[tableName] != EMPTY_NAME);
4866 }
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 4843 of file ParserNode.cpp.

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

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

4845  {
4846  if (sMap.find(tableName) != sMap.end()) {
4847  if (sMap[tableName] == EMPTY_NAME) {
4848  return tableName;
4849  }
4850  return sMap[tableName];
4851  } else {
4852  // lookup table in src catalog
4853  const TableDescriptor* td = catalog.getMetadataForTable(tableName);
4854  if (td) {
4855  sMap[tableName] = tableName;
4856  } else {
4857  sMap[tableName] = EMPTY_NAME;
4858  }
4859  }
4860  return tableName;
4861 }
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:222
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 3125 of file ParserNode.cpp.

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

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

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

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

References CHECK, and parse_insert_literal().

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

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

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

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

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

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

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

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

4839  {
4840  sMap[oldName] = newName;
4841 }

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

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

Referenced by serialize_key_metainfo().

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

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

References validate_shard_column_type().

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

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

Referenced by get_sort_column_def().

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

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

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

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

4633  {
4634  CHECK(td);
4635  auto& cat = session_info.getCatalog();
4636  std::vector<DBObject> privObjects;
4637  DBObject dbObject(td->tableName, TableDBObjectType);
4638  dbObject.loadKey(cat);
4639  dbObject.setPrivileges(access_priv);
4640  privObjects.push_back(dbObject);
4641  return SysCatalog::instance().checkPrivileges(session_info.get_currentUser(),
4642  privObjects);
4643 };
std::string cat(Ts &&...args)
std::string tableName
Catalog & getCatalog() const
Definition: SessionInfo.h:75
#define CHECK(condition)
Definition: Logger.h:222
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 2743 of file ParserNode.cpp.

References ColumnDescriptor::columnType, and kENCODING_DICT.

Referenced by shard_column_index().

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