OmniSciDB  c0231cc57d
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RelLogicalUnion Class Reference

#include <RelAlgDag.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 (RelRexToStringConfig config=RelRexToStringConfig::defaults()) const override
 
size_t toHash () 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 RaExecutionDesc *context_data) const
 
void setOutputMetainfo (const std::vector< TargetMetaInfo > &targets_metainfo) const
 
void setQueryPlanDag (const std::string &extracted_query_plan_dag) const
 
std::string getQueryPlanDag () const
 
size_t getQueryPlanDagHash () const
 
const std::vector
< TargetMetaInfo > & 
getOutputMetainfo () const
 
unsigned getId () const
 
void setIdInPlanTree (size_t id) const
 
std::optional< size_t > getIdInPlanTree () 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 > id_in_plan_tree_
 
std::optional< size_t > hash_
 

Detailed Description

Definition at line 2288 of file RelAlgDag.h.

Constructor & Destructor Documentation

RelLogicalUnion::RelLogicalUnion ( RelAlgInputs  inputs,
bool  is_all 
)

Definition at line 810 of file RelAlgDag.cpp.

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

Referenced by toHash().

811  : RelAlgNode(std::move(inputs)), is_all_(is_all) {
812  if (!g_enable_union) {
813  throw QueryNotSupported(
814  "The DEPRECATED enable-union option is set to off. Please remove this option as "
815  "it may be disabled in the future.");
816  }
817  CHECK_LE(2u, inputs_.size());
818  if (!is_all_) {
819  throw QueryNotSupported("UNION without ALL is not supported yet.");
820  }
821 }
RelAlgNode(RelAlgInputs inputs={})
Definition: RelAlgDag.h:774
bool const is_all_
Definition: RelAlgDag.h:2310
#define CHECK_LE(x, y)
Definition: Logger.h:233
bool g_enable_union
RelAlgInputs inputs_
Definition: RelAlgDag.h:886

+ Here is the caller graph for this function:

Member Function Documentation

void RelLogicalUnion::checkForMatchingMetaInfoTypes ( ) const

Definition at line 858 of file RelAlgDag.cpp.

References logger::INFO, RelAlgNode::inputs_, SQLTypeInfo::is_dict_encoded_string(), LOG, and SQLTypeInfo::to_string().

Referenced by RelAlgExecutor::executeUnion().

858  {
859  std::vector<TargetMetaInfo> const& tmis0 = inputs_[0]->getOutputMetainfo();
860  for (size_t i = 1; i < inputs_.size(); ++i) {
861  std::vector<TargetMetaInfo> const& tmisi = inputs_[i]->getOutputMetainfo();
862  if (tmis0.size() != tmisi.size()) {
863  LOG(INFO) << "tmis0.size()=" << tmis0.size() << " != " << tmisi.size()
864  << "=tmisi.size() for i=" << i;
865  throw std::runtime_error("Subqueries of a UNION must have matching data types.");
866  }
867  for (size_t j = 0; j < tmis0.size(); ++j) {
868  if (tmis0[j].get_type_info() != tmisi[j].get_type_info()) {
869  SQLTypeInfo const& ti0 = tmis0[j].get_type_info();
870  SQLTypeInfo const& ti1 = tmisi[j].get_type_info();
871  LOG(INFO) << "Types do not match for UNION:\n tmis0[" << j
872  << "].get_type_info().to_string() = " << ti0.to_string() << "\n tmis"
873  << i << '[' << j
874  << "].get_type_info().to_string() = " << ti1.to_string();
875  // The only permitted difference is when both columns are dictionary-encoded.
876  if (!(ti0.is_dict_encoded_string() && ti1.is_dict_encoded_string())) {
877  throw std::runtime_error(
878  "Subqueries of a UNION must have the exact same data types.");
879  }
880  }
881  }
882  }
883 }
#define LOG(tag)
Definition: Logger.h:216
std::string to_string() const
Definition: sqltypes.h:568
bool is_dict_encoded_string() const
Definition: sqltypes.h:652
RelAlgInputs inputs_
Definition: RelAlgDag.h:886

+ 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 886 of file RelAlgDag.cpp.

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

887  {
888  if (auto const* rex_input_ptr = dynamic_cast<RexInput const*>(rex_scalar)) {
889  RexInput rex_input(*rex_input_ptr);
890  rex_input.setSourceNode(getInput(input_idx));
891  scalar_exprs_.emplace_back(std::make_shared<RexInput const>(std::move(rex_input)));
892  return scalar_exprs_.back().get();
893  }
894  return rex_scalar;
895 }
std::vector< std::shared_ptr< const RexScalar > > scalar_exprs_
Definition: RelAlgDag.h:2307
const RelAlgNode * getInput(const size_t idx) const
Definition: RelAlgDag.h:826

+ Here is the call graph for this function:

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

Implements RelAlgNode.

Definition at line 2291 of file RelAlgDag.h.

2291  {
2292  return std::make_shared<RelLogicalUnion>(*this);
2293  }
std::string RelLogicalUnion::getFieldName ( const size_t  i) const

Definition at line 839 of file RelAlgDag.cpp.

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

839  {
840  if (auto const* input = dynamic_cast<RelCompound const*>(inputs_[0].get())) {
841  return input->getFieldName(i);
842  } else if (auto const* input = dynamic_cast<RelProject const*>(inputs_[0].get())) {
843  return input->getFieldName(i);
844  } else if (auto const* input = dynamic_cast<RelLogicalUnion const*>(inputs_[0].get())) {
845  return input->getFieldName(i);
846  } else if (auto const* input = dynamic_cast<RelAggregate const*>(inputs_[0].get())) {
847  return input->getFieldName(i);
848  } else if (auto const* input = dynamic_cast<RelScan const*>(inputs_[0].get())) {
849  return input->getFieldName(i);
850  } else if (auto const* input =
851  dynamic_cast<RelTableFunction const*>(inputs_[0].get())) {
852  return input->getFieldName(i);
853  }
854  UNREACHABLE() << "Unhandled input type: " << ::toString(inputs_.front());
855  return {};
856 }
#define UNREACHABLE()
Definition: Logger.h:266
std::string toString(RelRexToStringConfig config=RelRexToStringConfig::defaults()) const override
Definition: RelAlgDag.cpp:827
RelAlgInputs inputs_
Definition: RelAlgDag.h:886

+ Here is the call graph for this function:

bool RelLogicalUnion::isAll ( ) const
inline

Definition at line 2301 of file RelAlgDag.h.

References is_all_.

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

2301 { return is_all_; }
bool const is_all_
Definition: RelAlgDag.h:2310

+ Here is the caller graph for this function:

size_t RelLogicalUnion::size ( ) const
overridevirtual

Implements RelAlgNode.

Definition at line 823 of file RelAlgDag.cpp.

References RelAlgNode::inputs_.

823  {
824  return inputs_.front()->size();
825 }
RelAlgInputs inputs_
Definition: RelAlgDag.h:886
size_t RelLogicalUnion::toHash ( ) const
overridevirtual

Implements RelAlgNode.

Definition at line 831 of file RelAlgDag.cpp.

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

831  {
832  if (!hash_) {
833  hash_ = typeid(RelLogicalUnion).hash_code();
834  boost::hash_combine(*hash_, is_all_);
835  }
836  return *hash_;
837 }
bool const is_all_
Definition: RelAlgDag.h:2310
std::optional< size_t > hash_
Definition: RelAlgDag.h:889
RelLogicalUnion(RelAlgInputs, bool is_all)
Definition: RelAlgDag.cpp:810

+ Here is the call graph for this function:

std::string RelLogicalUnion::toString ( RelRexToStringConfig  config = RelRexToStringConfig::defaults()) const
overridevirtual

Implements RelAlgNode.

Definition at line 827 of file RelAlgDag.cpp.

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

Referenced by getFieldName().

827  {
828  return cat(::typeName(this), "(is_all(", is_all_, "))");
829 }
std::string cat(Ts &&...args)
bool const is_all_
Definition: RelAlgDag.h:2310
std::string typeName(const T *v)
Definition: toString.h:103

+ 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 2310 of file RelAlgDag.h.

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

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

Definition at line 2307 of file RelAlgDag.h.

Referenced by copyAndRedirectSource().


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