OmniSciDB  2b310ab3b2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
RelAlgDagBuilder.cpp File Reference
#include "RelAlgDagBuilder.h"
#include "../Shared/sqldefs.h"
#include "CalciteDeserializerUtils.h"
#include "Catalog/Catalog.h"
#include "Descriptors/RelAlgExecutionDescriptor.h"
#include "JsonAccessors.h"
#include "RelAlgOptimizer.h"
#include "RelLeftDeepInnerJoin.h"
#include "Rendering/RenderRelAlgUtils.h"
#include "RexVisitor.h"
#include <rapidjson/error/en.h>
#include <rapidjson/error/error.h>
#include <rapidjson/stringbuffer.h>
#include <rapidjson/writer.h>
#include <string>
#include <unordered_set>
+ Include dependency graph for RelAlgDagBuilder.cpp:

Go to the source code of this file.

Classes

class  anonymous_namespace{RelAlgDagBuilder.cpp}::RexRebindInputsVisitor
 
class  anonymous_namespace{RelAlgDagBuilder.cpp}::RexRebindReindexInputsVisitor
 
struct  std::hash< std::pair< const RelAlgNode *, int > >
 
class  anonymous_namespace{RelAlgDagBuilder.cpp}::anonymous_namespace{RelAlgDagBuilder.cpp}::RexInputReplacementVisitor
 
class  anonymous_namespace{RelAlgDagBuilder.cpp}::RANodeIterator
 
class  anonymous_namespace{RelAlgDagBuilder.cpp}::anonymous_namespace{RelAlgDagBuilder.cpp}::CoalesceSecondaryProjectVisitor
 
class  anonymous_namespace{RelAlgDagBuilder.cpp}::WindowFunctionDetectionVisitor
 
class  anonymous_namespace{RelAlgDagBuilder.cpp}::RexWindowFuncReplacementVisitor
 
class  anonymous_namespace{RelAlgDagBuilder.cpp}::RexInputBackpropagationVisitor
 
class  anonymous_namespace{RelAlgDagBuilder.cpp}::RexInputCollector
 
class  details::RelAlgDispatcher
 

Namespaces

 anonymous_namespace{RelAlgDagBuilder.cpp}
 
 std
 
 anonymous_namespace{RelAlgDagBuilder.cpp}::anonymous_namespace{RelAlgDagBuilder.cpp}
 
 details
 

Typedefs

using anonymous_namespace{RelAlgDagBuilder.cpp}::RexInputSet = std::unordered_set< RexInput >
 

Functions

std::vector< RexInputanonymous_namespace{RelAlgDagBuilder.cpp}::n_outputs (const RelAlgNode *node, const size_t n)
 
RANodeOutput get_node_output (const RelAlgNode *ra_node)
 
bool anonymous_namespace{RelAlgDagBuilder.cpp}::isRenamedInput (const RelAlgNode *node, const size_t index, const std::string &new_name)
 
std::vector< std::unique_ptr
< const RexAgg > > 
anonymous_namespace{RelAlgDagBuilder.cpp}::copyAggExprs (std::vector< std::unique_ptr< const RexAgg >> const &agg_exprs)
 
std::vector< std::unique_ptr
< const RexScalar > > 
anonymous_namespace{RelAlgDagBuilder.cpp}::copyRexScalars (std::vector< std::unique_ptr< const RexScalar >> const &scalar_sources)
 
std::vector< const Rex * > anonymous_namespace{RelAlgDagBuilder.cpp}::remapTargetPointers (std::vector< std::unique_ptr< const RexAgg >> const &agg_exprs_new, std::vector< std::unique_ptr< const RexScalar >> const &scalar_sources_new, std::vector< std::unique_ptr< const RexAgg >> const &agg_exprs_old, std::vector< std::unique_ptr< const RexScalar >> const &scalar_sources_old, std::vector< const Rex * > const &target_exprs_old)
 
std::set< std::pair< const
RelAlgNode *, int > > 
anonymous_namespace{RelAlgDagBuilder.cpp}::get_equiv_cols (const RelAlgNode *node, const size_t which_col)
 
unsigned anonymous_namespace{RelAlgDagBuilder.cpp}::node_id (const rapidjson::Value &ra_node) noexcept
 
std::string anonymous_namespace{RelAlgDagBuilder.cpp}::json_node_to_string (const rapidjson::Value &node) noexcept
 
