OmniSciDB  21ac014ffc
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Parser::anonymous_namespace{ParserNode.cpp} Namespace Reference

Functions

bool expr_is_null (const Analyzer::Expr *expr)
 
bool bool_from_string_literal (const Parser::StringLiteral *str_literal)
 
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)
 
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)
 

Variables

static const std::map< const
std::string, const
TableDefFuncPtr
tableDefFuncMap
 
static const std::map< const
std::string, const
DataframeDefFuncPtr
dataframeDefFuncMap
 
static constexpr char constEMPTY_NAME {""}
 

Function Documentation

bool Parser::anonymous_namespace{ParserNode.cpp}::bool_from_string_literal ( const Parser::StringLiteral str_literal)

Definition at line 922 of file ParserNode.cpp.

References Parser::StringLiteral::get_stringval().

Referenced by Parser::CopyTableStmt::execute(), and Parser::ExportQueryStmt::parseOptions().

922  {
923  const std::string* s = str_literal->get_stringval();
924  if (*s == "t" || *s == "true" || *s == "T" || *s == "True") {
925  return true;
926  } else if (*s == "f" || *s == "false" || *s == "F" || *s == "False") {
927  return false;
928  } else {
929  throw std::runtime_error("Invalid string for boolean " + *s);
930  }
931 }
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 3974 of file ParserNode.cpp.

References EMPTY_NAME.

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

3974  {
3975  // Substition map should be clean at end of rename:
3976  // all items in map must (map to self) or (map to EMPTY_STRING) by end
3977 
3978  for (auto it : sMap) {
3979  if ((it.second) != EMPTY_NAME && (it.first) != (it.second)) {
3980  throw std::runtime_error(
3981  "Error: Attempted to overwrite and lose data in table: \'" + (it.first) + "\'");
3982  }
3983  }
3984 }
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 2264 of file ParserNode.cpp.

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

Referenced by Parser::CreateTableStmt::CreateTableStmt(), and Parser::AlterTableStmt::delegateExecute().

2264  {
2265  CHECK(element.HasMember("name"));
2266  auto col_name = std::make_unique<std::string>(json_str(element["name"]));
2267  CHECK(element.HasMember("sqltype"));
2268  const auto sql_types = to_sql_type(json_str(element["sqltype"]));
2269 
2270  // decimal / numeric precision / scale
2271  int precision = -1;
2272  int scale = -1;
2273  if (element.HasMember("precision")) {
2274  precision = json_i64(element["precision"]);
2275  }
2276  if (element.HasMember("scale")) {
2277  scale = json_i64(element["scale"]);
2278  }
2279 
2280  std::optional<int64_t> array_size;
2281  if (element.HasMember("arraySize")) {
2282  // We do not yet support geo arrays
2283  array_size = json_i64(element["arraySize"]);
2284  }
2285  std::unique_ptr<SQLType> sql_type;
2286  if (element.HasMember("subtype")) {
2287  CHECK(element.HasMember("coordinateSystem"));
2288  const auto subtype_sql_types = to_sql_type(json_str(element["subtype"]));
2289  sql_type =
2290  std::make_unique<SQLType>(subtype_sql_types,
2291  static_cast<int>(sql_types),
2292  static_cast<int>(json_i64(element["coordinateSystem"])),
2293  false);
2294  } else if (precision > 0 && scale > 0) {
2295  sql_type = std::make_unique<SQLType>(sql_types,
2296  precision,
2297  scale,
2298  /*is_array=*/array_size.has_value(),
2299  array_size ? *array_size : -1);
2300  } else if (precision > 0) {
2301  sql_type = std::make_unique<SQLType>(sql_types,
2302  precision,
2303  0,
2304  /*is_array=*/array_size.has_value(),
2305  array_size ? *array_size : -1);
2306  } else {
2307  sql_type = std::make_unique<SQLType>(sql_types,
2308  /*is_array=*/array_size.has_value(),
2309  array_size ? *array_size : -1);
2310  }
2311  CHECK(sql_type);
2312 
2313  CHECK(element.HasMember("nullable"));
2314  const auto nullable = json_bool(element["nullable"]);
2315  std::unique_ptr<ColumnConstraintDef> constraint_def;
2316  StringLiteral* str_literal = nullptr;
2317  if (element.HasMember("default") && !element["default"].IsNull()) {
2318  std::string* defaultval = new std::string(json_str(element["default"]));
2319  boost::algorithm::trim_if(*defaultval, boost::is_any_of(" \"'`"));
2320  str_literal = new StringLiteral(defaultval);
2321  }
2322 
2323  constraint_def = std::make_unique<ColumnConstraintDef>(/*notnull=*/!nullable,
2324  /*unique=*/false,
2325  /*primarykey=*/false,
2326  /*defaultval=*/str_literal);
2327  std::unique_ptr<CompressDef> compress_def;
2328  if (element.HasMember("encodingType") && !element["encodingType"].IsNull()) {
2329  std::string encoding_type = json_str(element["encodingType"]);
2330  CHECK(element.HasMember("encodingSize"));
2331  auto encoding_name = std::make_unique<std::string>(json_str(element["encodingType"]));
2332  compress_def = std::make_unique<CompressDef>(encoding_name.release(),
2333  json_i64(element["encodingSize"]));
2334  }
2335  return std::make_unique<ColumnDef>(col_name.release(),
2336  sql_type.release(),
2337  compress_def ? compress_def.release() : nullptr,
2338  constraint_def ? constraint_def.release() : nullptr);
2339 }
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:206

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool Parser::anonymous_namespace{ParserNode.cpp}::expr_is_null ( const Analyzer::Expr expr)

Definition at line 914 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().

914  {
915  if (expr->get_type_info().get_type() == kNULLT) {
916  return true;
917  }
918  const auto const_expr = dynamic_cast<const Analyzer::Constant*>(expr);
919  return const_expr && const_expr->get_is_null();
920 }
bool get_is_null() const
Definition: Analyzer.h:334
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:323
const SQLTypeInfo & get_type_info() const
Definition: Analyzer.h:78

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

References run_benchmark_import::result, and to_string().

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

3940  {
3941  // TODO - is there a "better" way to create a tmp name for the table
3942  std::time_t result = std::time(nullptr);
3943  return name + "_tmp" + std::to_string(result);
3944 }
string name
Definition: setup.in.py:72
std::string to_string(char const *&&v)

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

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

2253  {
2254  const auto it =
2255  dataframeDefFuncMap.find(boost::to_lower_copy<std::string>(*p->get_name()));
2256  if (it == dataframeDefFuncMap.end()) {
2257  throw std::runtime_error(
2258  "Invalid CREATE DATAFRAME option " + *p->get_name() +
2259  ". Should be FRAGMENT_SIZE, MAX_CHUNK_SIZE, SKIP_ROWS, DELIMITER or HEADER.");
2260  }
2261  return it->second(df_td, p.get(), columns);
2262 }
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 2091 of file ParserNode.cpp.

2093  {
2094  return get_property_value<StringLiteral>(p, [&df_td](const auto val) {
2095  if (val.size() != 1) {
2096  throw std::runtime_error("Length of DELIMITER must be equal to 1.");
2097  }
2098  df_td.delimiter = val;
2099  });
2100 }
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 2069 of file ParserNode.cpp.

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

Definition at line 2062 of file ParserNode.cpp.

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

Definition at line 2102 of file ParserNode.cpp.

2104  {
2105  return get_property_value<StringLiteral>(p, [&df_td](const auto val) {
2106  if (val == "FALSE") {
2107  df_td.hasHeader = false;
2108  } else if (val == "TRUE") {
2109  df_td.hasHeader = true;
2110  } else {
2111  throw std::runtime_error("Option HEADER support only 'true' or 'false' values.");
2112  }
2113  });
2114 }
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 2083 of file ParserNode.cpp.

2086  {
2087  return get_property_value<IntLiteral>(
2088  p, [&df_td](const auto val) { df_td.maxChunkSize = val; });
2089 }
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 2076 of file ParserNode.cpp.

2078  {
2079  return get_property_value<IntLiteral>(p,
2080  [&td](const auto val) { td.maxChunkSize = val; });
2081 }
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 2190 of file ParserNode.cpp.

2192  {
2193  auto assignment = [&td](const auto val) {
2194  td.maxRollbackEpochs =
2195  val < 0 ? -1 : val; // Anything < 0 means unlimited rollbacks. Note that 0
2196  // still means keeping a shadow copy of data/metdata
2197  // between epochs so bad writes can be rolled back
2198  };
2199  return get_property_value<IntLiteral, decltype(assignment), PositiveOrZeroValidate>(
2200  p, assignment);
2201 }
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 2122 of file ParserNode.cpp.

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

Definition at line 2116 of file ParserNode.cpp.

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

Definition at line 2135 of file ParserNode.cpp.

2137  {
2138  return get_property_value<StringLiteral>(p, [&td](const auto partitions_uc) {
2139  if (partitions_uc != "SHARDED" && partitions_uc != "REPLICATED") {
2140  throw std::runtime_error("PARTITIONS must be SHARDED or REPLICATED");
2141  }
2142  if (td.shardedColumnId != 0 && partitions_uc == "REPLICATED") {
2143  throw std::runtime_error(
2144  "A table cannot be sharded and replicated at the same time");
2145  };
2146  td.partitions = partitions_uc;
2147  });
2148 }
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 2047 of file ParserNode.cpp.

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

Definition at line 2149 of file ParserNode.cpp.

References g_leaf_count.

2151  {
2152  if (!td.shardedColumnId) {
2153  throw std::runtime_error("SHARD KEY must be defined.");
2154  }
2155  return get_property_value<IntLiteral>(p, [&td](const auto shard_count) {
2156  if (g_leaf_count && shard_count % g_leaf_count) {
2157  throw std::runtime_error(
2158  "SHARD_COUNT must be a multiple of the number of leaves in the cluster.");
2159  }
2160  td.nShards = g_leaf_count ? shard_count / g_leaf_count : shard_count;
2161  if (!td.shardedColumnId && !td.nShards) {
2162  throw std::runtime_error(
2163  "Must specify the number of shards through the SHARD_COUNT option");
2164  };
2165  });
2166 }
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 2128 of file ParserNode.cpp.

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

Definition at line 2179 of file ParserNode.cpp.

References sort_column_index().

2181  {
2182  return get_property_value<StringLiteral>(p, [&td, &columns](const auto sort_upper) {
2183  td.sortedColumnId = sort_column_index(sort_upper, columns);
2184  if (!td.sortedColumnId) {
2185  throw std::runtime_error("Specified sort column " + sort_upper + " doesn't exist");
2186  }
2187  });
2188 }
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 2054 of file ParserNode.cpp.

2056  {
2057  auto assignment = [&td](const auto val) { td.storageType = val; };
2058  return get_property_value<StringLiteral, decltype(assignment), CaseSensitiveValidate>(
2059  p, assignment);
2060 }
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 2215 of file ParserNode.cpp.

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

2217  {
2218  const auto it = tableDefFuncMap.find(boost::to_lower_copy<std::string>(*p->get_name()));
2219  if (it == tableDefFuncMap.end()) {
2220  throw std::runtime_error(
2221  "Invalid CREATE TABLE option " + *p->get_name() +
2222  ". Should be FRAGMENT_SIZE, MAX_CHUNK_SIZE, PAGE_SIZE, MAX_ROLLBACK_EPOCHS, "
2223  "MAX_ROWS, "
2224  "PARTITIONS, SHARD_COUNT, VACUUM, SORT_COLUMN, STORAGE_TYPE.");
2225  }
2226  return it->second(td, p.get(), columns);
2227 }
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 2229 of file ParserNode.cpp.

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

2231  {
2232  const auto it = tableDefFuncMap.find(boost::to_lower_copy<std::string>(*p->get_name()));
2233  if (it == tableDefFuncMap.end()) {
2234  throw std::runtime_error(
2235  "Invalid CREATE TABLE AS option " + *p->get_name() +
2236  ". Should be FRAGMENT_SIZE, MAX_CHUNK_SIZE, PAGE_SIZE, MAX_ROLLBACK_EPOCHS, "
2237  "MAX_ROWS, "
2238  "PARTITIONS, SHARD_COUNT, VACUUM, SORT_COLUMN, STORAGE_TYPE or "
2239  "USE_SHARED_DICTIONARIES.");
2240  }
2241  return it->second(td, p.get(), columns);
2242 }
static const std::map< const std::string, const TableDefFuncPtr > tableDefFuncMap

+ Here is the caller 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 2168 of file ParserNode.cpp.

2170  {
2171  return get_property_value<StringLiteral>(p, [&td](const auto vacuum_uc) {
2172  if (vacuum_uc != "IMMEDIATE" && vacuum_uc != "DELAYED") {
2173  throw std::runtime_error("VACUUM must be IMMEDIATE or DELAYED");
2174  }
2175  td.hasDeletedCol = boost::iequals(vacuum_uc, "IMMEDIATE") ? false : true;
2176  });
2177 }
bool Parser::anonymous_namespace{ParserNode.cpp}::hasData ( SubstituteMap &  sMap,
std::string  tableName 
)

Definition at line 3969 of file ParserNode.cpp.

References EMPTY_NAME.

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

3969  {
3970  // assumes loadTable has been previously called
3971  return (sMap[tableName] != EMPTY_NAME);
3972 }
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 3950 of file ParserNode.cpp.

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

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

