OmniSciDB  085a039ca4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
anonymous_namespace{RelAlgDagBuilder.cpp}::anonymous_namespace{RelAlgDagBuilder.cpp} Namespace Reference

Classes

class  RexInputReplacementVisitor
 
class  CoalesceSecondaryProjectVisitor
 

Functions

std::vector< const Rex * > reproject_targets (const RelProject *simple_project, const std::vector< const Rex * > &target_exprs) noexcept
 
bool input_can_be_coalesced (const RelAlgNode *parent_node, const size_t index, const bool first_rex_is_input)
 
bool is_window_function_sum (const RexScalar *rex)
 
bool is_window_function_avg (const RexScalar *rex)
 
bool is_window_function_operator (const RexScalar *rex)
 

Function Documentation

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 
)

Definition at line 1804 of file RelAlgDagBuilder.cpp.

Referenced by anonymous_namespace{RelAlgDagBuilder.cpp}::coalesce_nodes(), and anonymous_namespace{RelAlgDagBuilder.cpp}::anonymous_namespace{RelAlgDagBuilder.cpp}::CoalesceSecondaryProjectVisitor::visitInput().

1806  {
1807  if (auto agg_node = dynamic_cast<const RelAggregate*>(parent_node)) {
1808  if (index == 0 && agg_node->getGroupByCount() > 0) {
1809  return true;
1810  } else {
1811  // Is an aggregated target, only allow the project to be elided if the aggregate
1812  // target is simply passed through (i.e. if the top level expression attached to
1813  // the project node is a RexInput expression)
1814  return first_rex_is_input;
1815  }
1816  }
1817  return first_rex_is_input;
1818 }

+ Here is the caller graph for this function:

bool anonymous_namespace{RelAlgDagBuilder.cpp}::anonymous_namespace{RelAlgDagBuilder.cpp}::is_window_function_avg ( const RexScalar rex)

Definition at line 1863 of file RelAlgDagBuilder.cpp.

References CHECK_EQ, COUNT, RexOperator::getOperand(), RexOperator::getOperator(), is_window_function_sum(), kDIVIDE, and RexOperator::size().

Referenced by is_window_function_operator().

1863  {
1864  const RexOperator* divide_operator = dynamic_cast<const RexOperator*>(rex);
1865  if (divide_operator && divide_operator->getOperator() == kDIVIDE) {
1866  CHECK_EQ(divide_operator->size(), size_t(2));
1867  const auto case_operator =
1868  dynamic_cast<const RexCase*>(divide_operator->getOperand(0));
1869  const auto second_window =
1870  dynamic_cast<const RexWindowFunctionOperator*>(divide_operator->getOperand(1));
1871  if (case_operator && second_window &&
1872  second_window->getKind() == SqlWindowFunctionKind::COUNT) {
1873  if (is_window_function_sum(case_operator)) {
1874  return true;
1875  }
1876  }
1877  }
1878  return false;
1879 }
#define CHECK_EQ(x, y)
Definition: Logger.h:231
size_t size() const
const RexScalar * getOperand(const size_t idx) const
SQLOps getOperator() const

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool anonymous_namespace{RelAlgDagBuilder.cpp}::anonymous_namespace{RelAlgDagBuilder.cpp}::is_window_function_operator ( const RexScalar rex)

Definition at line 1883 of file RelAlgDagBuilder.cpp.

References CHECK_EQ, is_window_function_avg(), is_window_function_sum(), and kCAST.

Referenced by RelProject::hasWindowFunctionExpr(), anonymous_namespace{RelAlgDagBuilder.cpp}::separate_window_function_expressions(), anonymous_namespace{RelAlgDagBuilder.cpp}::WindowFunctionCollector::visitCase(), and anonymous_namespace{RelAlgDagBuilder.cpp}::WindowFunctionCollector::visitOperator().

1883  {
1884  if (dynamic_cast<const RexWindowFunctionOperator*>(rex)) {
1885  return true;
1886  }
1887 
1888  // unwrap from casts, if they exist
1889  const auto rex_cast = dynamic_cast<const RexOperator*>(rex);
1890  if (rex_cast && rex_cast->getOperator() == kCAST) {
1891  CHECK_EQ(rex_cast->size(), size_t(1));
1892  return is_window_function_operator(rex_cast->getOperand(0));
1893  }
1894 
1896  return true;
1897  }
1898 
1899  return false;
1900 }
#define CHECK_EQ(x, y)
Definition: Logger.h:231
Definition: sqldefs.h:49

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool anonymous_namespace{RelAlgDagBuilder.cpp}::anonymous_namespace{RelAlgDagBuilder.cpp}::is_window_function_sum ( const RexScalar rex)

Definition at line 1849 of file RelAlgDagBuilder.cpp.

References SUM_INTERNAL.

Referenced by is_window_function_avg(), and is_window_function_operator().

1849  {
1850  const auto case_operator = dynamic_cast<const RexCase*>(rex);
1851  if (case_operator && case_operator->branchCount() == 1) {
1852  const auto then_window =
1853  dynamic_cast<const RexWindowFunctionOperator*>(case_operator->getThen(0));
1854  if (then_window && then_window->getKind() == SqlWindowFunctionKind::SUM_INTERNAL) {
1855  return true;
1856  }
1857  }
1858  return false;
1859 }

+ Here is the caller graph for this function:

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

Definition at line 1522 of file RelAlgDagBuilder.cpp.

References CHECK, CHECK_LT, and run_benchmark_import::result.

Referenced by anonymous_namespace{RelAlgDagBuilder.cpp}::create_compound().

1524  {
1525  std::vector<const Rex*> result;
1526  for (size_t i = 0; i < simple_project->size(); ++i) {
1527  const auto input_rex = dynamic_cast<const RexInput*>(simple_project->getProjectAt(i));
1528  CHECK(input_rex);
1529  CHECK_LT(static_cast<size_t>(input_rex->getIndex()), target_exprs.size());
1530  result.push_back(target_exprs[input_rex->getIndex()]);
1531  }
1532  return result;
1533 }
size_t size() const override
const RexScalar * getProjectAt(const size_t idx) const
#define CHECK_LT(x, y)
Definition: Logger.h:233
#define CHECK(condition)
Definition: Logger.h:223

+ Here is the caller graph for this function: