Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
englefly committed Sep 6, 2024
1 parent bd5e1b3 commit 9c1d4c1
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
// 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.

package org.apache.doris.nereids.processor.post;

import org.apache.doris.nereids.CascadesContext;
Expand All @@ -13,7 +30,7 @@
import org.apache.doris.nereids.trees.plans.physical.PhysicalProject;
import org.apache.doris.nereids.util.ExpressionUtils;

import com.clearspring.analytics.util.Lists;
import com.google.common.collect.Lists;

import java.util.ArrayList;
import java.util.HashMap;
Expand Down Expand Up @@ -79,7 +96,7 @@ public PhysicalHashAggregate<? extends Plan> visitPhysicalHashAggregate(
slotMap.put(key, cseCandidates.get(key).toSlot());
}
List<NamedExpression> aggOutputReplaced = new ArrayList<>();
for (NamedExpression expr: aggregate.getOutputExpressions()) {
for (NamedExpression expr : aggregate.getOutputExpressions()) {
aggOutputReplaced.add((NamedExpression) ExpressionUtils.replace(expr, slotMap));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import org.apache.doris.nereids.trees.expressions.WhenClause;
import org.apache.doris.nereids.trees.expressions.visitor.DefaultExpressionRewriter;
import org.apache.doris.nereids.trees.plans.Plan;
import org.apache.doris.nereids.trees.plans.physical.PhysicalHashAggregate;
import org.apache.doris.nereids.trees.plans.physical.PhysicalProject;

import com.google.common.collect.Lists;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
package org.apache.doris.nereids.rules.analysis;
// 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.

package org.apache.doris.nereids.rules.analysis;

import org.apache.doris.nereids.rules.Rule;
import org.apache.doris.nereids.rules.RuleType;
Expand All @@ -12,11 +28,9 @@
import org.apache.doris.nereids.trees.plans.Plan;
import org.apache.doris.nereids.trees.plans.logical.LogicalAggregate;
import org.apache.doris.nereids.trees.plans.logical.LogicalProject;
import org.apache.doris.nereids.trees.plans.physical.PhysicalHashAggregate;
import org.apache.doris.nereids.trees.plans.physical.PhysicalProject;
import org.apache.doris.nereids.util.ExpressionUtils;

import com.clearspring.analytics.util.Lists;
import com.google.common.collect.Lists;

import java.util.ArrayList;
import java.util.HashMap;
Expand Down Expand Up @@ -53,7 +67,7 @@ public Rule build() {
.toRule(RuleType.PROJECT_AGGREGATE_EXPRESSIONS_FOR_CSE);
}

private LogicalAggregate<? extends Plan> addProjectionIfNeed(LogicalAggregate<? extends Plan> aggregate) {
private LogicalAggregate<? extends Plan> addProjectionIfNeed(LogicalAggregate<? extends Plan> aggregate) {
// select sum(A+B), ...
// "A+B" is a cse candidate
// cseCandidates: A+B -> alias(A+B)
Expand Down Expand Up @@ -114,7 +128,7 @@ private void getCseCandidatesFromAggregateFunction(Expression expr, Map<Expressi
for (Expression child : expr.children()) {
if (!(child instanceof SlotReference) && !child.isConstant()) {
if (child instanceof Alias) {
result.put(child, (Alias)child);
result.put(child, (Alias) child);
} else {
result.put(child, new Alias(child));
}
Expand Down

0 comments on commit 9c1d4c1

Please sign in to comment.