OmniSciDB  471d68cefb
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
QueryPlanDagChecker Class Referencefinal

#include <QueryPlanDagChecker.h>

+ Inheritance diagram for QueryPlanDagChecker:
+ Collaboration diagram for QueryPlanDagChecker:

Public Member Functions

 QueryPlanDagChecker (const RelAlgTranslator &rel_alg_translator)
 
void check (const RelAlgNode *)
 
void detectNotSupportedNode ()
 
void reset ()
 
bool getCheckResult () const
 
- Public Member Functions inherited from RelRexDagVisitor
virtual ~RelRexDagVisitor ()=default
 
void visit (RelAlgNode const *)
 
virtual void visit (RexScalar const *)
 

Static Public Member Functions

static std::unordered_set
< std::string > 
getNotSupportedFunctionsList ()
 
static bool isNotSupportedDag (const RelAlgNode *rel_alg_node, const RelAlgTranslator &rel_alg_translator)
 

Private Member Functions

void visit (const RelLogicalValues *) override
 
void visit (const RelModify *) override
 
void visit (const RelTableFunction *) override
 
void visit (const RelProject *) override
 
void visit (const RelScan *) override
 
void visit (const RelCompound *) override
 
void visit (const RelLogicalUnion *) override
 
void visit (const RexFunctionOperator *) override
 
void visit (const RexOperator *) override
 

Private Attributes

bool contain_not_supported_node_
 
const RelAlgTranslatorrel_alg_translator_
 
const std::unordered_set
< std::string > 
not_supported_functions_
 

Additional Inherited Members

- Protected Member Functions inherited from RelRexDagVisitor
virtual void visit (RelAggregate const *)
 
virtual void visit (RelFilter const *)
 
virtual void visit (RelJoin const *)
 
virtual void visit (RelLeftDeepInnerJoin const *)
 
virtual void visit (RelSort const *)
 
virtual void visit (RexAbstractInput const *)
 
virtual void visit (RexCase const *)
 
virtual void visit (RexInput const *)
 
virtual void visit (RexLiteral const *)
 
virtual void visit (RexRef const *)
 
virtual void visit (RexSubQuery const *)
 
virtual void visit (RexWindowFunctionOperator const *)
 

Detailed Description

Definition at line 25 of file QueryPlanDagChecker.h.

Constructor & Destructor Documentation

QueryPlanDagChecker::QueryPlanDagChecker ( const RelAlgTranslator rel_alg_translator)
inline

Definition at line 27 of file QueryPlanDagChecker.h.

29  , rel_alg_translator_(rel_alg_translator)
static std::unordered_set< std::string > getNotSupportedFunctionsList()
const RelAlgTranslator & rel_alg_translator_
const std::unordered_set< std::string > not_supported_functions_

Member Function Documentation

void QueryPlanDagChecker::check ( const RelAlgNode rel_alg_node)

Definition at line 34 of file QueryPlanDagChecker.cpp.

References RelRexDagVisitor::visit().

Referenced by isNotSupportedDag().

34  {
35  RelRexDagVisitor::visit(rel_alg_node);
36 }
void visit(RelAlgNode const *)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void QueryPlanDagChecker::detectNotSupportedNode ( )

Definition at line 23 of file QueryPlanDagChecker.cpp.

References contain_not_supported_node_.

Referenced by visit().

23  {
25 }

+ Here is the caller graph for this function:

bool QueryPlanDagChecker::getCheckResult ( ) const

Definition at line 19 of file QueryPlanDagChecker.cpp.

References contain_not_supported_node_.

Referenced by isNotSupportedDag(), and visit().

19  {
21 }

+ Here is the caller graph for this function:

static std::unordered_set<std::string> QueryPlanDagChecker::getNotSupportedFunctionsList ( )
inlinestatic

Definition at line 31 of file QueryPlanDagChecker.h.

31  {
32  std::unordered_set<std::string> not_supported_functions;
33  not_supported_functions.emplace("CURRENT_USER");
34  not_supported_functions.emplace("CARDINALITY");
35  not_supported_functions.emplace("ARRAY_LENGTH");
36  not_supported_functions.emplace("ITEM");
37  not_supported_functions.emplace("NOW");
38  not_supported_functions.emplace("SIGN");
39  not_supported_functions.emplace("OFFSET_IN_FRAGMENT");
40  not_supported_functions.emplace("DATETIME");
41  return not_supported_functions;
42  }
bool QueryPlanDagChecker::isNotSupportedDag ( const RelAlgNode rel_alg_node,
const RelAlgTranslator rel_alg_translator 
)
static

Definition at line 27 of file QueryPlanDagChecker.cpp.

References check(), and getCheckResult().

Referenced by QueryPlanDagExtractor::extractQueryPlanDag().

28  {
29  QueryPlanDagChecker checker(rel_alg_translator);
30  checker.check(rel_alg_node);
31  return checker.getCheckResult();
32 }

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void QueryPlanDagChecker::reset ( )

Definition at line 133 of file QueryPlanDagChecker.cpp.

References contain_not_supported_node_.

Referenced by visit().

133  {
135 }

+ Here is the caller graph for this function:

void QueryPlanDagChecker::visit ( const RelLogicalValues rel_alg_node)
overrideprivatevirtual

Reimplemented from RelRexDagVisitor.

Definition at line 38 of file QueryPlanDagChecker.cpp.

References detectNotSupportedNode().

38  {
40  return;
41 }

+ Here is the call graph for this function:

void QueryPlanDagChecker::visit ( const RelModify rel_alg_node)
overrideprivatevirtual

Reimplemented from RelRexDagVisitor.

Definition at line 43 of file QueryPlanDagChecker.cpp.

References detectNotSupportedNode().

43  {
45  return;
46 }

+ Here is the call graph for this function:

void QueryPlanDagChecker::visit ( const RelTableFunction rel_alg_node)
overrideprivatevirtual

Reimplemented from RelRexDagVisitor.

Definition at line 48 of file QueryPlanDagChecker.cpp.

References detectNotSupportedNode().

48  {
50  return;
51 }

+ Here is the call graph for this function:

void QueryPlanDagChecker::visit ( const RelProject rel_alg_node)
overrideprivatevirtual

Reimplemented from RelRexDagVisitor.

Definition at line 53 of file QueryPlanDagChecker.cpp.

References detectNotSupportedNode(), ModifyManipulationTarget::isDeleteViaSelect(), ModifyManipulationTarget::isUpdateViaSelect(), ModifyManipulationTarget::isVarlenUpdateRequired(), and RelRexDagVisitor::visit().

53  {
54  if (rel_alg_node->isDeleteViaSelect() || rel_alg_node->isUpdateViaSelect() ||
55  rel_alg_node->isVarlenUpdateRequired()) {
57  return;
58  }
59  RelRexDagVisitor::visit(rel_alg_node);
60 }
void visit(RelAlgNode const *)
auto const isDeleteViaSelect() const
auto const isUpdateViaSelect() const
auto const isVarlenUpdateRequired() const

+ Here is the call graph for this function:

void QueryPlanDagChecker::visit ( const RelScan rel_alg_node)
overrideprivatevirtual

Reimplemented from RelRexDagVisitor.

Definition at line 89 of file QueryPlanDagChecker.cpp.

References detectNotSupportedNode(), StorageType::FOREIGN_TABLE, RelScan::getTableDescriptor(), TableDescriptor::storageType, and RelRexDagVisitor::visit().

89  {
92  return;
93  }
94  RelRexDagVisitor::visit(rel_alg_node);
95 }
void visit(RelAlgNode const *)
std::string storageType
static constexpr char const * FOREIGN_TABLE
const TableDescriptor * getTableDescriptor() const

+ Here is the call graph for this function:

void QueryPlanDagChecker::visit ( const RelCompound rel_alg_node)
overrideprivatevirtual

Reimplemented from RelRexDagVisitor.

Definition at line 62 of file QueryPlanDagChecker.cpp.

References detectNotSupportedNode(), RelCompound::getTargetExpr(), i, RelCompound::isAggregate(), ModifyManipulationTarget::isDeleteViaSelect(), ModifyManipulationTarget::isUpdateViaSelect(), ModifyManipulationTarget::isVarlenUpdateRequired(), kAPPROX_QUANTILE, kSAMPLE, kSINGLE_VALUE, RelCompound::size(), and RelRexDagVisitor::visit().

62  {
63  if (rel_alg_node->isDeleteViaSelect() || rel_alg_node->isUpdateViaSelect() ||
64  rel_alg_node->isVarlenUpdateRequired()) {
66  return;
67  }
68  // SINGLE_VALUE / SAMPLE query
69  if (rel_alg_node->isAggregate() && rel_alg_node->size() > 0) {
70  for (size_t i = 0; i < rel_alg_node->size(); ++i) {
71  auto target_expr = rel_alg_node->getTargetExpr(i);
72  auto agg_expr = dynamic_cast<const RexAgg*>(target_expr);
73  if (agg_expr && (agg_expr->getKind() == SQLAgg::kSINGLE_VALUE ||
74  agg_expr->getKind() == SQLAgg::kSAMPLE ||
75  agg_expr->getKind() == SQLAgg::kAPPROX_QUANTILE)) {
77  return;
78  }
79  }
80  }
81  RelRexDagVisitor::visit(rel_alg_node);
82 }
const Rex * getTargetExpr(const size_t i) const
void visit(RelAlgNode const *)
size_t size() const override
auto const isDeleteViaSelect() const
bool isAggregate() const
auto const isUpdateViaSelect() const
auto const isVarlenUpdateRequired() const

+ Here is the call graph for this function:

void QueryPlanDagChecker::visit ( const RelLogicalUnion rel_alg_node)
overrideprivatevirtual

Reimplemented from RelRexDagVisitor.

Definition at line 84 of file QueryPlanDagChecker.cpp.

References detectNotSupportedNode().

84  {
86  return;
87 }

+ Here is the call graph for this function:

void QueryPlanDagChecker::visit ( const RexFunctionOperator rex_node)
overrideprivatevirtual

Reimplemented from RelRexDagVisitor.

Definition at line 110 of file QueryPlanDagChecker.cpp.

References detectNotSupportedNode(), getCheckResult(), RexFunctionOperator::getName(), RexOperator::getOperand(), i, not_supported_functions_, rel_alg_translator_, reset(), RexOperator::size(), RelAlgTranslator::translateScalarRex(), and RelRexDagVisitor::visit().

110  {
111  if (not_supported_functions_.count(rex_node->getName())) {
113  if (rex_node->getName() == "DATETIME") {
114  const auto arg = rel_alg_translator_.translateScalarRex(rex_node->getOperand(0));
115  const auto arg_lit = std::dynamic_pointer_cast<Analyzer::Constant>(arg);
116  if (arg_lit && !arg_lit->get_is_null() && arg_lit->get_type_info().is_string()) {
117  if (*arg_lit->get_constval().stringval != "NOW"sv) {
118  reset();
119  }
120  }
121  }
122  }
123  if (getCheckResult()) {
124  return;
125  }
126  for (size_t i = 0; i < rex_node->size(); ++i) {
127  if (rex_node->getOperand(i)) {
129  }
130  }
131 }
void visit(RelAlgNode const *)
std::shared_ptr< Analyzer::Expr > translateScalarRex(const RexScalar *rex) const
size_t size() const
const RexScalar * getOperand(const size_t idx) const
const RelAlgTranslator & rel_alg_translator_
const std::unordered_set< std::string > not_supported_functions_
const std::string & getName() const

+ Here is the call graph for this function:

void QueryPlanDagChecker::visit ( const RexOperator rex_node)
overrideprivatevirtual

Reimplemented from RelRexDagVisitor.

Definition at line 97 of file QueryPlanDagChecker.cpp.

References detectNotSupportedNode(), RexOperator::getOperand(), RexOperator::getOperator(), i, kOR, RexOperator::size(), and RelRexDagVisitor::visit().

97  {
98  // prevent too heavy IN clause containing more than 20 values to check
99  if (rex_node->getOperator() == SQLOps::kOR && rex_node->size() > 20) {
101  return;
102  }
103  for (size_t i = 0; i < rex_node->size(); ++i) {
104  if (rex_node->getOperand(i)) {
106  }
107  }
108 }
void visit(RelAlgNode const *)
size_t size() const
const RexScalar * getOperand(const size_t idx) const
Definition: sqldefs.h:38
SQLOps getOperator() const

+ Here is the call graph for this function:

Member Data Documentation

bool QueryPlanDagChecker::contain_not_supported_node_
private

Definition at line 63 of file QueryPlanDagChecker.h.

Referenced by detectNotSupportedNode(), getCheckResult(), and reset().

const std::unordered_set<std::string> QueryPlanDagChecker::not_supported_functions_
private

Definition at line 65 of file QueryPlanDagChecker.h.

Referenced by visit().

const RelAlgTranslator& QueryPlanDagChecker::rel_alg_translator_
private

Definition at line 64 of file QueryPlanDagChecker.h.

Referenced by visit().


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