OmniSciDB  ca0c39ec8f
 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 4971 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().

4971  {
4972  bool not_null;
4973  const ColumnConstraintDef* cc = coldef->get_column_constraint();
4974  if (cc == nullptr) {
4975  not_null = false;
4976  } else {
4977  not_null = cc->get_notnull();
4978  }
4979  std::string default_value;
4980  const std::string* default_value_ptr = nullptr;
4981  if (cc) {
4982  if (auto def_val_literal = cc->get_defaultval()) {
4983  auto defaultsp = dynamic_cast<const StringLiteral*>(def_val_literal);
4984  default_value =
4985  defaultsp ? *defaultsp->get_stringval() : def_val_literal->to_string();
4986  // The preprocessing below is needed because:
4987  // a) TypedImportBuffer expects arrays in the {...} format
4988  // b) TypedImportBuffer expects string literals inside arrays w/o any quotes
4989  if (coldef->get_column_type()->get_is_array()) {
4990  std::regex array_re(R"(^ARRAY\s*\[(.*)\]$)", std::regex_constants::icase);
4991  default_value = std::regex_replace(default_value, array_re, "{$1}");
4992  boost::erase_all(default_value, "\'");
4993  }
4994  default_value_ptr = &default_value;
4995  }
4996  }
4997  ddl_utils::set_column_descriptor(*coldef->get_column_name(),
4998  cd,
4999  coldef->get_column_type(),
5000  not_null,
5001  coldef->get_compression(),
5002  default_value_ptr);
5003 }
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:661

+ 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: