OmniSciDB  8a228a1076
RelLogicalUnion Class Reference

#include <RelAlgDagBuilder.h>

+ Inheritance diagram for RelLogicalUnion:
+ Collaboration diagram for RelLogicalUnion:

Public Member Functions

 RelLogicalUnion (RelAlgInputs, bool is_all)
 
std::shared_ptr< RelAlgNodedeepCopy () const override
 
size_t size () const override
 
std::string toString () const override
 
std::string getFieldName (const size_t i) const
 
bool isAll () const
 
void checkForMatchingMetaInfoTypes () const
 
RexScalar const * copyAndRedirectSource (RexScalar const *, size_t input_idx) const
 
- 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 ()
 

Public Attributes

std::vector< std::shared_ptr< const RexScalar > > scalar_exprs_
 

Private Attributes

bool const is_all_
 

Additional Inherited Members

- Static Public Member Functions inherited from RelAlgNode
static void resetRelAlgFirstId () noexcept
 
- Protected Attributes inherited from RelAlgNode
RelAlgInputs inputs_
 
const unsigned id_
 

Detailed Description

Definition at line 1782 of file RelAlgDagBuilder.h.

Constructor & Destructor Documentation

◆ RelLogicalUnion()

RelLogicalUnion::RelLogicalUnion ( RelAlgInputs  inputs,
bool  is_all 
)

Definition at line 579 of file RelAlgDagBuilder.cpp.

References CHECK_EQ, g_enable_union, RelAlgNode::inputs_, and is_all_.

580  : RelAlgNode(std::move(inputs)), is_all_(is_all) {
581  if (!g_enable_union) {
582  throw QueryNotSupported(
583  "UNION is not supported yet. There is an experimental enable-union option "
584  "available to enable UNION ALL queries.");
585  }
586  CHECK_EQ(2u, inputs_.size());
587  if (!is_all_) {
588  throw QueryNotSupported("UNION without ALL is not supported yet.");
589  }
590 }
#define CHECK_EQ(x, y)
Definition: Logger.h:205
RelAlgNode(RelAlgInputs inputs={})
bool g_enable_union
RelAlgInputs inputs_

Member Function Documentation

◆ checkForMatchingMetaInfoTypes()

void RelLogicalUnion::checkForMatchingMetaInfoTypes ( ) const

Definition at line 619 of file RelAlgDagBuilder.cpp.

References SQLTypeInfo::get_comp_param(), RelAlgNode::inputs_, SQLTypeInfo::is_dict_encoded_string(), SQLTypeInfo::to_string(), and VLOG.

Referenced by RelAlgExecutor::executeUnion().

619  {
620  std::vector<TargetMetaInfo> const& tmis0 = inputs_[0]->getOutputMetainfo();
621  std::vector<TargetMetaInfo> const& tmis1 = inputs_[1]->getOutputMetainfo();
622  if (tmis0.size() != tmis1.size()) {
623  VLOG(2) << "tmis0.size() = " << tmis0.size() << " != " << tmis1.size()
624  << " = tmis1.size()";
625  throw std::runtime_error("Subqueries of a UNION must have matching data types.");
626  }
627  for (size_t i = 0; i < tmis0.size(); ++i) {
628  if (tmis0[i].get_type_info() != tmis1[i].get_type_info()) {
629  SQLTypeInfo const& ti0 = tmis0[i].get_type_info();
630  SQLTypeInfo const& ti1 = tmis1[i].get_type_info();
631  VLOG(2) << "Types do not match for UNION:\n tmis0[" << i
632  << "].get_type_info().to_string() = " << ti0.to_string() << "\n tmis1["
633  << i << "].get_type_info().to_string() = " << ti1.to_string();
634  if (ti0.is_dict_encoded_string() && ti1.is_dict_encoded_string() &&
635  ti0.get_comp_param() != ti1.get_comp_param()) {
636  throw std::runtime_error(
637  "Taking the UNION of different text-encoded dictionaries is not yet "
638  "supported. This may be resolved by using shared dictionaries. For example, "
639  "by making one a shared dictionary reference to the other.");
640  } else {
641  throw std::runtime_error(
642  "Subqueries of a UNION must have the exact same data types.");
643  }
644  }
645  }
646 }
HOST DEVICE int get_comp_param() const
Definition: sqltypes.h:268
bool is_dict_encoded_string() const
Definition: sqltypes.h:443
std::string to_string() const
Definition: sqltypes.h:394
#define VLOG(n)
Definition: Logger.h:291
RelAlgInputs inputs_
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ copyAndRedirectSource()

RexScalar const * RelLogicalUnion::copyAndRedirectSource ( RexScalar const *  rex_scalar,
size_t  input_idx 
) const

Definition at line 649 of file RelAlgDagBuilder.cpp.

References RelAlgNode::getInput(), scalar_exprs_, and RexInput::setSourceNode().

650  {
651  if (auto const* rex_input_ptr = dynamic_cast<RexInput const*>(rex_scalar)) {
652  RexInput rex_input(*rex_input_ptr);
653  rex_input.setSourceNode(getInput(input_idx));
654  scalar_exprs_.emplace_back(std::make_shared<RexInput const>(std::move(rex_input)));
655  return scalar_exprs_.back().get();
656  }
657  return rex_scalar;
658 }
std::vector< std::shared_ptr< const RexScalar > > scalar_exprs_
const RelAlgNode * getInput(const size_t idx) const
+ Here is the call graph for this function:

◆ deepCopy()

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

Implements RelAlgNode.

Definition at line 1785 of file RelAlgDagBuilder.h.

References Rex::toString().

1785  {
1786  return std::make_shared<RelLogicalUnion>(*this);
1787  }
+ Here is the call graph for this function:

◆ getFieldName()

std::string RelLogicalUnion::getFieldName ( const size_t  i) const

Definition at line 600 of file RelAlgDagBuilder.cpp.

References RelAlgNode::inputs_, and UNREACHABLE.

600  {
601  if (auto const* input = dynamic_cast<RelCompound const*>(inputs_[0].get())) {
602  return input->getFieldName(i);
603  } else if (auto const* input = dynamic_cast<RelProject const*>(inputs_[0].get())) {
604  return input->getFieldName(i);
605  } else if (auto const* input = dynamic_cast<RelLogicalUnion const*>(inputs_[0].get())) {
606  return input->getFieldName(i);
607  } else if (auto const* input = dynamic_cast<RelAggregate const*>(inputs_[0].get())) {
608  return input->getFieldName(i);
609  } else if (auto const* input = dynamic_cast<RelScan const*>(inputs_[0].get())) {
610  return input->getFieldName(i);
611  } else if (auto const* input =
612  dynamic_cast<RelTableFunction const*>(inputs_[0].get())) {
613  return input->getFieldName(i);
614  }
615  UNREACHABLE() << "Unhandled input type: " << inputs_.front()->toString();
616  return {};
617 }
#define UNREACHABLE()
Definition: Logger.h:241
RelAlgInputs inputs_

◆ isAll()

bool RelLogicalUnion::isAll ( ) const
inline

Definition at line 1793 of file RelAlgDagBuilder.h.

Referenced by RelAlgExecutor::createUnionWorkUnit(), and RelAlgExecutor::executeUnion().

1793 { return is_all_; }
+ Here is the caller graph for this function:

◆ size()

size_t RelLogicalUnion::size ( ) const
overridevirtual

Implements RelAlgNode.

Definition at line 592 of file RelAlgDagBuilder.cpp.

References RelAlgNode::inputs_.

Referenced by details::RelAlgDispatcher::dispatchLogicalValues().

592  {
593  return inputs_.front()->size();
594 }
RelAlgInputs inputs_
+ Here is the caller graph for this function:

◆ toString()

std::string RelLogicalUnion::toString ( ) const
overridevirtual

Implements RelAlgNode.

Definition at line 596 of file RelAlgDagBuilder.cpp.

References cat(), and is_all_.

596  {
597  return cat("(RelLogicalUnion<", this, ">(is_all(", is_all_, ")))");
598 }
std::string cat(Ts &&... args)
+ Here is the call graph for this function:

Member Data Documentation

◆ is_all_

bool const RelLogicalUnion::is_all_
private

Definition at line 1802 of file RelAlgDagBuilder.h.

Referenced by RelLogicalUnion(), and toString().

◆ scalar_exprs_

std::vector<std::shared_ptr<const RexScalar> > RelLogicalUnion::scalar_exprs_
mutable

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