std::unique_ptr< RexAbstractInputanonymous_namespace{RelAlgDagBuilder.cpp}::parse_abstract_input (const rapidjson::Value &expr) noexcept
 
std::unique_ptr< RexLiteralanonymous_namespace{RelAlgDagBuilder.cpp}::parse_literal (const rapidjson::Value &expr)
 
std::unique_ptr< const RexScalaranonymous_namespace{RelAlgDagBuilder.cpp}::parse_scalar_expr (const rapidjson::Value &expr, const Catalog_Namespace::Catalog &cat, RelAlgDagBuilder &root_dag_builder)
 
SQLTypeInfo anonymous_namespace{RelAlgDagBuilder.cpp}::parse_type (const rapidjson::Value &type_obj)
 
std::vector< std::unique_ptr
< const RexScalar > > 
anonymous_namespace{RelAlgDagBuilder.cpp}::parse_expr_array (const rapidjson::Value &arr, const Catalog_Namespace::Catalog &cat, RelAlgDagBuilder &root_dag_builder)
 
SqlWindowFunctionKind anonymous_namespace{RelAlgDagBuilder.cpp}::parse_window_function_kind (const std::string &name)
 
std::vector< std::unique_ptr
< const RexScalar > > 
anonymous_namespace{RelAlgDagBuilder.cpp}::parse_window_order_exprs (const rapidjson::Value &arr, const Catalog_Namespace::Catalog &cat, RelAlgDagBuilder &root_dag_builder)
 
SortDirection anonymous_namespace{RelAlgDagBuilder.cpp}::parse_sort_direction (const rapidjson::Value &collation)
 
NullSortedPosition anonymous_namespace{RelAlgDagBuilder.cpp}::parse_nulls_position (const rapidjson::Value &collation)
 
std::vector< SortFieldanonymous_namespace{RelAlgDagBuilder.cpp}::parse_window_order_collation (const rapidjson::Value &arr, const Catalog_Namespace::Catalog &cat, RelAlgDagBuilder &root_dag_builder)
 
RexWindowFunctionOperator::RexWindowBound anonymous_namespace{RelAlgDagBuilder.cpp}::parse_window_bound (const rapidjson::Value &window_bound_obj, const Catalog_Namespace::Catalog &cat, RelAlgDagBuilder &root_dag_builder)
 
std::unique_ptr< const
RexSubQuery
anonymous_namespace{RelAlgDagBuilder.cpp}::parse_subquery (const rapidjson::Value &expr, const Catalog_Namespace::Catalog &cat, RelAlgDagBuilder &root_dag_builder)
 
std::unique_ptr< RexOperatoranonymous_namespace{RelAlgDagBuilder.cpp}::parse_operator (const rapidjson::Value &expr, const Catalog_Namespace::Catalog &cat, RelAlgDagBuilder &root_dag_builder)
 
std::unique_ptr< RexCaseanonymous_namespace{RelAlgDagBuilder.cpp}::parse_case (const rapidjson::Value &expr, const Catalog_Namespace::Catalog &cat, RelAlgDagBuilder &root_dag_builder)
 
std::vector< std::string > anonymous_namespace{RelAlgDagBuilder.cpp}::strings_from_json_array (const rapidjson::Value &json_str_arr) noexcept
 
std::vector< size_t > anonymous_namespace{RelAlgDagBuilder.cpp}::indices_from_json_array (const rapidjson::Value &json_idx_arr) noexcept
 
std::unique_ptr< const RexAgganonymous_namespace{RelAlgDagBuilder.cpp}::parse_aggregate_expr (const rapidjson::Value &expr)
 
JoinType anonymous_namespace{RelAlgDagBuilder.cpp}::to_join_type (const std::string &join_type_name)
 
std::unique_ptr< const RexScalaranonymous_namespace{RelAlgDagBuilder.cpp}::disambiguate_rex (const RexScalar *, const RANodeOutput &)
 
std::unique_ptr< const
RexOperator
anonymous_namespace{RelAlgDagBuilder.cpp}::disambiguate_operator (const RexOperator *rex_operator, const RANodeOutput &ra_output) noexcept
 
std::unique_ptr< const RexCaseanonymous_namespace{RelAlgDagBuilder.cpp}::disambiguate_case (const RexCase *rex_case, const RANodeOutput &ra_output)
 
void anonymous_namespace{RelAlgDagBuilder.cpp}::bind_project_to_input (RelProject *project_node, const RANodeOutput &input) noexcept
 
void anonymous_namespace{RelAlgDagBuilder.cpp}::bind_table_func_to_input (RelTableFunction *table_func_node, const RANodeOutput &input) noexcept
 
void anonymous_namespace{RelAlgDagBuilder.cpp}::bind_inputs (const std::vector< std::shared_ptr< RelAlgNode >> &nodes) noexcept
 
void anonymous_namespace{RelAlgDagBuilder.cpp}::handleQueryHint (const std::vector< std::shared_ptr< RelAlgNode >> &nodes, RelAlgDagBuilder *dag_builder) noexcept
 
void anonymous_namespace{RelAlgDagBuilder.cpp}::mark_nops (const std::vector< std::shared_ptr< RelAlgNode >> &nodes) noexcept
 
std::vector< const Rex * > anonymous_namespace{RelAlgDagBuilder.cpp}::anonymous_namespace{RelAlgDagBuilder.cpp}::reproject_targets (const RelProject *simple_project, const std::vector< const Rex * > &target_exprs) noexcept
 
void anonymous_namespace{RelAlgDagBuilder.cpp}::create_compound (std::vector< std::shared_ptr< RelAlgNode >> &nodes, const std::vector< size_t > &pattern) noexcept
 
bool anonymous_namespace{RelAlgDagBuilder.cpp}::anonymous_namespace{RelAlgDagBuilder.cpp}::input_can_be_coalesced (const RelAlgNode *parent_node, const size_t index, const bool first_rex_is_input)
 
bool anonymous_namespace{RelAlgDagBuilder.cpp}::anonymous_namespace{RelAlgDagBuilder.cpp}::is_window_function_sum (const RexScalar *rex)
 
bool anonymous_namespace{RelAlgDagBuilder.cpp}::anonymous_namespace{RelAlgDagBuilder.cpp}::is_window_function_operator (const RexScalar *rex)
 
void anonymous_namespace{RelAlgDagBuilder.cpp}::coalesce_nodes (std::vector< std::shared_ptr< RelAlgNode >> &nodes, const std::vector< const RelAlgNode * > &left_deep_joins)
 
void anonymous_namespace{RelAlgDagBuilder.cpp}::separate_window_function_expressions (std::vector< std::shared_ptr< RelAlgNode >> &nodes)
 
void anonymous_namespace{RelAlgDagBuilder.cpp}::add_window_function_pre_project (std::vector< std::shared_ptr< RelAlgNode >> &nodes)
 
int64_t anonymous_namespace{RelAlgDagBuilder.cpp}::get_int_literal_field (const rapidjson::Value &obj, const char field[], const int64_t default_val) noexcept
 
void anonymous_namespace{RelAlgDagBuilder.cpp}::check_empty_inputs_field (const rapidjson::Value &node) noexcept
 
const TableDescriptoranonymous_namespace{RelAlgDagBuilder.cpp}::getTableFromScanNode (const Catalog_Namespace::Catalog &cat, const rapidjson::Value &scan_ra)
 
std::vector< std::string > anonymous_namespace{RelAlgDagBuilder.cpp}::getFieldNamesFromScanNode (const rapidjson::Value &scan_ra)
 
std::string tree_string (const RelAlgNode *ra, const size_t depth)
 

Variables

bool g_cluster
 
bool g_enable_union
 
const unsigned anonymous_namespace{RelAlgDagBuilder.cpp}::FIRST_RA_NODE_ID = 1
 

Function Documentation

RANodeOutput get_node_output ( const RelAlgNode ra_node)

Definition at line 152 of file RelAlgDagBuilder.cpp.

References CHECK_EQ, logger::FATAL, get_node_output(), LOG, anonymous_namespace{RelAlgDagBuilder.cpp}::n_outputs(), and RelAlgNode::toString().

Referenced by anonymous_namespace{RelAlgDagBuilder.cpp}::bind_inputs(), anonymous_namespace{RelAlgDagBuilder.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().

152  {
153  const auto scan_node = dynamic_cast<const RelScan*>(ra_node);
154  if (scan_node) {
155  // Scan node has no inputs, output contains all columns in the table.
156  CHECK_EQ(size_t(0), scan_node->inputCount());
157  return n_outputs(scan_node, scan_node->size());
158  }
159  const auto project_node = dynamic_cast<const RelProject*>(ra_node);
160  if (project_node) {
161  // Project output count doesn't depend on the input
162  CHECK_EQ(size_t(1), project_node->inputCount());
163  return n_outputs(project_node, project_node->size());
164  }
165  const auto filter_node = dynamic_cast<const RelFilter*>(ra_node);
166  if (filter_node) {
167  // Filter preserves shape
168  CHECK_EQ(size_t(1), filter_node->inputCount());
169  const auto prev_out = get_node_output(filter_node->getInput(0));
170  return n_outputs(filter_node, prev_out.size());
171  }
172  const auto aggregate_node = dynamic_cast<const RelAggregate*>(ra_node);
173  if (aggregate_node) {
174  // Aggregate output count doesn't depend on the input
175  CHECK_EQ(size_t(1), aggregate_node->inputCount());
176  return n_outputs(aggregate_node, aggregate_node->size());
177  }
178  const auto compound_node = dynamic_cast<const RelCompound*>(ra_node);
179  if (compound_node) {
180  // Compound output count doesn't depend on the input
181  CHECK_EQ(size_t(1), compound_node->inputCount());
182  return n_outputs(compound_node, compound_node->size());
183  }
184  const auto join_node = dynamic_cast<const RelJoin*>(ra_node);
185  if (join_node) {
186  // Join concatenates the outputs from the inputs and the output
187  // directly references the nodes in the input.
188  CHECK_EQ(size_t(2), join_node->inputCount());
189  auto lhs_out =
190  n_outputs(join_node->getInput(0), get_node_output(join_node->getInput(0)).size());
191  const auto rhs_out =
192  n_outputs(join_node->getInput(1), get_node_output(join_node->getInput(1)).size());
193  lhs_out.insert(lhs_out.end(), rhs_out.begin(), rhs_out.end());
194  return lhs_out;
195  }
196  const auto table_func_node = dynamic_cast<const RelTableFunction*>(ra_node);
197  if (table_func_node) {
198  // Table Function output count doesn't depend on the input
199  return n_outputs(table_func_node, table_func_node->size());
200  }
201  const auto sort_node = dynamic_cast<const RelSort*>(ra_node);
202  if (sort_node) {
203  // Sort preserves shape
204  CHECK_EQ(size_t(1), sort_node->inputCount());
205  const auto prev_out = get_node_output(sort_node->getInput(0));
206  return n_outputs(sort_node, prev_out.size());
207  }
208  const auto logical_values_node = dynamic_cast<const RelLogicalValues*>(ra_node);
209  if (logical_values_node) {
210  CHECK_EQ(size_t(0), logical_values_node->inputCount());
211  return n_outputs(logical_values_node, logical_values_node->size());
212  }
213  const auto logical_union_node = dynamic_cast<const RelLogicalUnion*>(ra_node);
214  if (logical_union_node) {
215  return n_outputs(logical_union_node, logical_union_node->size());
216  }
217  LOG(FATAL) << "Unhandled ra_node type: " << ra_node->toString();
218  return {};
219 }
#define CHECK_EQ(x, y)
Definition: Logger.h:205
#define LOG(tag)
Definition: Logger.h:188
virtual std::string toString() const =0
RANodeOutput get_node_output(const RelAlgNode *ra_node)
std::vector< RexInput > n_outputs(const RelAlgNode *node, const size_t n)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

std::string tree_string ( const RelAlgNode ra,
const size_t  depth 
)

Definition at line 2674 of file RelAlgDagBuilder.cpp.

References RelAlgNode::getInput(), RelAlgNode::inputCount(), run_benchmark_import::result, RelAlgNode::toString(), and tree_string().

Referenced by tree_string().

2674  {
2675  std::string result = std::string(2 * depth, ' ') + ra->toString() + '\n';
2676  for (size_t i = 0; i < ra->inputCount(); ++i) {
2677  result += tree_string(ra->getInput(i), depth + 1);
2678  }
2679  return result;
2680 }
const RelAlgNode * getInput(const size_t idx) const
std::string tree_string(const RelAlgNode *ra, const size_t depth)
virtual std::string toString() const =0
const size_t inputCount() const

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Variable Documentation

bool g_cluster