OmniSciDB  cde582ebc3
 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 ()
 
void check (const RelAlgNode *)
 
void detectNonSupportedNode (const std::string &node_tag)
 
void reset ()
 
bool getCheckResult () const
 
std::string const & getNonSupportedNodeTag () const
 
- Public Member Functions inherited from RelRexDagVisitor
virtual ~RelRexDagVisitor ()=default
 
virtual void visit (RelAlgNode const *)
 
virtual void visit (RexScalar const *)
 

Static Public Member Functions

static std::unordered_set
< std::string > 
getNonSupportedFunctionsList ()
 
static std::pair< bool,
std::string > 
hasNonSupportedNodeInDag (const RelAlgNode *rel_alg_node)
 

Private Member Functions

void visit (const RelLogicalValues *) override
 
void visit (const RelModify *) 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 detect_non_supported_node_
 
std::string non_supported_node_tag_
 
const std::unordered_set
< std::string > 
non_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 (RelTableFunction const *)
 
virtual void visit (RelTranslatedJoin 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 *)
 
void castAndVisit (RelAlgNode const *)
 

Detailed Description

Definition at line 25 of file QueryPlanDagChecker.h.

Constructor & Destructor Documentation

QueryPlanDagChecker::QueryPlanDagChecker ( )
inline

Definition at line 27 of file QueryPlanDagChecker.h.

std::string non_supported_node_tag_
const std::unordered_set< std::string > non_supported_functions_
static std::unordered_set< std::string > getNonSupportedFunctionsList()

Member Function Documentation

void QueryPlanDagChecker::check ( const RelAlgNode rel_alg_node)

Definition at line 35 of file QueryPlanDagChecker.cpp.

References RelRexDagVisitor::visit().

Referenced by hasNonSupportedNodeInDag().

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

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void QueryPlanDagChecker::detectNonSupportedNode ( const std::string &  node_tag)

Definition at line 23 of file QueryPlanDagChecker.cpp.

References detect_non_supported_node_, and non_supported_node_tag_.

Referenced by visit().

23  {
25  non_supported_node_tag_ = node_tag;
26 }
std::string non_supported_node_tag_

+ Here is the caller graph for this function:

bool QueryPlanDagChecker::getCheckResult ( ) const

Definition at line 19 of file QueryPlanDagChecker.cpp.

References detect_non_supported_node_.

Referenced by hasNonSupportedNodeInDag(), and visit().

19  {
21 }

+ Here is the caller graph for this function:

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

Definition at line 31 of file QueryPlanDagChecker.h.

31  {
32  std::unordered_set<std::string> non_supported_functions;
33  non_supported_functions.emplace("CURRENT_USER");
34  non_supported_functions.emplace("CURRENT_TIME");
35  non_supported_functions.emplace("CURRENT_DATE");
36  non_supported_functions.emplace("CURRENT_TIMESTAMP");
37  non_supported_functions.emplace("CARDINALITY");
38  non_supported_functions.emplace("ARRAY_LENGTH");
39  non_supported_functions.emplace("ITEM");
40  non_supported_functions.emplace("NOW");
41  non_supported_functions.emplace("SIGN");
42  non_supported_functions.emplace("OFFSET_IN_FRAGMENT");
43  non_supported_functions.emplace("DATETIME");
44  return non_supported_functions;
45  }
const std::string & QueryPlanDagChecker::getNonSupportedNodeTag ( ) const

Definition at line 134 of file QueryPlanDagChecker.cpp.

References non_supported_node_tag_.

Referenced by hasNonSupportedNodeInDag().

134  {
136 }
std::string non_supported_node_tag_

+ Here is the caller graph for this function:

std::pair< bool, std::string > QueryPlanDagChecker::hasNonSupportedNodeInDag ( const RelAlgNode rel_alg_node)
static

Definition at line 28 of file QueryPlanDagChecker.cpp.

References check(), getCheckResult(), and getNonSupportedNodeTag().

Referenced by QueryPlanDagExtractor::extractQueryPlanDag().

29  {
30  QueryPlanDagChecker checker;
31  checker.check(rel_alg_node);
32  return std::make_pair(checker.getCheckResult(), checker.getNonSupportedNodeTag());
33 }
void check(const RelAlgNode *)
std::string const & getNonSupportedNodeTag() const

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void QueryPlanDagChecker::reset ( )

Definition at line 129 of file QueryPlanDagChecker.cpp.

References detect_non_supported_node_, and non_supported_node_tag_.

129  {
132 }
std::string non_supported_node_tag_
void QueryPlanDagChecker::visit ( const RelLogicalValues rel_alg_node)
overrideprivatevirtual

Reimplemented from RelRexDagVisitor.

Definition at line 39 of file QueryPlanDagChecker.cpp.

References detectNonSupportedNode().

39  {
40  detectNonSupportedNode("Detect RelLogicalValues node");
41  return;
42 }
void detectNonSupportedNode(const std::string &node_tag)

+ Here is the call graph for this function:

void QueryPlanDagChecker::visit ( const RelModify rel_alg_node)
overrideprivatevirtual

Reimplemented from RelRexDagVisitor.

Definition at line 44 of file QueryPlanDagChecker.cpp.

References detectNonSupportedNode().

44  {
45  detectNonSupportedNode("Detect RelModify node");
46  return;
47 }
void detectNonSupportedNode(const std::string &node_tag)

+ Here is the call graph for this function:

void QueryPlanDagChecker::visit ( const RelProject rel_alg_node)
overrideprivatevirtual

Reimplemented from RelRexDagVisitor.

Definition at line 49 of file QueryPlanDagChecker.cpp.

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

49  {
50  if (rel_alg_node->isDeleteViaSelect() || rel_alg_node->isUpdateViaSelect() ||
51  rel_alg_node->isVarlenUpdateRequired()) {
52  detectNonSupportedNode("Executing UPDATE/MODITY/DELETE query");
53  return;
54  }
55  RelRexDagVisitor::visit(rel_alg_node);
56 }
virtual void visit(RelAlgNode const *)
void detectNonSupportedNode(const std::string &node_tag)
auto const isDeleteViaSelect() const
Definition: RelAlgDag.h:1000
auto const isUpdateViaSelect() const
Definition: RelAlgDag.h:999
auto const isVarlenUpdateRequired() const
Definition: RelAlgDag.h:1001

+ Here is the call graph for this function:

void QueryPlanDagChecker::visit ( const RelScan rel_alg_node)
overrideprivatevirtual

Reimplemented from RelRexDagVisitor.

Definition at line 87 of file QueryPlanDagChecker.cpp.

References detectNonSupportedNode(), RelScan::getTableDescriptor(), TableDescriptor::is_system_table, TableDescriptor::isForeignTable(), TableDescriptor::isTemporaryTable(), and RelRexDagVisitor::visit().

87  {
88  if (rel_alg_node->getTableDescriptor()->isForeignTable()) {
89  detectNonSupportedNode("Detect foreign table");
90  return;
91  }
92  if (rel_alg_node->getTableDescriptor()->isTemporaryTable()) {
93  detectNonSupportedNode("Detect temporary table");
94  }
95 
96  if (rel_alg_node->getTableDescriptor()->is_system_table) {
97  detectNonSupportedNode("Detect system table");
98  }
99  RelRexDagVisitor::visit(rel_alg_node);
100 }
virtual void visit(RelAlgNode const *)
bool isForeignTable() const
bool isTemporaryTable() const
void detectNonSupportedNode(const std::string &node_tag)
const TableDescriptor * getTableDescriptor() const
Definition: RelAlgDag.h:911

+ Here is the call graph for this function:

void QueryPlanDagChecker::visit ( const RelCompound rel_alg_node)
overrideprivatevirtual

Reimplemented from RelRexDagVisitor.

Definition at line 58 of file QueryPlanDagChecker.cpp.

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

58  {
59  if (rel_alg_node->isDeleteViaSelect() || rel_alg_node->isUpdateViaSelect() ||
60  rel_alg_node->isVarlenUpdateRequired()) {
61  detectNonSupportedNode("Executing UPDATE/MODITY/DELETE query");
62  return;
63  }
64  // SINGLE_VALUE / SAMPLE query
65  if (rel_alg_node->isAggregate() && rel_alg_node->size() > 0) {
66  for (size_t i = 0; i < rel_alg_node->size(); ++i) {
67  auto target_expr = rel_alg_node->getTargetExpr(i);
68  auto agg_expr = dynamic_cast<const RexAgg*>(target_expr);
69  if (agg_expr && (agg_expr->getKind() == SQLAgg::kSINGLE_VALUE ||
70  agg_expr->getKind() == SQLAgg::kSAMPLE ||
71  agg_expr->getKind() == SQLAgg::kAPPROX_QUANTILE)) {
73  "Detect non-supported aggregation function: "
74  "SINGLE_VALUE/SAMPLE/APPROX_QUANTILE");
75  return;
76  }
77  }
78  }
79  RelRexDagVisitor::visit(rel_alg_node);
80 }
const Rex * getTargetExpr(const size_t i) const
Definition: RelAlgDag.h:1679
virtual void visit(RelAlgNode const *)
size_t size() const override
Definition: RelAlgDag.h:1671
void detectNonSupportedNode(const std::string &node_tag)
auto const isDeleteViaSelect() const
Definition: RelAlgDag.h:1000
bool isAggregate() const
Definition: RelAlgDag.h:1700
auto const isUpdateViaSelect() const
Definition: RelAlgDag.h:999
auto const isVarlenUpdateRequired() const
Definition: RelAlgDag.h:1001

+ Here is the call graph for this function:

void QueryPlanDagChecker::visit ( const RelLogicalUnion rel_alg_node)
overrideprivatevirtual

Reimplemented from RelRexDagVisitor.

Definition at line 82 of file QueryPlanDagChecker.cpp.

References detectNonSupportedNode().

82  {
83  detectNonSupportedNode("Detect RelLogicalUnion node");
84  return;
85 }
void detectNonSupportedNode(const std::string &node_tag)

+ Here is the call graph for this function:

void QueryPlanDagChecker::visit ( const RexFunctionOperator rex_node)
overrideprivatevirtual

Reimplemented from RelRexDagVisitor.

Definition at line 115 of file QueryPlanDagChecker.cpp.

References detectNonSupportedNode(), getCheckResult(), RexFunctionOperator::getName(), RexOperator::getOperand(), non_supported_functions_, RexOperator::size(), and RelRexDagVisitor::visit().

115  {
116  if (non_supported_functions_.count(rex_node->getName())) {
117  detectNonSupportedNode("Detect non-supported function: " + rex_node->getName());
118  }
119  if (getCheckResult()) {
120  return;
121  }
122  for (size_t i = 0; i < rex_node->size(); ++i) {
123  if (rex_node->getOperand(i)) {
124  RelRexDagVisitor::visit(rex_node->getOperand(i));
125  }
126  }
127 }
virtual void visit(RelAlgNode const *)
size_t size() const
Definition: RelAlgDag.h:245
const RexScalar * getOperand(const size_t idx) const
Definition: RelAlgDag.h:247
const std::unordered_set< std::string > non_supported_functions_
void detectNonSupportedNode(const std::string &node_tag)
const std::string & getName() const
Definition: RelAlgDag.h:452

+ Here is the call graph for this function:

void QueryPlanDagChecker::visit ( const RexOperator rex_node)
overrideprivatevirtual

Reimplemented from RelRexDagVisitor.

Definition at line 102 of file QueryPlanDagChecker.cpp.

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

102  {
103  // prevent too heavy IN clause containing more than 20 values to check
104  if (rex_node->getOperator() == SQLOps::kOR && rex_node->size() > 20) {
105  detectNonSupportedNode("Detect heavy IN-clause having more than 20 values");
106  return;
107  }
108  for (size_t i = 0; i < rex_node->size(); ++i) {
109  if (rex_node->getOperand(i)) {
110  RelRexDagVisitor::visit(rex_node->getOperand(i));
111  }
112  }
113 }
virtual void visit(RelAlgNode const *)
size_t size() const
Definition: RelAlgDag.h:245
const RexScalar * getOperand(const size_t idx) const
Definition: RelAlgDag.h:247
Definition: sqldefs.h:37
SQLOps getOperator() const
Definition: RelAlgDag.h:257
void detectNonSupportedNode(const std::string &node_tag)

+ Here is the call graph for this function:

Member Data Documentation

bool QueryPlanDagChecker::detect_non_supported_node_
private

Definition at line 66 of file QueryPlanDagChecker.h.

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

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

Definition at line 68 of file QueryPlanDagChecker.h.

Referenced by visit().

std::string QueryPlanDagChecker::non_supported_node_tag_
private

Definition at line 67 of file QueryPlanDagChecker.h.

Referenced by detectNonSupportedNode(), getNonSupportedNodeTag(), and reset().


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