diff --git a/sql/src/main/java/io/crate/planner/Planner.java b/sql/src/main/java/io/crate/planner/Planner.java index 7d88e78dabff..54188ecbd34b 100644 --- a/sql/src/main/java/io/crate/planner/Planner.java +++ b/sql/src/main/java/io/crate/planner/Planner.java @@ -23,10 +23,11 @@ import com.carrotsearch.hppc.procedures.ObjectProcedure; import com.google.common.base.Objects; -import com.google.common.base.*; +import com.google.common.base.Optional; +import com.google.common.base.Preconditions; +import com.google.common.base.Strings; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; -import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import io.crate.Constants; import io.crate.PartitionName; @@ -50,7 +51,6 @@ import io.crate.planner.node.dql.*; import io.crate.planner.projection.*; import io.crate.planner.symbol.*; -import io.crate.planner.symbol.Function; import io.crate.types.DataType; import io.crate.types.DataTypes; import io.crate.types.LongType; @@ -71,7 +71,6 @@ public class Planner extends AnalysisVisitor { static final PlannerAggregationSplitter splitter = new PlannerAggregationSplitter(); static final PlannerReferenceExtractor referenceExtractor = new PlannerReferenceExtractor(); - static final PlannerFunctionArgumentCopier functionArgumentCopier = new PlannerFunctionArgumentCopier(); private final ClusterService clusterService; private AggregationProjection localMergeProjection; @@ -589,6 +588,7 @@ private void queryThenFetch(SelectAnalysis analysis, Plan plan, Context context) private void globalAggregates(SelectAnalysis analysis, Plan plan, Context context) { String schema = analysis.table().ident().schema(); + if ((schema == null || schema.equalsIgnoreCase(DocSchemaInfo.NAME)) && hasOnlyGlobalCount(analysis.outputSymbols()) && !analysis.hasSysExpressions() @@ -596,10 +596,8 @@ && hasOnlyGlobalCount(analysis.outputSymbols()) plan.add(new ESCountNode(analysis.table(), analysis.whereClause())); return; } - // global aggregate: collect and partial aggregate on C and final agg on H - PlannerContextBuilder contextBuilder = new PlannerContextBuilder(2) - .output(analysis.outputSymbols()); + PlannerContextBuilder contextBuilder = new PlannerContextBuilder(2).output(analysis.outputSymbols()); // havingClause could be a Literal or Function. // if its a Literal and value is false, we'll never reach this point (no match), diff --git a/sql/src/main/java/io/crate/planner/PlannerFunctionArgumentCopier.java b/sql/src/main/java/io/crate/planner/PlannerFunctionArgumentCopier.java deleted file mode 100644 index 1405fc1518ee..000000000000 --- a/sql/src/main/java/io/crate/planner/PlannerFunctionArgumentCopier.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Licensed to CRATE Technology GmbH ("Crate") under one or more contributor - * license agreements. See the NOTICE file distributed with this work for - * additional information regarding copyright ownership. Crate 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. - * - * However, if you have executed another commercial license agreement - * with Crate these terms will supersede the license and you may use the - * software solely pursuant to the terms of the relevant commercial agreement. - */ - -package io.crate.planner; - -import com.google.common.collect.Lists; -import io.crate.planner.symbol.*; - -import java.io.IOException; -import java.util.List; - -/** - * Visitor which deepcopies functions if their arguments are references, - * used in {@linkplain io.crate.planner.Planner}. - */ -public class PlannerFunctionArgumentCopier extends SymbolVisitor { - - /** - * process given symbol and return possibly changed one - * @param symbol - * @return - */ - public Symbol process(Symbol symbol) { - return symbol.accept(this, null); - } - - /** - * process list of Symbols and change in place - */ - public void process(List symbols) { - for (int i = 0; i < symbols.size(); i++) { - symbols.set(i, process(symbols.get(i), null)); - } - } - - @Override - public Symbol visitFunction(Function symbol, Void context) { - List arguments = Lists.newArrayList(symbol.arguments()); - for (int i = 0; i < arguments.size(); i++) { - Symbol argument = arguments.get(i); - arguments.set(i, process(argument, null)); - - } - return new Function(symbol.info(), arguments); - - } - - @Override - public Symbol visitReference(Reference symbol, Void context) { - try { - return symbol.deepCopy(); - } catch (IOException e) { - throw new RuntimeException( - SymbolFormatter.format("Error copying %s", symbol)); - } - } - - @Override - protected Symbol visitSymbol(Symbol symbol, Void context) { - return symbol; - } -}