OmniSciDB  d2f719934e
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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
 
size_t toHash () const override
 
std::string getFieldName (const size_t i) const
 
bool isAll () const
 
void checkForMatchingMetaInfoTypes () const
 
RexScalar constcopyAndRedirectSource (RexScalar const *, size_t input_idx) const
 
- Public Member Functions inherited from RelAlgNode
 RelAlgNode (RelAlgInputs inputs={})
 
virtual ~RelAlgNode ()
 
void resetQueryExecutionState ()
 
void setContextData (const RaExecutionDesc *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 RaExecutionDescgetContextData () 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)
 
void setRelNodeDagId (const size_t id) const
 
size_t getRelNodeDagId () const
 
bool isNop () const
 
void markAsNop ()
 
void clearContextData () const
 

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_
 
std::optional< size_t > hash_
 

Detailed Description

Definition at line 2074 of file RelAlgDagBuilder.h.

Constructor & Destructor Documentation

RelLogicalUnion::RelLogicalUnion ( RelAlgInputs  inputs,
bool  is_all 
)

Definition at line 590 of file RelAlgDagBuilder.cpp.

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

Referenced by toHash().

591  : RelAlgNode(std::move(inputs)), is_all_(is_all) {
592  if (!g_enable_union) {
593  throw QueryNotSupported(
594  "UNION is not supported yet. There is an experimental enable-union option "
595  "available to enable UNION ALL queries.");
596  }
597  CHECK_EQ(2u, inputs_.size());
598  if (!is_all_) {
599  throw QueryNotSupported("UNION without ALL is not supported yet.");
600  }
601 }
#define CHECK_EQ(x, y)
Definition: Logger.h:219
RelAlgNode(RelAlgInputs inputs={})
bool g_enable_union
RelAlgInputs inputs_

+ Here is the caller graph for this function:

Member Function Documentation

void RelLogicalUnion::checkForMatchingMetaInfoTypes ( ) const

Definition at line 638 of file RelAlgDagBuilder.cpp.

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

Referenced by RelAlgExecutor::executeUnion().

638  {
639  std::vector<TargetMetaInfo> const& tmis0 = inputs_[0]->getOutputMetainfo();
640  std::vector<TargetMetaInfo> const& tmis1 = inputs_[1]->getOutputMetainfo();
641  if (tmis0.size() != tmis1.size()) {
642  VLOG(2) << "tmis0.size() = " << tmis0.size() << " != " << tmis1.size()
643  << " = tmis1.size()";
644  throw std::runtime_error("Subqueries of a UNION must have matching data types.");
645  }
646  for (size_t i = 0; i < tmis0.size(); ++i) {
647  if (tmis0[i].get_type_info() != tmis1[i].get_type_info()) {
648  SQLTypeInfo const& ti0 = tmis0[i].get_type_info();
649  SQLTypeInfo const& ti1 = tmis1[i].get_type_info();
650  VLOG(2) << "Types do not match for UNION:\n tmis0[" << i
651  << "].get_type_info().to_string() = " << ti0.to_string() << "\n tmis1["
652  << i << "].get_type_info().to_string() = " << ti1.to_string();
653  if (ti0.get_comp_param() != ti1.get_comp_param()) {
654  if (!ti0.is_dict_encoded_string() || !ti1.is_dict_encoded_string()) {
655  throw std::runtime_error(
656  "Subqueries of a UNION must have the exact same data types.");
657  }
658  }
659  }
660  }
661 }
std::string to_string() const
Definition: sqltypes.h:482
HOST DEVICE int get_comp_param() const
Definition: sqltypes.h:338
bool is_dict_encoded_string() const
Definition: sqltypes.h:557
#define VLOG(n)
Definition: Logger.h:305
RelAlgInputs inputs_

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Definition at line 664 of file RelAlgDagBuilder.cpp.

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

665  {
666  if (auto const* rex_input_ptr = dynamic_cast<RexInput const*>(rex_scalar)) {
667  RexInput rex_input(*rex_input_ptr);
668  rex_input.setSourceNode(getInput(input_idx));
669  scalar_exprs_.emplace_back(std::make_shared<RexInput const>(std::move(rex_input)));
670  return scalar_exprs_.back().get();
671  }
672  return rex_scalar;
673 }
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:

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

Implements RelAlgNode.

Definition at line 2077 of file RelAlgDagBuilder.h.

2077  {
2078  return std::make_shared<RelLogicalUnion>(*this);
2079  }
std::string RelLogicalUnion::getFieldName ( const size_t  i) const

Definition at line 619 of file RelAlgDagBuilder.cpp.

References RelAlgNode::inputs_, toString(), and UNREACHABLE.

619  {
620  if (auto const* input = dynamic_cast<RelCompound const*>(inputs_[0].get())) {
621  return input->getFieldName(i);
622  } else if (auto const* input = dynamic_cast<RelProject const*>(inputs_[0].get())) {
623  return input->getFieldName(i);
624  } else if (auto const* input = dynamic_cast<RelLogicalUnion const*>(inputs_[0].get())) {
625  return input->getFieldName(i);
626  } else if (auto const* input = dynamic_cast<RelAggregate const*>(inputs_[0].get())) {
627  return input->getFieldName(i);
628  } else if (auto const* input = dynamic_cast<RelScan const*>(inputs_[0].get())) {
629  return input->getFieldName(i);
630  } else if (auto const* input =
631  dynamic_cast<RelTableFunction const*>(inputs_[0].get())) {
632  return input->getFieldName(i);
633  }
634  UNREACHABLE() << "Unhandled input type: " << ::toString(inputs_.front());
635  return {};
636 }
#define UNREACHABLE()
Definition: Logger.h:255
RelAlgInputs inputs_
std::string toString() const override

+ Here is the call graph for this function:

bool RelLogicalUnion::isAll ( ) const
inline

Definition at line 2086 of file RelAlgDagBuilder.h.

References is_all_.

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

2086 { return is_all_; }

+ Here is the caller graph for this function:

size_t RelLogicalUnion::size ( ) const
overridevirtual

Implements RelAlgNode.

Definition at line 603 of file RelAlgDagBuilder.cpp.

References RelAlgNode::inputs_.

603  {
604  return inputs_.front()->size();
605 }
RelAlgInputs inputs_
size_t RelLogicalUnion::toHash ( ) const
overridevirtual

Implements RelAlgNode.

Definition at line 611 of file RelAlgDagBuilder.cpp.

References RelAlgNode::hash_, is_all_, and RelLogicalUnion().

611  {
612  if (!hash_) {
613  hash_ = typeid(RelLogicalUnion).hash_code();
614  boost::hash_combine(*hash_, is_all_);
615  }
616  return *hash_;
617 }
std::optional< size_t > hash_
RelLogicalUnion(RelAlgInputs, bool is_all)

+ Here is the call graph for this function:

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

Implements RelAlgNode.

Definition at line 607 of file RelAlgDagBuilder.cpp.

References cat(), is_all_, and typeName().

Referenced by getFieldName().

607  {
608  return cat(::typeName(this), "(is_all(", is_all_, "))");
609 }
std::string cat(Ts &&...args)
std::string typeName(const T *v)
Definition: toString.h:93

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Member Data Documentation

bool const RelLogicalUnion::is_all_
private

Definition at line 2095 of file RelAlgDagBuilder.h.

Referenced by isAll(), RelLogicalUnion(), toHash(), and toString().

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

Definition at line 2092 of file RelAlgDagBuilder.h.

Referenced by copyAndRedirectSource().


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