OmniSciDB  085a039ca4
 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 (const 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 ( const 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 4083 of file ParserNode.cpp.

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

4087  {}) {
4088  auto calcite_mgr = catalog.getCalciteMgr();
4089  const auto calciteQueryParsingOption =
4090  calcite_mgr->getCalciteQueryParsingOption(true, false, true);
4091  const auto calciteOptimizationOption =
4092  calcite_mgr->getCalciteOptimizationOption(false, g_enable_watchdog, {});
4093  const auto result = calcite_mgr->process(query_state_proxy,
4094  pg_shim(query_str),
4095  calciteQueryParsingOption,
4096  calciteOptimizationOption);
4097  // force sort into tableid order in case of name change to guarantee fixed order of
4098  // mutex access
4099  auto comparator = [&catalog](const std::string& table_1, const std::string& table_2) {
4100  return get_table_id(catalog, table_1) < get_table_id(catalog, table_2);
4101  };
4102  std::set<std::string, decltype(comparator)> tables(comparator);
4103  for (auto& tab : result.resolved_accessed_objects.tables_selected_from) {
4104  tables.emplace(tab[0]);
4105  }
4106  if (insert_table_name.has_value()) {
4107  tables.emplace(insert_table_name.value());
4108  }
4110  for (const auto& table : tables) {
4111  locks.emplace_back(
4114  catalog, table)));
4115  if (insert_table_name.has_value() && table == insert_table_name.value()) {
4116  locks.emplace_back(
4119  catalog.getDatabaseId(), (*locks.back())())));
4120  } else {
4121  locks.emplace_back(
4124  catalog.getDatabaseId(), (*locks.back())())));
4125  }
4126  }
4127  return locks;
4128 }
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:268
std::shared_ptr< Calcite > getCalciteMgr() const
Definition: Catalog.h:230
bool g_enable_watchdog
int getDatabaseId() const
Definition: Catalog.h:284
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 1068 of file ParserNode.cpp.

References Parser::StringLiteral::get_stringval().

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

1068  {
1069  const std::string* s = str_literal->get_stringval();
1070  if (*s == "t" || *s == "true" || *s == "T" || *s == "True") {
1071  return true;
1072  } else if (*s == "f" || *s == "false" || *s == "F" || *s == "False") {
1073  return false;
1074  } else {
1075  throw std::runtime_error("Invalid string for boolean " + *s);
1076  }
1077 }
const std::string * get_stringval() const
Definition: ParserNode.h:136

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Definition at line 4760 of file ParserNode.cpp.

References EMPTY_NAME.

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

4760  {
4761  // Substition map should be clean at end of rename:
4762  // all items in map must (map to self) or (map to EMPTY_STRING) by end
4763 
4764  for (auto it : sMap) {
4765  if ((it.second) != EMPTY_NAME && (it.first) != (it.second)) {
4766  throw std::runtime_error(
4767  "Error: Attempted to overwrite and lose data in table: \'" + (it.first) + "\'");
4768  }
4769  }
4770 }
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 3022 of file ParserNode.cpp.

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

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

3022  {
3023  CHECK(element.HasMember("name"));
3024  auto col_name = std::make_unique<std::string>(json_str(element["name"]));
3025  CHECK(element.HasMember("sqltype"));
3026  const auto sql_types = to_sql_type(json_str(element["sqltype"]));
3027 
3028  // decimal / numeric precision / scale
3029  int precision = -1;
3030  int scale = -1;
3031  if (element.HasMember("precision")) {
3032  precision = json_i64(element["precision"]);
3033  }
3034  if (element.HasMember("scale")) {
3035  scale = json_i64(element["scale"]);
3036  }
3037 
3038  std::optional<int64_t> array_size;
3039  if (element.HasMember("arraySize")) {
3040  // We do not yet support geo arrays
3041  array_size = json_i64(element["arraySize"]);
3042  }
3043  std::unique_ptr<SQLType> sql_type;
3044  if (element.HasMember("subtype")) {
3045  CHECK(element.HasMember("coordinateSystem"));
3046  const auto subtype_sql_types = to_sql_type(json_str(element["subtype"]));
3047  sql_type =
3048  std::make_unique<SQLType>(subtype_sql_types,
3049  static_cast<int>(sql_types),
3050  static_cast<int>(json_i64(element["coordinateSystem"])),
3051  false);
3052  } else if (precision > 0 && scale > 0) {
3053  sql_type = std::make_unique<SQLType>(sql_types,
3054  precision,
3055  scale,
3056  /*is_array=*/array_size.has_value(),
3057  array_size ? *array_size : -1);
3058  } else if (precision > 0) {
3059  sql_type = std::make_unique<SQLType>(sql_types,
3060  precision,
3061  0,
3062  /*is_array=*/array_size.has_value(),
3063  array_size ? *array_size : -1);
3064  } else {
3065  sql_type = std::make_unique<SQLType>(sql_types,
3066  /*is_array=*/array_size.has_value(),
3067  array_size ? *array_size : -1);
3068  }
3069  CHECK(sql_type);
3070 
3071  CHECK(element.HasMember("nullable"));
3072  const auto nullable = json_bool(element["nullable"]);
3073  std::unique_ptr<ColumnConstraintDef> constraint_def;
3074  StringLiteral* str_literal = nullptr;
3075  if (element.HasMember("default") && !element["default"].IsNull()) {
3076  std::string* defaultval = new std::string(json_str(element["default"]));
3077  boost::algorithm::trim_if(*defaultval, boost::is_any_of(" \"'`"));
3078  str_literal = new StringLiteral(defaultval);
3079  }
3080 
3081  constraint_def = std::make_unique<ColumnConstraintDef>(/*notnull=*/!nullable,
3082  /*unique=*/false,
3083  /*primarykey=*/false,
3084  /*defaultval=*/str_literal);
3085  std::unique_ptr<CompressDef> compress_def;
3086  if (element.HasMember("encodingType") && !element["encodingType"].IsNull()) {
3087  std::string encoding_type = json_str(element["encodingType"]);
3088  CHECK(element.HasMember("encodingSize"));
3089  auto encoding_name = std::make_unique<std::string>(json_str(element["encodingType"]));
3090  compress_def = std::make_unique<CompressDef>(encoding_name.release(),
3091  json_i64(element["encodingSize"]));
3092  }
3093  return std::make_unique<ColumnDef>(col_name.release(),
3094  sql_type.release(),
3095  compress_def ? compress_def.release() : nullptr,
3096  constraint_def ? constraint_def.release() : nullptr);
3097 }
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:223

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

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

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

4774  {
4776  throw std::runtime_error(td->tableName + " is a foreign table. " +
4777  "Use ALTER FOREIGN TABLE.");
4778  }
4779 }
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 1602 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().

1602  {
1603  if (expr->get_type_info().get_type() == kNULLT) {
1604  return true;
1605  }
1606  const auto const_expr = dynamic_cast<const Analyzer::Constant*>(expr);
1607  return const_expr && const_expr->get_is_null();
1608 }
bool get_is_null() const
Definition: Analyzer.h:341
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:329
const SQLTypeInfo & get_type_info() const
Definition: Analyzer.h:81

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

References run_benchmark_import::result, and to_string().

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

4725  {
4726  // TODO - is there a "better" way to create a tmp name for the table
4727  std::time_t result = std::time(nullptr);
4728  return name + "_tmp" + std::to_string(result);
4729 }
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 3009 of file ParserNode.cpp.

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

3011  {
3012  const auto it =
3013  dataframeDefFuncMap.find(boost::to_lower_copy<std::string>(*p->get_name()));
3014  if (it == dataframeDefFuncMap.end()) {
3015  throw std::runtime_error(
3016  "Invalid CREATE DATAFRAME option " + *p->get_name() +
3017  ". Should be FRAGMENT_SIZE, MAX_CHUNK_SIZE, SKIP_ROWS, DELIMITER or HEADER.");
3018  }
3019  return it->second(df_td, p.get(), columns);
3020 }
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 2849 of file ParserNode.cpp.

2851  {
2852  return get_property_value<StringLiteral>(p, [&df_td](const auto val) {
2853  if (val.size() != 1) {
2854  throw std::runtime_error("Length of DELIMITER must be equal to 1.");
2855  }
2856  df_td.delimiter = val;
2857  });
2858 }
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 2827 of file ParserNode.cpp.

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

Definition at line 2820 of file ParserNode.cpp.

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

Definition at line 2860 of file ParserNode.cpp.

