OmniSciDB  cde582ebc3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Parser::DDLStmt Class Referenceabstract

#include <ParserNode.h>

+ Inheritance diagram for Parser::DDLStmt:
+ Collaboration diagram for Parser::DDLStmt:

Public Member Functions

virtual void execute (const Catalog_Namespace::SessionInfo &session, bool read_only_mode)=0
 
void setColumnDescriptor (ColumnDescriptor &cd, const ColumnDef *coldef)
 
- Public Member Functions inherited from Parser::Node
virtual ~Node ()
 

Detailed Description

Definition at line 760 of file ParserNode.h.

Member Function Documentation

void Parser::DDLStmt::setColumnDescriptor ( ColumnDescriptor cd,
const ColumnDef coldef 
)

Definition at line 4920 of file ParserNode.cpp.

References Parser::ColumnDef::get_column_constraint(), Parser::ColumnDef::get_column_name(), Parser::ColumnDef::get_column_type(), Parser::ColumnDef::get_compression(), Parser::ColumnConstraintDef::get_defaultval(), ddl_utils::SqlType::get_is_array(), Parser::ColumnConstraintDef::get_notnull(), Parser::StringLiteral::get_stringval(), and ddl_utils::set_column_descriptor().

Referenced by Parser::CreateDataframeStmt::execute(), Parser::AddColumnStmt::execute(), and Parser::CreateTableStmt::executeDryRun().

4920  {
4921  bool not_null;
4922  const ColumnConstraintDef* cc = coldef->get_column_constraint();
4923  if (cc == nullptr) {
4924  not_null = false;
4925  } else {
4926  not_null = cc->get_notnull();
4927  }
4928  std::string default_value;
4929  const std::string* default_value_ptr = nullptr;
4930  if (cc) {
4931  if (auto def_val_literal = cc->get_defaultval()) {
4932  auto defaultsp = dynamic_cast<const StringLiteral*>(def_val_literal);
4933  default_value =
4934  defaultsp ? *defaultsp->get_stringval() : def_val_literal->to_string();
4935  // The preprocessing below is needed because:
4936  // a) TypedImportBuffer expects arrays in the {...} format
4937  // b) TypedImportBuffer expects string literals inside arrays w/o any quotes
4938  if (coldef->get_column_type()->get_is_array()) {
4939  std::regex array_re(R"(^ARRAY\s*\[(.*)\]$)", std::regex_constants::icase);
4940  default_value = std::regex_replace(default_value, array_re, "{$1}");
4941  boost::erase_all(default_value, "\'");
4942  }
4943  default_value_ptr = &default_value;
4944  }
4945  }
4946  ddl_utils::set_column_descriptor(*coldef->get_column_name(),
4947  cd,
4948  coldef->get_column_type(),
4949  not_null,
4950  coldef->get_compression(),
4951  default_value_ptr);
4952 }
void set_column_descriptor(const std::string &column_name, ColumnDescriptor &cd, SqlType *column_type, const bool not_null, const Encoding *encoding, const std::string *default_value)
Definition: DdlUtils.cpp:646

+ Here is the call graph for this function:

+ Here is the caller graph for this function:


The documentation for this class was generated from the following files: