QueryEngine/RelAlgDagBuilder.cpp
// The inputs used by scalar expressions are given as indices in the serialized
// representation of the query. This is hard to navigate; make the relationship
// explicit by creating RexInput expressions which hold a pointer to the source
// relational algebra node and the index relative to the output of that node.
The inputs used by scalar expressions are given as indices in the serialized
representation of the query. This is hard to navigate; make the relationship
explicit by creating RexInput expressions which hold a pointer to the source
relational algebra node and the index relative to the output of that node.
The inputs used by scalar expressions are given as indices in the serialized representation of the query . This is hard to navigate ; make the relationship explicit by creating RexInput expressions which hold a pointer to the source relational algebra node and the index relative to the output of that node .
std::unique_ptr<const RexScalar> disambiguate_rex(const RexScalar* rex_scalar,
                                                  const RANodeOutput& ra_output) {
  const auto rex_abstract_input = dynamic_cast<const RexAbstractInput*>(rex_scalar);
  if (rex_abstract_input) {
    CHECK_LT(static_cast<size_t>(rex_abstract_input->getIndex()), ra_output.size());
    return std::unique_ptr<const RexInput>(
        new RexInput(ra_output[rex_abstract_input->getIndex()]));
  }
  const auto rex_operator = dynamic_cast<const RexOperator*>(rex_scalar);
  if (rex_operator) {
    return disambiguate_operator(rex_operator, ra_output);
  }
  const auto rex_case = dynamic_cast<const RexCase*>(rex_scalar);
  if (rex_case) {
    return disambiguate_case(rex_case, ra_output);
  }
  const auto rex_literal = dynamic_cast<const RexLiteral*>(rex_scalar);
  CHECK(rex_literal);
  return std::unique_ptr<const RexLiteral>(new RexLiteral(*rex_literal));
}
std :: unique_ptr < const RexScalar > disambiguate_rex ( const RexScalar * rex_scalar , const RANodeOutput & ra_output ) { const auto rex_abstract_input = dynamic_cast < const RexAbstractInput * > ( rex_scalar ) ; if ( rex_abstract_input ) { CHECK_LT ( static_cast < size_t > ( rex_abstract_input -> getIndex ( ) ) , ra_output . size ( ) ) ; return std :: unique_ptr < const RexInput > ( new RexInput ( ra_output [ rex_abstract_input -> getIndex ( ) ] ) ) ; } const auto rex_operator = dynamic_cast < const RexOperator * > ( rex_scalar ) ; if ( rex_operator ) { return disambiguate_operator ( rex_operator , ra_output ) ; } const auto rex_case = dynamic_cast < const RexCase * > ( rex_scalar ) ; if ( rex_case ) { return disambiguate_case ( rex_case , ra_output ) ; } const auto rex_literal = dynamic_cast < const RexLiteral * > ( rex_scalar ) ; CHECK ( rex_literal ) ; return std :: unique_ptr < const RexLiteral > ( new RexLiteral ( * rex_literal ) ) ; }
The inputs used by scalar expressions are given as indices in the serialized
representation of the query.
The inputs used by scalar expressions are given as indices in the serialized representation of the query .