OmniSciDB  b24e664e58
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
anonymous_namespace{RelAlgAbstractInterpreter.cpp}::anonymous_namespace{RelAlgAbstractInterpreter.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_operator (const RexScalar *rex)
 
bool project_has_window_function_input (const RelProject *ra_project)
 

Function Documentation

bool anonymous_namespace{RelAlgAbstractInterpreter.cpp}::anonymous_namespace{RelAlgAbstractInterpreter.cpp}::input_can_be_coalesced ( const RelAlgNode parent_node,
const size_t  index,
const bool  first_rex_is_input 
)

Definition at line 1262 of file RelAlgAbstractInterpreter.cpp.

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

1264  {
1265  if (auto agg_node = dynamic_cast<const RelAggregate*>(parent_node)) {
1266  if (index == 0 && agg_node->getGroupByCount() > 0) {
1267  return true;
1268  } else {
1269  // Is an aggregated target, only allow the project to be elided if the aggregate
1270  // target is simply passed through (i.e. if the top level expression attached to
1271  // the project node is a RexInput expression)
1272  return first_rex_is_input;
1273  }
1274  }
1275  return first_rex_is_input;
1276 }

+ Here is the caller graph for this function:

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

Definition at line 1321 of file RelAlgAbstractInterpreter.cpp.

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

Referenced by project_has_window_function_input(), anonymous_namespace{RelAlgAbstractInterpreter.cpp}::separate_window_function_expressions(), anonymous_namespace{RelAlgAbstractInterpreter.cpp}::RexWindowFuncReplacementVisitor::should_replace_operand(), anonymous_namespace{RelAlgAbstractInterpreter.cpp}::WindowFunctionDetectionVisitor::visitCase(), and anonymous_namespace{RelAlgAbstractInterpreter.cpp}::WindowFunctionDetectionVisitor::visitOperator().

1321  {
1322  if (dynamic_cast<const RexWindowFunctionOperator*>(rex)) {
1323  return true;
1324  }
1325 
1326  // unwrap from casts, if they exist
1327  const auto rex_cast = dynamic_cast<const RexOperator*>(rex);
1328  if (rex_cast && rex_cast->getOperator() == kCAST) {
1329  CHECK_EQ(rex_cast->size(), size_t(1));
1330  return is_window_function_operator(rex_cast->getOperand(0));
1331  }
1332 
1333  if (is_window_function_sum(rex)) {
1334  return true;
1335  }
1336  // Check for Window Function AVG:
1337  // (CASE WHEN count > 0 THEN sum ELSE 0) / COUNT
1338  const RexOperator* divide_operator = dynamic_cast<const RexOperator*>(rex);
1339  if (divide_operator && divide_operator->getOperator() == kDIVIDE) {
1340  CHECK_EQ(divide_operator->size(), size_t(2));
1341  const auto case_operator =
1342  dynamic_cast<const RexCase*>(divide_operator->getOperand(0));
1343  const auto second_window =
1344  dynamic_cast<const RexWindowFunctionOperator*>(divide_operator->getOperand(1));
1345  if (case_operator && second_window &&
1346  second_window->getKind() == SqlWindowFunctionKind::COUNT) {
1347  if (is_window_function_sum(case_operator)) {
1348  return true;
1349  }
1350  }
1351  }
1352  return false;
1353 }
#define CHECK_EQ(x, y)
Definition: Logger.h:198
size_t size() const
const RexScalar * getOperand(const size_t idx) const
Definition: sqldefs.h:49
SQLOps getOperator() const

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Definition at line 1307 of file RelAlgAbstractInterpreter.cpp.

References SUM_INTERNAL.

Referenced by is_window_function_operator().

1307  {
1308  const auto case_operator = dynamic_cast<const RexCase*>(rex);
1309  if (case_operator && case_operator->branchCount() == 1) {
1310  const auto then_window =
1311  dynamic_cast<const RexWindowFunctionOperator*>(case_operator->getThen(0));
1312  if (then_window && then_window->getKind() == SqlWindowFunctionKind::SUM_INTERNAL) {
1313  return true;
1314  }
1315  }
1316  return false;
1317 }

+ Here is the caller graph for this function:

bool anonymous_namespace{RelAlgAbstractInterpreter.cpp}::anonymous_namespace{RelAlgAbstractInterpreter.cpp}::project_has_window_function_input ( const RelProject ra_project)
inline

Definition at line 1355 of file RelAlgAbstractInterpreter.cpp.

References RelProject::getProjectAt(), is_window_function_operator(), and RelProject::size().

Referenced by anonymous_namespace{RelAlgAbstractInterpreter.cpp}::coalesce_nodes().

1355  {
1356  for (size_t i = 0; i < ra_project->size(); i++) {
1357  if (is_window_function_operator(ra_project->getProjectAt(i))) {
1358  return true;
1359  }
1360  }
1361  return false;
1362 }
size_t size() const override
const RexScalar * getProjectAt(const size_t idx) const

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

std::vector<const Rex*> anonymous_namespace{RelAlgAbstractInterpreter.cpp}::anonymous_namespace{RelAlgAbstractInterpreter.cpp}::reproject_targets ( const RelProject simple_project,
const std::vector< const Rex * > &  target_exprs 
)
noexcept

Definition at line 1013 of file RelAlgAbstractInterpreter.cpp.

References CHECK(), CHECK_LT, and run_benchmark_import::result.

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

1015  {
1016  std::vector<const Rex*> result;
1017  for (size_t i = 0; i < simple_project->size(); ++i) {
1018  const auto input_rex = dynamic_cast<const RexInput*>(simple_project->getProjectAt(i));
1019  CHECK(input_rex);
1020  CHECK_LT(static_cast<size_t>(input_rex->getIndex()), target_exprs.size());
1021  result.push_back(target_exprs[input_rex->getIndex()]);
1022  }
1023  return result;
1024 }
size_t size() const override
CHECK(cgen_state)
const RexScalar * getProjectAt(const size_t idx) const
#define CHECK_LT(x, y)
Definition: Logger.h:200

+ Here is the call graph for this function:

+ Here is the caller graph for this function: