OmniSciDB  ba1bac9284
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
RelModify Class Reference

#include <RelAlgDagBuilder.h>

+ Inheritance diagram for RelModify:
+ Collaboration diagram for RelModify:

Public Types

enum  ModifyOperation { ModifyOperation::Insert, ModifyOperation::Delete, ModifyOperation::Update }
 
using RelAlgNodeInputPtr = std::shared_ptr< const RelAlgNode >
 
using TargetColumnList = std::vector< std::string >
 

Public Member Functions

 RelModify (Catalog_Namespace::Catalog const &cat, TableDescriptor const *const td, bool flattened, std::string const &op_string, TargetColumnList const &target_column_list, RelAlgNodeInputPtr input)
 
 RelModify (Catalog_Namespace::Catalog const &cat, TableDescriptor const *const td, bool flattened, ModifyOperation op, TargetColumnList const &target_column_list, RelAlgNodeInputPtr input)
 
TableDescriptor const *const getTableDescriptor () const
 
bool const isFlattened () const
 
ModifyOperation getOperation () const
 
TargetColumnList constgetUpdateColumnNames ()
 
int getUpdateColumnCount () const
 
size_t size () const override
 
std::shared_ptr< RelAlgNodedeepCopy () const override
 
std::string toString () const override
 
void applyUpdateModificationsToInputNode ()
 
void applyDeleteModificationsToInputNode ()
 
- Public Member Functions inherited from RelAlgNode
 RelAlgNode (RelAlgInputs inputs={})
 
virtual ~RelAlgNode ()
 
void resetQueryExecutionState ()
 
void setContextData (const void *context_data) const
 
void setOutputMetainfo (const std::vector< TargetMetaInfo > &targets_metainfo) const
 
const std::vector
< TargetMetaInfo > & 
getOutputMetainfo () const
 
unsigned getId () const
 
bool hasContextData () const
 
const void * getContextData () const
 
const size_t inputCount () const
 
const RelAlgNodegetInput (const size_t idx) const
 
std::shared_ptr< const RelAlgNodegetAndOwnInput (const size_t idx) const
 
void addManagedInput (std::shared_ptr< const RelAlgNode > input)
 
bool hasInput (const RelAlgNode *needle) const
 
virtual void replaceInput (std::shared_ptr< const RelAlgNode > old_input, std::shared_ptr< const RelAlgNode > input)
 
bool isNop () const
 
void markAsNop ()
 
void clearContextData () const
 

Static Public Member Functions

static std::string yieldModifyOperationString (ModifyOperation const op)
 
static ModifyOperation yieldModifyOperationEnum (std::string const &op_string)
 
- Static Public Member Functions inherited from RelAlgNode
static void resetRelAlgFirstId () noexcept
 

Private Attributes

Catalog_Namespace::Catalog constcatalog_
 
const TableDescriptortable_descriptor_
 
bool flattened_
 
ModifyOperation operation_
 
TargetColumnList target_column_list_
 

Additional Inherited Members

- Protected Attributes inherited from RelAlgNode
RelAlgInputs inputs_
 
const unsigned id_
 

Detailed Description

Definition at line 1387 of file RelAlgDagBuilder.h.

Member Typedef Documentation

Definition at line 1390 of file RelAlgDagBuilder.h.

using RelModify::TargetColumnList = std::vector<std::string>

Definition at line 1391 of file RelAlgDagBuilder.h.

Member Enumeration Documentation

Enumerator
Insert 
Delete 
Update 

Definition at line 1389 of file RelAlgDagBuilder.h.

1389 { Insert, Delete, Update };

Constructor & Destructor Documentation

RelModify::RelModify ( Catalog_Namespace::Catalog const cat,
TableDescriptor const *const  td,
bool  flattened,
std::string const op_string,
TargetColumnList const target_column_list,
RelAlgNodeInputPtr  input 
)
inline

Definition at line 1420 of file RelAlgDagBuilder.h.

References RelAlgNode::inputs_, table_descriptor_, and foreign_storage::validate_non_foreign_table_write().

1426  : catalog_(cat)
1427  , table_descriptor_(td)
1428  , flattened_(flattened)
1429  , operation_(yieldModifyOperationEnum(op_string))
1430  , target_column_list_(target_column_list) {
1432  inputs_.push_back(input);
1433  }
void validate_non_foreign_table_write(const TableDescriptor *table_descriptor)
Definition: FsiUtils.h:22
std::string cat(Ts &&...args)
const TableDescriptor * table_descriptor_
Catalog_Namespace::Catalog const & catalog_
static ModifyOperation yieldModifyOperationEnum(std::string const &op_string)
ModifyOperation operation_
TargetColumnList target_column_list_
RelAlgInputs inputs_

+ Here is the call graph for this function:

RelModify::RelModify ( Catalog_Namespace::Catalog const cat,
TableDescriptor const *const  td,
bool  flattened,
ModifyOperation  op,
TargetColumnList const target_column_list,
RelAlgNodeInputPtr  input 
)
inline

Definition at line 1435 of file RelAlgDagBuilder.h.

References RelAlgNode::inputs_, table_descriptor_, and foreign_storage::validate_non_foreign_table_write().

1441  : catalog_(cat)
1442  , table_descriptor_(td)
1443  , flattened_(flattened)
1444  , operation_(op)
1445  , target_column_list_(target_column_list) {
1447  inputs_.push_back(input);
1448  }
void validate_non_foreign_table_write(const TableDescriptor *table_descriptor)
Definition: FsiUtils.h:22
std::string cat(Ts &&...args)
const TableDescriptor * table_descriptor_
Catalog_Namespace::Catalog const & catalog_
ModifyOperation operation_
TargetColumnList target_column_list_
RelAlgInputs inputs_

+ Here is the call graph for this function:

Member Function Documentation

void RelModify::applyDeleteModificationsToInputNode ( )
inline

Definition at line 1530 of file RelAlgDagBuilder.h.

References CHECK, const, RelAlgNode::inputs_, ModifyManipulationTarget::setDeleteViaSelectFlag(), ModifyManipulationTarget::setModifiedTableDescriptor(), and table_descriptor_.

1530  {
1531  RelProject const* previous_project_node =
1532  dynamic_cast<RelProject const*>(inputs_[0].get());
1533  CHECK(previous_project_node != nullptr);
1534  previous_project_node->setDeleteViaSelectFlag();
1535  previous_project_node->setModifiedTableDescriptor(table_descriptor_);
1536  }
#define const
void setDeleteViaSelectFlag() const
const TableDescriptor * table_descriptor_
void setModifiedTableDescriptor(TableDescriptor const *td) const
#define CHECK(condition)
Definition: Logger.h:206
RelAlgInputs inputs_

+ Here is the call graph for this function:

void RelModify::applyUpdateModificationsToInputNode ( )
inline

Definition at line 1476 of file RelAlgDagBuilder.h.

References catalog_, CHECK, const, Catalog_Namespace::Catalog::getMetadataForColumn(), Catalog_Namespace::Catalog::getShardColumnMetadataForTable(), RelAlgNode::inputs_, TableDescriptor::nShards, ModifyManipulationTarget::setModifiedTableDescriptor(), ModifyManipulationTarget::setTargetColumns(), ModifyManipulationTarget::setUpdateViaSelectFlag(), ModifyManipulationTarget::setVarlenUpdateRequired(), table_descriptor_, TableDescriptor::tableId, target_column_list_, and RelProject::visitScalarExprs().

1476  {
1477  RelProject const* previous_project_node =
1478  dynamic_cast<RelProject const*>(inputs_[0].get());
1479  CHECK(previous_project_node != nullptr);
1480 
1481  previous_project_node->setUpdateViaSelectFlag();
1482  // remove the offset column in the projection for update handling
1483  target_column_list_.pop_back();
1484 
1485  previous_project_node->setModifiedTableDescriptor(table_descriptor_);
1486  previous_project_node->setTargetColumns(target_column_list_);
1487 
1488  int target_update_column_expr_start = 0;
1489  int target_update_column_expr_end = (int)(target_column_list_.size() - 1);
1490  CHECK(target_update_column_expr_start >= 0);
1491  CHECK(target_update_column_expr_end >= 0);
1492 
1493  bool varlen_update_required = false;
1494 
1495  auto varlen_scan_visitor = [this,
1496  &varlen_update_required,
1497  target_update_column_expr_start,
1498  target_update_column_expr_end](int index) {
1499  if (index >= target_update_column_expr_start &&
1500  index <= target_update_column_expr_end) {
1501  auto target_index = index - target_update_column_expr_start;
1502 
1503  auto* column_desc = catalog_.getMetadataForColumn(
1505  CHECK(column_desc);
1506 
1507  if (table_descriptor_->nShards) {
1508  const auto shard_cd =
1510  CHECK(shard_cd);
1511  if ((column_desc->columnName == shard_cd->columnName)) {
1512  throw std::runtime_error("UPDATE of a shard key is currently unsupported.");
1513  }
1514  }
1515 
1516  // Check for valid types
1517  if (column_desc->columnType.is_varlen()) {
1518  varlen_update_required = true;
1519  }
1520  if (column_desc->columnType.is_geometry()) {
1521  throw std::runtime_error("UPDATE of a geo column is unsupported.");
1522  }
1523  }
1524  };
1525 
1526  previous_project_node->visitScalarExprs(varlen_scan_visitor);
1527  previous_project_node->setVarlenUpdateRequired(varlen_update_required);
1528  }
void setVarlenUpdateRequired(bool required) const
void setTargetColumns(ColumnNameList const &target_columns) const
#define const
const ColumnDescriptor * getShardColumnMetadataForTable(const TableDescriptor *td) const
Definition: Catalog.cpp:4053
const TableDescriptor * table_descriptor_
const ColumnDescriptor * getMetadataForColumn(int tableId, const std::string &colName) const
Catalog_Namespace::Catalog const & catalog_
void visitScalarExprs(EXPR_VISITOR_FUNCTOR visitor_functor) const
void setModifiedTableDescriptor(TableDescriptor const *td) const
#define CHECK(condition)
Definition: Logger.h:206
void setUpdateViaSelectFlag() const
TargetColumnList target_column_list_
RelAlgInputs inputs_

+ Here is the call graph for this function:

std::shared_ptr<RelAlgNode> RelModify::deepCopy ( ) const
inlineoverridevirtual

Implements RelAlgNode.

Definition at line 1457 of file RelAlgDagBuilder.h.

1457  {
1458  return std::make_shared<RelModify>(*this);
1459  }
ModifyOperation RelModify::getOperation ( ) const
inline

Definition at line 1452 of file RelAlgDagBuilder.h.

References operation_.

1452 { return operation_; }
ModifyOperation operation_
TableDescriptor const* const RelModify::getTableDescriptor ( ) const
inline

Definition at line 1450 of file RelAlgDagBuilder.h.

References table_descriptor_.

1450 { return table_descriptor_; }
const TableDescriptor * table_descriptor_
int RelModify::getUpdateColumnCount ( ) const
inline

Definition at line 1454 of file RelAlgDagBuilder.h.

References target_column_list_.

1454 { return target_column_list_.size(); }
TargetColumnList target_column_list_
TargetColumnList const& RelModify::getUpdateColumnNames ( )
inline

Definition at line 1453 of file RelAlgDagBuilder.h.

References target_column_list_.

1453 { return target_column_list_; }
TargetColumnList target_column_list_
bool const RelModify::isFlattened ( ) const
inline

Definition at line 1451 of file RelAlgDagBuilder.h.

References flattened_.

1451 { return flattened_; }
size_t RelModify::size ( ) const
inlineoverridevirtual

Implements RelAlgNode.

Definition at line 1456 of file RelAlgDagBuilder.h.

1456 { return 0; }
std::string RelModify::toString ( ) const
inlineoverridevirtual

Implements RelAlgNode.

Definition at line 1461 of file RelAlgDagBuilder.h.

References cat(), flattened_, RelAlgNode::inputs_, operation_, table_descriptor_, TableDescriptor::tableName, target_column_list_, to_string(), typeName(), and yieldModifyOperationString().

1461  {
1462  return cat(::typeName(this),
1463  "(",
1465  ", flattened=",
1467  ", op=",
1469  ", target_column_list=",
1471  ", inputs=",
1472  ::toString(inputs_),
1473  ")");
1474  }
std::string toString() const override
std::string cat(Ts &&...args)
std::string tableName
std::string to_string(char const *&&v)
const TableDescriptor * table_descriptor_
static std::string yieldModifyOperationString(ModifyOperation const op)
std::string typeName(const T *v)
Definition: toString.h:82
ModifyOperation operation_
TargetColumnList target_column_list_
RelAlgInputs inputs_

+ Here is the call graph for this function:

static ModifyOperation RelModify::yieldModifyOperationEnum ( std::string const op_string)
inlinestatic

Definition at line 1407 of file RelAlgDagBuilder.h.

References Delete, Insert, and Update.

1407  {
1408  if (op_string == "INSERT") {
1409  return ModifyOperation::Insert;
1410  } else if (op_string == "DELETE") {
1411  return ModifyOperation::Delete;
1412  } else if (op_string == "UPDATE") {
1413  return ModifyOperation::Update;
1414  }
1415 
1416  throw std::runtime_error(
1417  std::string("Unsupported logical modify operation encountered " + op_string));
1418  }
static std::string RelModify::yieldModifyOperationString ( ModifyOperation const  op)
inlinestatic

Definition at line 1393 of file RelAlgDagBuilder.h.

References Delete, Insert, and Update.

Referenced by toString().

1393  {
1394  switch (op) {
1396  return "DELETE";
1398  return "INSERT";
1400  return "UPDATE";
1401  default:
1402  break;
1403  }
1404  throw std::runtime_error("Unexpected ModifyOperation enum encountered.");
1405  }

+ Here is the caller graph for this function:

Member Data Documentation

Catalog_Namespace::Catalog const& RelModify::catalog_
private

Definition at line 1539 of file RelAlgDagBuilder.h.

Referenced by applyUpdateModificationsToInputNode().

bool RelModify::flattened_
private

Definition at line 1541 of file RelAlgDagBuilder.h.

Referenced by isFlattened(), and toString().

ModifyOperation RelModify::operation_
private

Definition at line 1542 of file RelAlgDagBuilder.h.

Referenced by getOperation(), and toString().

TargetColumnList RelModify::target_column_list_
private

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