OmniSciDB  04ee39c94c
RelAlgAbstractInterpreter.h File Reference
#include "../Catalog/Catalog.h"
#include "../Shared/ConfigResolve.h"
#include "../Shared/Rendering/RenderQueryOptions.h"
#include "../Shared/sql_window_function_to_string.h"
#include "TargetMetaInfo.h"
#include "TypePunning.h"
#include <rapidjson/document.h>
#include <boost/make_unique.hpp>
#include <boost/utility.hpp>
#include <boost/variant.hpp>
#include <iterator>
#include <memory>
#include <unordered_map>
+ Include dependency graph for RelAlgAbstractInterpreter.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  Rex
 
class  RexScalar
 
class  RexAbstractInput
 
class  RexLiteral
 
class  RexOperator
 
class  RexSubQuery
 
class  RexInput
 
struct  std::hash< RexInput >
 
class  RexCase
 
class  RexFunctionOperator
 
class  SortField
 
class  RexWindowFunctionOperator
 
struct  RexWindowFunctionOperator::RexWindowBound
 
class  RexRef
 
class  RexAgg
 
class  RelAlgNode
 
class  RelScan
 
class  ModifyManipulationTarget
 
class  RelProject
 
class  RelAggregate
 
class  RelJoin
 
class  RelFilter
 
class  RelLeftDeepInnerJoin
 
class  RelCompound
 
class  RelSort
 
class  RelModify
 
class  RelLogicalValues
 
class  QueryNotSupported
 

Namespaces

 std
 

Typedefs

using ColumnNameList = std::vector< std::string >
 
using RexLiteralArray = std::vector< RexLiteral >
 
using TupleContentsArray = std::vector< RexLiteralArray >
 
using RANodeOutput = std::vector< RexInput >
 

Enumerations

enum  SortDirection { SortDirection::Ascending, SortDirection::Descending }
 
enum  NullSortedPosition { NullSortedPosition::First, NullSortedPosition::Last }
 

Functions

std::shared_ptr< const RelAlgNodedeserialize_ra_dag (const std::string &query_ra, const Catalog_Namespace::Catalog &cat, RelAlgExecutor *ra_executor, const RenderQueryOptions *render_opts=nullptr)
 
std::string tree_string (const RelAlgNode *, const size_t indent=0)
 
RANodeOutput get_node_output (const RelAlgNode *ra_node)
 

Typedef Documentation

◆ ColumnNameList

using ColumnNameList = std::vector<std::string>

Definition at line 37 of file RelAlgAbstractInterpreter.h.

◆ RANodeOutput

using RANodeOutput = std::vector<RexInput>

Definition at line 1396 of file RelAlgAbstractInterpreter.h.

◆ RexLiteralArray

using RexLiteralArray = std::vector<RexLiteral>

Definition at line 210 of file RelAlgAbstractInterpreter.h.

◆ TupleContentsArray

using TupleContentsArray = std::vector<RexLiteralArray>

Definition at line 211 of file RelAlgAbstractInterpreter.h.

Enumeration Type Documentation

◆ NullSortedPosition

enum NullSortedPosition
strong
Enumerator
First 
Last 

Definition at line 424 of file RelAlgAbstractInterpreter.h.

◆ SortDirection

enum SortDirection
strong
Enumerator
Ascending 
Descending 

Definition at line 422 of file RelAlgAbstractInterpreter.h.

Function Documentation

◆ deserialize_ra_dag()

std::shared_ptr<const RelAlgNode> deserialize_ra_dag ( const std::string &  query_ra,
const Catalog_Namespace::Catalog cat,
RelAlgExecutor ra_executor,
const RenderQueryOptions render_opts = nullptr 
)

Definition at line 1671 of file RelAlgAbstractInterpreter.cpp.

References CHECK, anonymous_namespace{RelAlgAbstractInterpreter.cpp}::ra_interpret(), and RelAlgNode::resetRelAlgFirstId().

Referenced by RelAlgExecutor::executeRelAlgQueryNoRetry(), and QueryNotSupported::QueryNotSupported().

1675  {
1676  rapidjson::Document query_ast;
1677  query_ast.Parse(query_ra.c_str());
1678  CHECK(!query_ast.HasParseError());
1679  CHECK(query_ast.IsObject());
1681  return ra_interpret(query_ast, cat, ra_executor, render_opts);
1682 }
std::shared_ptr< const RelAlgNode > ra_interpret(const rapidjson::Value &query_ast, const Catalog_Namespace::Catalog &cat, RelAlgExecutor *ra_executor, const RenderQueryOptions *render_opts)
#define CHECK(condition)
Definition: Logger.h:187
static void resetRelAlgFirstId() noexcept
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ get_node_output()

RANodeOutput get_node_output ( const RelAlgNode ra_node)

Definition at line 109 of file RelAlgAbstractInterpreter.cpp.

References CHECK, CHECK_EQ, get_node_output(), anonymous_namespace{RelAlgAbstractInterpreter.cpp}::n_outputs(), and RelAlgNode::size().

Referenced by anonymous_namespace{RelAlgAbstractInterpreter.cpp}::bind_inputs(), anonymous_namespace{RelAlgAbstractInterpreter.cpp}::create_compound(), anonymous_namespace{RelAlgExecutor.cpp}::get_left_deep_join_input_sizes(), get_node_output(), RelProject::isIdentity(), anonymous_namespace{QueryPhysicalInputsCollector.cpp}::RexPhysicalInputsVisitor::visitInput(), and anonymous_namespace{QueryPhysicalInputsCollector.cpp}::RexPhysicalInputsVisitor::visitOperator().

109  {
110  RANodeOutput outputs;
111  const auto scan_node = dynamic_cast<const RelScan*>(ra_node);
112  if (scan_node) {
113  // Scan node has no inputs, output contains all columns in the table.
114  CHECK_EQ(size_t(0), scan_node->inputCount());
115  return n_outputs(scan_node, scan_node->size());
116  }
117  const auto project_node = dynamic_cast<const RelProject*>(ra_node);
118  if (project_node) {
119  // Project output count doesn't depend on the input
120  CHECK_EQ(size_t(1), project_node->inputCount());
121  return n_outputs(project_node, project_node->size());
122  }
123  const auto filter_node = dynamic_cast<const RelFilter*>(ra_node);
124  if (filter_node) {
125  // Filter preserves shape
126  CHECK_EQ(size_t(1), filter_node->inputCount());
127  const auto prev_out = get_node_output(filter_node->getInput(0));
128  return n_outputs(filter_node, prev_out.size());
129  }
130  const auto aggregate_node = dynamic_cast<const RelAggregate*>(ra_node);
131  if (aggregate_node) {
132  // Aggregate output count doesn't depend on the input
133  CHECK_EQ(size_t(1), aggregate_node->inputCount());
134  return n_outputs(aggregate_node, aggregate_node->size());
135  }
136  const auto compound_node = dynamic_cast<const RelCompound*>(ra_node);
137  if (compound_node) {
138  // Compound output count doesn't depend on the input
139  CHECK_EQ(size_t(1), compound_node->inputCount());
140  return n_outputs(compound_node, compound_node->size());
141  }
142  const auto join_node = dynamic_cast<const RelJoin*>(ra_node);
143  if (join_node) {
144  // Join concatenates the outputs from the inputs and the output
145  // directly references the nodes in the input.
146  CHECK_EQ(size_t(2), join_node->inputCount());
147  auto lhs_out =
148  n_outputs(join_node->getInput(0), get_node_output(join_node->getInput(0)).size());
149  const auto rhs_out =
150  n_outputs(join_node->getInput(1), get_node_output(join_node->getInput(1)).size());
151  lhs_out.insert(lhs_out.end(), rhs_out.begin(), rhs_out.end());
152  return lhs_out;
153  }
154  const auto sort_node = dynamic_cast<const RelSort*>(ra_node);
155  if (sort_node) {
156  // Sort preserves shape
157  CHECK_EQ(size_t(1), sort_node->inputCount());
158  const auto prev_out = get_node_output(sort_node->getInput(0));
159  return n_outputs(sort_node, prev_out.size());
160  }
161  const auto logical_values_node = dynamic_cast<const RelLogicalValues*>(ra_node);
162  if (logical_values_node) {
163  CHECK_EQ(size_t(0), logical_values_node->inputCount());
164  return n_outputs(logical_values_node, logical_values_node->size());
165  }
166  CHECK(false);
167  return outputs;
168 }
#define CHECK_EQ(x, y)
Definition: Logger.h:195
std::vector< RexInput > n_outputs(const RelAlgNode *node, const size_t n)
std::vector< RexInput > RANodeOutput
RANodeOutput get_node_output(const RelAlgNode *ra_node)
#define CHECK(condition)
Definition: Logger.h:187
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ tree_string()

std::string tree_string ( const RelAlgNode ,
const size_t  indent = 0 
)

Definition at line 1685 of file RelAlgAbstractInterpreter.cpp.

References RelAlgNode::getInput(), RelAlgNode::inputCount(), run-benchmark-import::result, RelAlgNode::toString(), and tree_string().

Referenced by QueryNotSupported::QueryNotSupported(), and tree_string().

1685  {
1686  std::string result = std::string(indent, ' ') + ra->toString() + "\n";
1687  for (size_t i = 0; i < ra->inputCount(); ++i) {
1688  result += tree_string(ra->getInput(i), indent + 2);
1689  }
1690  return result;
1691 }
std::string tree_string(const RelAlgNode *ra, const size_t indent)
+ Here is the call graph for this function:
+ Here is the caller graph for this function: