quickstep-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jianqiao <...@git.apache.org>
Subject [GitHub] incubator-quickstep pull request #171: QUICKSTEP-68 Reorder intermediate rel...
Date Mon, 30 Jan 2017 20:54:55 GMT
Github user jianqiao commented on a diff in the pull request:

    https://github.com/apache/incubator-quickstep/pull/171#discussion_r98538359
  
    --- Diff: query_optimizer/rules/ReorderColumns.cpp ---
    @@ -0,0 +1,205 @@
    +/**
    + * Licensed to the Apache Software Foundation (ASF) under one
    + * or more contributor license agreements.  See the NOTICE file
    + * distributed with this work for additional information
    + * regarding copyright ownership.  The ASF licenses this file
    + * to you under the Apache License, Version 2.0 (the
    + * "License"); you may not use this file except in compliance
    + * with the License.  You may obtain a copy of the License at
    + *
    + *   http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing,
    + * software distributed under the License is distributed on an
    + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    + * KIND, either express or implied.  See the License for the
    + * specific language governing permissions and limitations
    + * under the License.
    + **/
    +
    +#include "query_optimizer/rules/ReorderColumns.hpp"
    +
    +#include <algorithm>
    +#include <cstddef>
    +#include <limits>
    +#include <unordered_map>
    +#include <vector>
    +
    +#include "query_optimizer/expressions/AttributeReference.hpp"
    +#include "query_optimizer/expressions/ExprId.hpp"
    +#include "query_optimizer/expressions/NamedExpression.hpp"
    +#include "query_optimizer/physical/HashJoin.hpp"
    +#include "query_optimizer/physical/PatternMatcher.hpp"
    +#include "query_optimizer/physical/Physical.hpp"
    +#include "query_optimizer/physical/PhysicalType.hpp"
    +#include "query_optimizer/physical/Selection.hpp"
    +#include "query_optimizer/physical/TableReference.hpp"
    +
    +#include "glog/logging.h"
    +
    +namespace quickstep {
    +namespace optimizer {
    +
    +namespace E = ::quickstep::optimizer::expressions;
    +namespace P = ::quickstep::optimizer::physical;
    +
    +P::PhysicalPtr ReorderColumns::apply(const P::PhysicalPtr &input) {
    +  DCHECK(input->getPhysicalType() == P::PhysicalType::kTopLevelPlan);
    +
    +  return applyInternal(input, true);
    +}
    +
    +P::PhysicalPtr ReorderColumns::applyInternal(const P::PhysicalPtr &input,
    +                                             bool lock_ordering) {
    +  // We have to guarantee that the top level ordering of the columns remain
    +  // unchanged so that the output columns are ordered as specified by the user.
    +  // So here we use the flag "lock_ordering" to skip the first transformable
    +  // node (i.e. the first Selection or HashJoin).
    +  const bool is_not_transformable = !IsTransformable(input);
    +  const bool skip_transform = lock_ordering || is_not_transformable;
    +  lock_ordering = lock_ordering && is_not_transformable;
    +
    +  if (skip_transform) {
    +    std::vector<P::PhysicalPtr> new_children;
    +    for (const P::PhysicalPtr &child : input->children()) {
    +      new_children.emplace_back(applyInternal(child, lock_ordering));
    --- End diff --
    
    Updated.


---
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