2862  {
2863  return get_property_value<StringLiteral>(p, [&df_td](const auto val) {
2864  if (val == "FALSE") {
2865  df_td.hasHeader = false;
2866  } else if (val == "TRUE") {
2867  df_td.hasHeader = true;
2868  } else {
2869  throw std::runtime_error("Option HEADER support only 'true' or 'false' values.");
2870  }
2871  });
2872 }
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 2841 of file ParserNode.cpp.

2844  {
2845  return get_property_value<IntLiteral>(
2846  p, [&df_td](const auto val) { df_td.maxChunkSize = val; });
2847 }
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 2834 of file ParserNode.cpp.

2836  {
2837  return get_property_value<IntLiteral>(p,
2838  [&td](const auto val) { td.maxChunkSize = val; });
2839 }
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 2948 of file ParserNode.cpp.

2950  {
2951  auto assignment = [&td](const auto val) {
2952  td.maxRollbackEpochs =
2953  val < 0 ? -1 : val; // Anything < 0 means unlimited rollbacks. Note that 0
2954  // still means keeping a shadow copy of data/metdata
2955  // between epochs so bad writes can be rolled back
2956  };
2957  return get_property_value<IntLiteral, decltype(assignment), PositiveOrZeroValidate>(
2958  p, assignment);
2959 }
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 2880 of file ParserNode.cpp.

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

Definition at line 2874 of file ParserNode.cpp.

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

Definition at line 2893 of file ParserNode.cpp.

2895  {
2896  return get_property_value<StringLiteral>(p, [&td](const auto partitions_uc) {
2897  if (partitions_uc != "SHARDED" && partitions_uc != "REPLICATED") {
2898  throw std::runtime_error("PARTITIONS must be SHARDED or REPLICATED");
2899  }
2900  if (td.shardedColumnId != 0 && partitions_uc == "REPLICATED") {
2901  throw std::runtime_error(
2902  "A table cannot be sharded and replicated at the same time");
2903  };
2904  td.partitions = partitions_uc;
2905  });
2906 }
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 2805 of file ParserNode.cpp.

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

Definition at line 2907 of file ParserNode.cpp.

References g_leaf_count.

2909  {
2910  if (!td.shardedColumnId) {
2911  throw std::runtime_error("SHARD KEY must be defined.");
2912  }
2913  return get_property_value<IntLiteral>(p, [&td](const auto shard_count) {
2914  if (g_leaf_count && shard_count % g_leaf_count) {
2915  throw std::runtime_error(
2916  "SHARD_COUNT must be a multiple of the number of leaves in the cluster.");
2917  }
2918  td.nShards = g_leaf_count ? shard_count / g_leaf_count : shard_count;
2919  if (!td.shardedColumnId && !td.nShards) {
2920  throw std::runtime_error(
2921  "Must specify the number of shards through the SHARD_COUNT option");
2922  };
2923  });
2924 }
size_t g_leaf_count
Definition: ParserNode.cpp:78
decltype(auto) Parser::anonymous_namespace{ParserNode.cpp}::get_skip_rows_def ( DataframeTableDescriptor df_td,
const NameValueAssign *  p,
const std::list< ColumnDescriptor > &  columns 
)

Definition at line 2886 of file ParserNode.cpp.

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

Definition at line 2937 of file ParserNode.cpp.

References sort_column_index().

2939  {
2940  return get_property_value<StringLiteral>(p, [&td, &columns](const auto sort_upper) {
2941  td.sortedColumnId = sort_column_index(sort_upper, columns);
2942  if (!td.sortedColumnId) {
2943  throw std::runtime_error("Specified sort column " + sort_upper + " doesn't exist");
2944  }
2945  });
2946 }
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 2812 of file ParserNode.cpp.

2814  {
2815  auto assignment = [&td](const auto val) { td.storageType = val; };
2816  return get_property_value<StringLiteral, decltype(assignment), CaseSensitiveValidate>(
2817  p, assignment);
2818 }
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 2973 of file ParserNode.cpp.

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

2975  {
2976  const auto it = tableDefFuncMap.find(boost::to_lower_copy<std::string>(*p->get_name()));
2977  if (it == tableDefFuncMap.end()) {
2978  throw std::runtime_error(
2979  "Invalid CREATE TABLE option " + *p->get_name() +
2980  ". Should be FRAGMENT_SIZE, MAX_CHUNK_SIZE, PAGE_SIZE, MAX_ROLLBACK_EPOCHS, "
2981  "MAX_ROWS, "
2982  "PARTITIONS, SHARD_COUNT, VACUUM, SORT_COLUMN, STORAGE_TYPE.");
2983  }
2984  return it->second(td, p.get(), columns);
2985 }
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 2987 of file ParserNode.cpp.

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

2989  {
2990  const auto it = tableDefFuncMap.find(boost::to_lower_copy<std::string>(*p->get_name()));
2991  if (it == tableDefFuncMap.end()) {
2992  throw std::runtime_error(
2993  "Invalid CREATE TABLE AS option " + *p->get_name() +
2994  ". Should be FRAGMENT_SIZE, MAX_CHUNK_SIZE, PAGE_SIZE, MAX_ROLLBACK_EPOCHS, "
2995  "MAX_ROWS, "
2996  "PARTITIONS, SHARD_COUNT, VACUUM, SORT_COLUMN, STORAGE_TYPE or "
2997  "USE_SHARED_DICTIONARIES.");
2998  }
2999  return it->second(td, p.get(), columns);
3000 }
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 4074 of file ParserNode.cpp.

References Catalog_Namespace::Catalog::getTableId().

4075  {
4076  auto table_id = catalog.getTableId(table_name);
4077  if (!table_id.has_value()) {
4078  throw std::runtime_error{"Table \"" + table_name + "\" does not exist."};
4079  }
4080  return table_id.value();
4081 }
std::optional< int32_t > getTableId(const std::string &table_name) const
Definition: Catalog.cpp:1647

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

2928  {
2929  return get_property_value<StringLiteral>(p, [&td](const auto vacuum_uc) {
2930  if (vacuum_uc != "IMMEDIATE" && vacuum_uc != "DELAYED") {
2931  throw std::runtime_error("VACUUM must be IMMEDIATE or DELAYED");
2932  }
2933  td.hasDeletedCol = boost::iequals(vacuum_uc, "IMMEDIATE") ? false : true;
2934  });
2935 }
bool Parser::anonymous_namespace{ParserNode.cpp}::hasData ( SubstituteMap &  sMap,
std::string  tableName 
)

Definition at line 4755 of file ParserNode.cpp.

References EMPTY_NAME.

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

4755  {
4756  // assumes loadTable has been previously called
4757  return (sMap[tableName] != EMPTY_NAME);
4758 }
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 4735 of file ParserNode.cpp.

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

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

4737  {
4738  if (sMap.find(tableName) != sMap.end()) {
4739  if (sMap[tableName] == EMPTY_NAME) {
4740  return tableName;
4741  }
4742  return sMap[tableName];
4743  } else {
4744  // lookup table in src catalog
4745  const TableDescriptor* td = catalog.getMetadataForTable(tableName);
4746  if (td) {
4747  sMap[tableName] = tableName;
4748  } else {
4749  sMap[tableName] = EMPTY_NAME;
4750  }
4751  }
4752  return tableName;
4753 }
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 1079 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::delimiter, 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_reject, import_export::CopyParams::null_str, import_export::CopyParams::odbc_connection_string, import_export::CopyParams::odbc_credential_string, import_export::CopyParams::odbc_dsn, import_export::CopyParams::odbc_password, import_export::CopyParams::odbc_sql_order_by, import_export::CopyParams::odbc_username, 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::threads, and to_string().

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

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

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

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

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

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

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

References CHECK, and parse_insert_literal().

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

2384  {
2385  CHECK(array.IsArray());
2386  auto json_elements = array.GetArray();
2387  auto* elements = new std::list<Expr*>();
2388  for (const auto& e : json_elements) {
2389  elements->push_back(parse_insert_literal(e));
2390  }
2391  return new ArrayLiteral(elements);
2392 }
Literal * parse_insert_literal(const rapidjson::Value &literal)
#define CHECK(condition)
Definition: Logger.h:223

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

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

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

2350  {
2351  CHECK(literal.IsObject());
2352  CHECK(literal.HasMember("literal"));
2353  CHECK(literal.HasMember("type"));
2354  auto type = json_str(literal["type"]);
2355  if (type == "NULL") {
2356  return new NullLiteral();
2357  } else if (type == "CHAR" || type == "BOOLEAN") {
2358  auto* val = new std::string(json_str(literal["literal"]));
2359  return new StringLiteral(val);
2360  } else if (type == "DECIMAL") {
2361  CHECK(literal.HasMember("scale"));
2362  CHECK(literal.HasMember("precision"));
2363  auto scale = json_i64(literal["scale"]);
2364  auto precision = json_i64(literal["precision"]);
2365  if (scale == 0) {
2366  auto int_val = std::stol(json_str(literal["literal"]));
2367  return new IntLiteral(int_val);
2368  } else if (precision > 18) {
2369  auto dbl_val = std::stod(json_str(literal["literal"]));
2370  return new DoubleLiteral(dbl_val);
2371  } else {
2372  auto* val = new std::string(json_str(literal["literal"]));
2373  return new FixedPtLiteral(val);
2374  }
2375  } else if (type == "DOUBLE") {
2376  auto dbl_val = std::stod(json_str(literal["literal"]));
2377  return new DoubleLiteral(dbl_val);
2378  } else {
2379  CHECK(false) << "Unexpected calcite data type: " << type;
2380  }
2381  return nullptr;
2382 }
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:223

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

1975  {
1976  if (payload.HasMember("options") && payload["options"].IsObject()) {
1977  for (const auto& option : payload["options"].GetObject()) {
1978  auto option_name = std::make_unique<std::string>(option.name.GetString());
1979  std::unique_ptr<Literal> literal_value;
1980  if (option.value.IsString()) {
1981  std::string str = option.value.GetString();
1982  if (stringToNull && str == "") {
1983  literal_value = std::make_unique<NullLiteral>();
1984  } else if (stringToInteger && std::all_of(str.begin(), str.end(), ::isdigit)) {
1985  int iVal = std::stoi(str);
1986  literal_value = std::make_unique<IntLiteral>(iVal);
1987  } else {
1988  // Rapidjson will deliberately provide escape'd strings when accessed
1989  // ... but the literal should have a copy of the raw unescaped string
1990  auto unique_literal_string = std::make_unique<std::string>(unescape(str));
1991  literal_value =
1992  std::make_unique<StringLiteral>(unique_literal_string.release());
1993  }
1994  } else if (option.value.IsInt() || option.value.IsInt64()) {
1995  literal_value = std::make_unique<IntLiteral>(json_i64(option.value));
1996  } else if (option.value.IsNull()) {
1997  literal_value = std::make_unique<NullLiteral>();
1998  } else {
1999  throw std::runtime_error("Unable to handle literal for " + *option_name);
2000  }
2001  CHECK(literal_value);
2002 
2003  nameValueList.emplace_back(std::make_unique<NameValueAssign>(
2004  option_name.release(), literal_value.release()));
2005  }
2006  }
2007 }
const int64_t json_i64(const rapidjson::Value &obj) noexcept
Definition: JsonAccessors.h:39
#define CHECK(condition)
Definition: Logger.h:223

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

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

4731  {
4732  sMap[oldName] = newName;
4733 }

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

2774  {
2775  rapidjson::Document document;
2776  auto& allocator = document.GetAllocator();
2777  rapidjson::Value arr(rapidjson::kArrayType);
2778  if (shard_key_def) {
2779  rapidjson::Value shard_key_obj(rapidjson::kObjectType);
2780  set_string_field(shard_key_obj, "type", "SHARD KEY", document);
2781  set_string_field(shard_key_obj, "name", shard_key_def->get_column(), document);
2782  arr.PushBack(shard_key_obj, allocator);
2783  }
2784  for (const auto& shared_dict_def : shared_dict_defs) {
2785  rapidjson::Value shared_dict_obj(rapidjson::kObjectType);
2786  set_string_field(shared_dict_obj, "type", "SHARED DICTIONARY", document);
2787  set_string_field(shared_dict_obj, "name", shared_dict_def.get_column(), document);
2789  shared_dict_obj, "foreign_table", shared_dict_def.get_foreign_table(), document);
2790  set_string_field(shared_dict_obj,
2791  "foreign_column",
2792  shared_dict_def.get_foreign_column(),
2793  document);
2794  arr.PushBack(shared_dict_obj, allocator);
2795  }
2796  rapidjson::StringBuffer buffer;
2797  rapidjson::Writer<rapidjson::StringBuffer> writer(buffer);
2798  arr.Accept(writer);
2799  return buffer.GetString();
2800 }
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 2759 of file ParserNode.cpp.

Referenced by serialize_key_metainfo().

2762  {
2763  rapidjson::Value field_name_json_str;
2764  field_name_json_str.SetString(
2765  field_name.c_str(), field_name.size(), document.GetAllocator());
2766  rapidjson::Value field_value_json_str;
2767  field_value_json_str.SetString(
2768  field_value.c_str(), field_value.size(), document.GetAllocator());
2769  obj.AddMember(field_name_json_str, field_value_json_str, document.GetAllocator());
2770 }

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

References validate_shard_column_type().

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

2727  {
2728  size_t index = 1;
2729  for (const auto& cd : columns) {
2730  if (cd.columnName == name) {
2732  return index;
2733  }
2734  ++index;
2735  if (cd.columnType.is_geometry()) {
2736  index += cd.columnType.get_physical_cols();
2737  }
2738  }
2739  // Not found, return 0
2740  return 0;
2741 }
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 2743 of file ParserNode.cpp.

Referenced by get_sort_column_def().

2744  {
2745  size_t index = 1;
2746  for (const auto& cd : columns) {
2747  if (boost::to_upper_copy<std::string>(cd.columnName) == name) {
2748  return index;
2749  }
2750  ++index;
2751  if (cd.columnType.is_geometry()) {
2752  index += cd.columnType.get_physical_cols();
2753  }
2754  }
2755  // Not found, return 0
2756  return 0;
2757 }
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 1940 of file ParserNode.cpp.

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

1940  {
1941  boost::replace_all(s, "\\\\t", "\t");
1942  boost::replace_all(s, "\\t", "\t");
1943  boost::replace_all(s, "\\\\n", "\n");
1944  boost::replace_all(s, "\\n", "\n");
1945 
1946  // handle numerics
1947  std::smatch m;
1948 
1949  // "\x00"
1950  std::regex e1("(\\\\x[0-9A-Fa-f][0-9A-Fa-f])");
1951  while (std::regex_search(s, m, e1)) {
1952  std::string original(m[0].first, m[0].second);
1953  std::string replacement;
1954  long val = strtol(original.substr(2, 2).c_str(), NULL, 16);
1955  replacement.push_back(val);
1956  boost::replace_all(s, original, replacement);
1957  }
1958 
1959  // "\u0000"
1960  std::regex e2("(\\\\u[0-9A-Fa-f][0-9A-Fa-f][0-9A-Fa-f][0-9A-Fa-f])");
1961  while (std::regex_search(s, m, e2)) {
1962  std::string original(m[0].first, m[0].second);
1963  std::string replacement;
1964  long val = strtol(original.substr(2, 4).c_str(), NULL, 16);
1965  replacement.push_back(val);
1966  boost::replace_all(s, original, replacement);
1967  }
1968 
1969  return s;
1970 }

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

4539  {
4540  CHECK(td);
4541  auto& cat = session_info.getCatalog();
4542  std::vector<DBObject> privObjects;
4543  DBObject dbObject(td->tableName, TableDBObjectType);
4544  dbObject.loadKey(cat);
4545  dbObject.setPrivileges(access_priv);
4546  privObjects.push_back(dbObject);
4547  return SysCatalog::instance().checkPrivileges(session_info.get_currentUser(),
4548  privObjects);
4549 };
std::string cat(Ts &&...args)
std::string tableName
Catalog & getCatalog() const
Definition: SessionInfo.h:65
#define CHECK(condition)
Definition: Logger.h:223
const UserMetadata & get_currentUser() const
Definition: SessionInfo.h:71

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

References ColumnDescriptor::columnType, and kENCODING_DICT.

Referenced by shard_column_index().

2717  {
2718  const auto& col_ti = cd.columnType;
2719  if (!col_ti.is_integer() && !col_ti.is_time() &&
2720  !(col_ti.is_string() && col_ti.get_compression() == kENCODING_DICT)) {
2721  throw std::runtime_error("Cannot shard on type " + col_ti.get_type_name() +
2722  ", encoding " + col_ti.get_compression_name());
2723  }
2724 }
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 3002 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 2961 of file ParserNode.cpp.