3952  {
3953  if (sMap.find(tableName) != sMap.end()) {
3954  if (sMap[tableName] == EMPTY_NAME)
3955  return tableName;
3956  return sMap[tableName];
3957  } else {
3958  // lookup table in src catalog
3959  const TableDescriptor* td = catalog.getMetadataForTable(tableName);
3960  if (td) {
3961  sMap[tableName] = tableName;
3962  } else {
3963  sMap[tableName] = EMPTY_NAME;
3964  }
3965  }
3966  return tableName;
3967 }
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}::recordRename ( SubstituteMap &  sMap,
std::string  oldName,
std::string  newName 
)

Definition at line 3946 of file ParserNode.cpp.

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

3946  {
3947  sMap[oldName] = newName;
3948 }

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

2016  {
2017  rapidjson::Document document;
2018  auto& allocator = document.GetAllocator();
2019  rapidjson::Value arr(rapidjson::kArrayType);
2020  if (shard_key_def) {
2021  rapidjson::Value shard_key_obj(rapidjson::kObjectType);
2022  set_string_field(shard_key_obj, "type", "SHARD KEY", document);
2023  set_string_field(shard_key_obj, "name", shard_key_def->get_column(), document);
2024  arr.PushBack(shard_key_obj, allocator);
2025  }
2026  for (const auto& shared_dict_def : shared_dict_defs) {
2027  rapidjson::Value shared_dict_obj(rapidjson::kObjectType);
2028  set_string_field(shared_dict_obj, "type", "SHARED DICTIONARY", document);
2029  set_string_field(shared_dict_obj, "name", shared_dict_def.get_column(), document);
2031  shared_dict_obj, "foreign_table", shared_dict_def.get_foreign_table(), document);
2032  set_string_field(shared_dict_obj,
2033  "foreign_column",
2034  shared_dict_def.get_foreign_column(),
2035  document);
2036  arr.PushBack(shared_dict_obj, allocator);
2037  }
2038  rapidjson::StringBuffer buffer;
2039  rapidjson::Writer<rapidjson::StringBuffer> writer(buffer);
2040  arr.Accept(writer);
2041  return buffer.GetString();
2042 }
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 2001 of file ParserNode.cpp.

Referenced by serialize_key_metainfo().

2004  {
2005  rapidjson::Value field_name_json_str;
2006  field_name_json_str.SetString(
2007  field_name.c_str(), field_name.size(), document.GetAllocator());
2008  rapidjson::Value field_value_json_str;
2009  field_value_json_str.SetString(
2010  field_value.c_str(), field_value.size(), document.GetAllocator());
2011  obj.AddMember(field_name_json_str, field_value_json_str, document.GetAllocator());
2012 }

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

References validate_shard_column_type().

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

1969  {
1970  size_t index = 1;
1971  for (const auto& cd : columns) {
1972  if (cd.columnName == name) {
1974  return index;
1975  }
1976  ++index;
1977  if (cd.columnType.is_geometry()) {
1978  index += cd.columnType.get_physical_cols();
1979  }
1980  }
1981  // Not found, return 0
1982  return 0;
1983 }
string name
Definition: setup.in.py:72
void validate_shard_column_type(const ColumnDescriptor &cd)

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

Referenced by get_sort_column_def().

1986  {
1987  size_t index = 1;
1988  for (const auto& cd : columns) {
1989  if (boost::to_upper_copy<std::string>(cd.columnName) == name) {
1990  return index;
1991  }
1992  ++index;
1993  if (cd.columnType.is_geometry()) {
1994  index += cd.columnType.get_physical_cols();
1995  }
1996  }
1997  // Not found, return 0
1998  return 0;
1999 }
string name
Definition: setup.in.py:72

+ Here is the caller graph for this function:

void Parser::anonymous_namespace{ParserNode.cpp}::validate_shard_column_type ( const ColumnDescriptor cd)

Definition at line 1954 of file ParserNode.cpp.

References ColumnDescriptor::columnType, ColumnDescriptor::default_value, and kENCODING_DICT.

Referenced by shard_column_index().

1954  {
1955  const auto& col_ti = cd.columnType;
1956  if (col_ti.is_integer() ||
1957  (col_ti.is_string() && col_ti.get_compression() == kENCODING_DICT) ||
1958  col_ti.is_time()) {
1959  if (cd.default_value.has_value()) {
1960  throw std::runtime_error("Default values for shard keys are not supported yet.");
1961  }
1962  } else {
1963  throw std::runtime_error("Cannot shard on type " + col_ti.get_type_name() +
1964  ", encoding " + col_ti.get_compression_name());
1965  }
1966 }
std::optional< std::string > default_value
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 2244 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 2203 of file ParserNode.cpp.