quickstep-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From zuyu <...@git.apache.org>
Subject [GitHub] incubator-quickstep pull request #229: Implement parser and resolver for UNI...
Date Fri, 07 Apr 2017 02:17:26 GMT
Github user zuyu commented on a diff in the pull request:

    https://github.com/apache/incubator-quickstep/pull/229#discussion_r110304392
  
    --- Diff: query_optimizer/resolver/Resolver.cpp ---
    @@ -1350,16 +1351,172 @@ L::LogicalPtr Resolver::resolveSelect(
       return logical_plan;
     }
     
    +L::LogicalPtr Resolver::resolveSetOperations(
    +    const ParseSetOperation &parse_set_operations,
    +    const std::string &set_operation_name,
    +    const std::vector<const Type*> *type_hints,
    +    const NameResolver *parent_resolver) {
    +  std::vector<const ParseSetOperation*> operands;
    +  CollapseSetOperation(parse_set_operations, parse_set_operations, &operands);
    +
    +  DCHECK_LT(1u, operands.size());
    +  std::vector<L::LogicalPtr> resolved_operations;
    +  std::vector<std::vector<E::AttributeReferencePtr>> attribute_matrix;
    +
    +  // Resolve the first operation, and get the output attributes.
    +  auto iter = operands.begin();
    +  const ParseSetOperation &operation = static_cast<const ParseSetOperation&>(**iter);
    +  L::LogicalPtr operation_logical =
    +      resolveSetOperationDispatcher(operation, set_operation_name, type_hints, parent_resolver);
    +  const std::vector<E::AttributeReferencePtr> operation_attributes =
    +      operation_logical->getOutputAttributes();
    +  attribute_matrix.push_back(operation_attributes);
    +  resolved_operations.push_back(operation_logical);
    +
    +  // Resolve the rest operations, and check the size of output attributes.
    +  ++iter;
    +  for (; iter != operands.end(); ++iter) {
    +    const ParseSetOperation &current_operation =
    +        static_cast<const ParseSetOperation&>(**iter);
    +    L::LogicalPtr current_logical =
    +        resolveSetOperationDispatcher(current_operation, set_operation_name, type_hints,
parent_resolver);
    +    attribute_matrix.emplace_back(current_logical->getOutputAttributes());
    +
    +    // Check output attributes size.
    +    // Detailed type check and type cast will perform later.
    +    if (attribute_matrix.back().size() != operation_attributes.size()) {
    +        THROW_SQL_ERROR_AT(&current_operation)
    +            << "Can not perform " << parse_set_operations.getName()
    +            << "opeartion between " << std::to_string(attribute_matrix.back().size())
    +            << "and " << std::to_string(operation_attributes.size())
    +            << "columns";
    +    }
    +
    +    resolved_operations.push_back(current_logical);
    +  }
    +
    +  // Get the possible output attributes that the attributes of all operands can cast
to.
    +  std::vector<E::AttributeReferencePtr> possible_attributes;
    +  for (std::size_t aid = 0; aid < operation_attributes.size(); ++aid) {
    +    E::AttributeReferencePtr possible_attribute = attribute_matrix[0][aid];
    --- End diff --
    
    Mark `const`?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message