OmniSciDB  cde582ebc3
 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 4104 of file ParserNode.cpp.

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

4108  {}) {
4109  auto calcite_mgr = catalog.getCalciteMgr();
4110  const auto calciteQueryParsingOption =
4111  calcite_mgr->getCalciteQueryParsingOption(true, false, true);
4112  const auto calciteOptimizationOption =
4113  calcite_mgr->getCalciteOptimizationOption(false, g_enable_watchdog, {});
4114  const auto result = calcite_mgr->process(query_state_proxy,
4115  pg_shim(query_str),
4116  calciteQueryParsingOption,
4117  calciteOptimizationOption);
4118  // force sort into tableid order in case of name change to guarantee fixed order of
4119  // mutex access
4120  auto comparator = [&catalog](const std::string& table_1, const std::string& table_2) {
4121  return get_table_id(catalog, table_1) < get_table_id(catalog, table_2);
4122  };
4123  std::set<std::string, decltype(comparator)> tables(comparator);
4124  for (auto& tab : result.resolved_accessed_objects.tables_selected_from) {
4125  tables.emplace(tab[0]);
4126  }
4127  if (insert_table_name.has_value()) {
4128  tables.emplace(insert_table_name.value());
4129  }
4131  for (const auto& table : tables) {
4132  locks.emplace_back(
4135  catalog, table)));
4136  if (insert_table_name.has_value() && table == insert_table_name.value()) {
4137  locks.emplace_back(
4140  catalog.getDatabaseId(), (*locks.back())())));
4141  } else {
4142  locks.emplace_back(
4145  catalog.getDatabaseId(), (*locks.back())())));
4146  }
4147  }
4148  return locks;
4149 }
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 4817 of file ParserNode.cpp.

References EMPTY_NAME.

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

4817  {
4818  // Substition map should be clean at end of rename:
4819  // all items in map must (map to self) or (map to EMPTY_STRING) by end
4820 
4821  for (auto it : sMap) {
4822  if ((it.second) != EMPTY_NAME && (it.first) != (it.second)) {
4823  throw std::runtime_error(
4824  "Error: Attempted to overwrite and lose data in table: \'" + (it.first) + "\'");
4825  }
4826  }
4827 }
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 3033 of file ParserNode.cpp.

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

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

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

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

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

4831  {
4833  throw std::runtime_error(td->tableName + " is a foreign table. " +
4834  "Use ALTER FOREIGN TABLE.");
4835  }
4836 }
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 1608 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().

1608  {
1609  if (expr->get_type_info().get_type() == kNULLT) {
1610  return true;
1611  }
1612  const auto const_expr = dynamic_cast<const Analyzer::Constant*>(expr);
1613  return const_expr && const_expr->get_is_null();
1614 }
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 4782 of file ParserNode.cpp.

References run_benchmark_import::result, and to_string().

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

4782  {
4783  // TODO - is there a "better" way to create a tmp name for the table
4784  std::time_t result = std::time(nullptr);
4785  return name + "_tmp" + std::to_string(result);
4786 }
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 3020 of file ParserNode.cpp.

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

3022  {
3023  const auto it =
3024  dataframeDefFuncMap.find(boost::to_lower_copy<std::string>(*p->get_name()));
3025  if (it == dataframeDefFuncMap.end()) {
3026  throw std::runtime_error(
3027  "Invalid CREATE DATAFRAME option " + *p->get_name() +
3028  ". Should be FRAGMENT_SIZE, MAX_CHUNK_SIZE, SKIP_ROWS, DELIMITER or HEADER.");
3029  }
3030  return it->second(df_td, p.get(), columns);
3031 }
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 2860 of file ParserNode.cpp.

2862  {
2863  return get_property_value<StringLiteral>(p, [&df_td](const auto val) {
2864  if (val.size() != 1) {
2865  throw std::runtime_error("Length of DELIMITER must be equal to 1.");
2866  }
2867  df_td.delimiter = val;
2868  });
2869 }
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 2838 of file ParserNode.cpp.

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

Definition at line 2831 of file ParserNode.cpp.

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

Definition at line 2871 of file ParserNode.cpp.

2873  {
2874  return get_property_value<StringLiteral>(p, [&df_td](const auto val) {
2875  if (val == "FALSE") {
2876  df_td.hasHeader = false;
2877  } else if (val == "TRUE") {
2878  df_td.hasHeader = true;
2879  } else {
2880  throw std::runtime_error("Option HEADER support only 'true' or 'false' values.");
2881  }
2882  });
2883 }
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 2852 of file ParserNode.cpp.

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

2847  {
2848  return get_property_value<IntLiteral>(p,
2849  [&td](const auto val) { td.maxChunkSize = val; });
2850 }
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 2959 of file ParserNode.cpp.

2961  {
2962  auto assignment = [&td](const auto val) {
2963  td.maxRollbackEpochs =
2964  val < 0 ? -1 : val; // Anything < 0 means unlimited rollbacks. Note that 0
2965  // still means keeping a shadow copy of data/metdata
2966  // between epochs so bad writes can be rolled back
2967  };
2968  return get_property_value<IntLiteral, decltype(assignment), PositiveOrZeroValidate>(
2969  p, assignment);
2970 }
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 2891 of file ParserNode.cpp.

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

Definition at line 2885 of file ParserNode.cpp.

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

Definition at line 2904 of file ParserNode.cpp.

2906  {
2907  return get_property_value<StringLiteral>(p, [&td](const auto partitions_uc) {
2908  if (partitions_uc != "SHARDED" && partitions_uc != "REPLICATED") {
2909  throw std::runtime_error("PARTITIONS must be SHARDED or REPLICATED");
2910  }
2911  if (td.shardedColumnId != 0 && partitions_uc == "REPLICATED") {
2912  throw std::runtime_error(
2913  "A table cannot be sharded and replicated at the same time");
2914  };
2915  td.partitions = partitions_uc;
2916  });
2917 }
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 2816 of file ParserNode.cpp.

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

Definition at line 2918 of file ParserNode.cpp.

References g_leaf_count.

2920  {
2921  if (!td.shardedColumnId) {
2922  throw std::runtime_error("SHARD KEY must be defined.");
2923  }
2924  return get_property_value<IntLiteral>(p, [&td](const auto shard_count) {
2925  if (g_leaf_count && shard_count % g_leaf_count) {
2926  throw std::runtime_error(
2927  "SHARD_COUNT must be a multiple of the number of leaves in the cluster.");
2928  }
2929  td.nShards = g_leaf_count ? shard_count / g_leaf_count : shard_count;
2930  if (!td.shardedColumnId && !td.nShards) {
2931  throw std::runtime_error(
2932  "Must specify the number of shards through the SHARD_COUNT option");
2933  };
2934  });
2935 }
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 2897 of file ParserNode.cpp.

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

Definition at line 2948 of file ParserNode.cpp.

References sort_column_index().

2950  {
2951  return get_property_value<StringLiteral>(p, [&td, &columns](const auto sort_upper) {
2952  td.sortedColumnId = sort_column_index(sort_upper, columns);
2953  if (!td.sortedColumnId) {
2954  throw std::runtime_error("Specified sort column " + sort_upper + " doesn't exist");
2955  }
2956  });
2957 }
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 2823 of file ParserNode.cpp.

2825  {
2826  auto assignment = [&td](const auto val) { td.storageType = val; };
2827  return get_property_value<StringLiteral, decltype(assignment), CaseSensitiveValidate>(
2828  p, assignment);
2829 }
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 2984 of file ParserNode.cpp.

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

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

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

3000  {
3001  const auto it = tableDefFuncMap.find(boost::to_lower_copy<std::string>(*p->get_name()));
3002  if (it == tableDefFuncMap.end()) {
3003  throw std::runtime_error(
3004  "Invalid CREATE TABLE AS option " + *p->get_name() +
3005  ". Should be FRAGMENT_SIZE, MAX_CHUNK_SIZE, PAGE_SIZE, MAX_ROLLBACK_EPOCHS, "
3006  "MAX_ROWS, "
3007  "PARTITIONS, SHARD_COUNT, VACUUM, SORT_COLUMN, STORAGE_TYPE or "
3008  "USE_SHARED_DICTIONARIES.");
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:

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

Definition at line 4095 of file ParserNode.cpp.

References Catalog_Namespace::Catalog::getTableId().

4096  {
4097  auto table_id = catalog.getTableId(table_name);
4098  if (!table_id.has_value()) {
4099  throw std::runtime_error{"Table \"" + table_name + "\" does not exist."};
4100  }
4101  return table_id.value();
4102 }
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 2937 of file ParserNode.cpp.

2939  {
2940  return get_property_value<StringLiteral>(p, [&td](const auto vacuum_uc) {
2941  if (vacuum_uc != "IMMEDIATE" && vacuum_uc != "DELAYED") {
2942  throw std::runtime_error("VACUUM must be IMMEDIATE or DELAYED");
2943  }
2944  td.hasDeletedCol = boost::iequals(vacuum_uc, "IMMEDIATE") ? false : true;
2945  });
2946 }
bool Parser::anonymous_namespace{ParserNode.cpp}::hasData ( SubstituteMap &  sMap,
std::string  tableName 
)

Definition at line 4812 of file ParserNode.cpp.

References EMPTY_NAME.

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

4812  {
4813  // assumes loadTable has been previously called
4814  return (sMap[tableName] != EMPTY_NAME);
4815 }
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 4792 of file ParserNode.cpp.

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

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

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

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

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

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

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

References CHECK, and parse_insert_literal().

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

2390  {
2391  CHECK(array.IsArray());
2392  auto json_elements = array.GetArray();
2393  auto* elements = new std::list<Expr*>();
2394  for (const auto& e : json_elements) {
2395  elements->push_back(parse_insert_literal(e));
2396  }
2397  return new ArrayLiteral(elements);
2398 }
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 2356 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().

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

1981  {
1982  if (payload.HasMember("options") && payload["options"].IsObject()) {
1983  for (const auto& option : payload["options"].GetObject()) {
1984  auto option_name = std::make_unique<std::string>(option.name.GetString());
1985  std::unique_ptr<Literal> literal_value;
1986  if (option.value.IsString()) {
1987  std::string str = option.value.GetString();
1988  if (stringToNull && str == "") {
1989  literal_value = std::make_unique<NullLiteral>();
1990  } else if (stringToInteger && std::all_of(str.begin(), str.end(), ::isdigit)) {
1991  int iVal = std::stoi(str);
1992  literal_value = std::make_unique<IntLiteral>(iVal);
1993  } else {
1994  // Rapidjson will deliberately provide escape'd strings when accessed
1995  // ... but the literal should have a copy of the raw unescaped string
1996  auto unique_literal_string = std::make_unique<std::string>(unescape(str));
1997  literal_value =
1998  std::make_unique<StringLiteral>(unique_literal_string.release());
1999  }
2000  } else if (option.value.IsInt() || option.value.IsInt64()) {
2001  literal_value = std::make_unique<IntLiteral>(json_i64(option.value));
2002  } else if (option.value.IsNull()) {
2003  literal_value = std::make_unique<NullLiteral>();
2004  } else {
2005  throw std::runtime_error("Unable to handle literal for " + *option_name);
2006  }
2007  CHECK(literal_value);
2008 
2009  nameValueList.emplace_back(std::make_unique<NameValueAssign>(
2010  option_name.release(), literal_value.release()));
2011  }
2012  }
2013 }
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 4788 of file ParserNode.cpp.

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

4788  {
4789  sMap[oldName] = newName;
4790 }

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

2785  {
2786  rapidjson::Document document;
2787  auto& allocator = document.GetAllocator();
2788  rapidjson::Value arr(rapidjson::kArrayType);
2789  if (shard_key_def) {
2790  rapidjson::Value shard_key_obj(rapidjson::kObjectType);
2791  set_string_field(shard_key_obj, "type", "SHARD KEY", document);
2792  set_string_field(shard_key_obj, "name", shard_key_def->get_column(), document);
2793  arr.PushBack(shard_key_obj, allocator);
2794  }
2795  for (const auto& shared_dict_def : shared_dict_defs) {
2796  rapidjson::Value shared_dict_obj(rapidjson::kObjectType);
2797  set_string_field(shared_dict_obj, "type", "SHARED DICTIONARY", document);
2798  set_string_field(shared_dict_obj, "name", shared_dict_def.get_column(), document);
2800  shared_dict_obj, "foreign_table", shared_dict_def.get_foreign_table(), document);
2801  set_string_field(shared_dict_obj,
2802  "foreign_column",
2803  shared_dict_def.get_foreign_column(),
2804  document);
2805  arr.PushBack(shared_dict_obj, allocator);
2806  }
2807  rapidjson::StringBuffer buffer;
2808  rapidjson::Writer<rapidjson::StringBuffer> writer(buffer);
2809  arr.Accept(writer);
2810  return buffer.GetString();
2811 }
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 2770 of file ParserNode.cpp.

Referenced by serialize_key_metainfo().

2773  {
2774  rapidjson::Value field_name_json_str;
2775  field_name_json_str.SetString(
2776  field_name.c_str(), field_name.size(), document.GetAllocator());
2777  rapidjson::Value field_value_json_str;
2778  field_value_json_str.SetString(
2779  field_value.c_str(), field_value.size(), document.GetAllocator());
2780  obj.AddMember(field_name_json_str, field_value_json_str, document.GetAllocator());
2781 }

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

References validate_shard_column_type().

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

2738  {
2739  size_t index = 1;
2740  for (const auto& cd : columns) {
2741  if (cd.columnName == name) {
2743  return index;
2744  }
2745  ++index;
2746  if (cd.columnType.is_geometry()) {
2747  index += cd.columnType.get_physical_cols();
2748  }
2749  }
2750  // Not found, return 0
2751  return 0;
2752 }
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 2754 of file ParserNode.cpp.

Referenced by get_sort_column_def().

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

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

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

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

4582  {
4583  CHECK(td);
4584  auto& cat = session_info.getCatalog();
4585  std::vector<DBObject> privObjects;
4586  DBObject dbObject(td->tableName, TableDBObjectType);
4587  dbObject.loadKey(cat);
4588  dbObject.setPrivileges(access_priv);
4589  privObjects.push_back(dbObject);
4590  return SysCatalog::instance().checkPrivileges(session_info.get_currentUser(),
4591  privObjects);
4592 };
std::string cat(Ts &&...args)
std::string tableName
Catalog & getCatalog() const
Definition: SessionInfo.h:65
#define CHECK(condition)
Definition: Logger.h:222
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 2728 of file ParserNode.cpp.

References ColumnDescriptor::columnType, and kENCODING_DICT.

Referenced by shard_column_index().

2728  {
2729  const auto& col_ti = cd.columnType;
2730  if (!col_ti.is_integer() && !col_ti.is_time() &&
2731  !(col_ti.is_string() && col_ti.get_compression() == kENCODING_DICT)) {
2732  throw std::runtime_error("Cannot shard on type " + col_ti.get_type_name() +
2733  ", encoding " + col_ti.get_compression_name());
2734  }
2735 }
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 3013 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 2972 of file ParserNode.cpp.