private AggregatePlan(StatementContext context, FilterableStatement statement, TableRef table, RowProjector projector, Integer limit, Integer offset, OrderBy orderBy, ParallelIteratorFactory parallelIteratorFactory, GroupBy groupBy, Expression having, Expression dynamicFilter, QueryPlan dataPlan) throws SQLException { super(context, statement, table, projector, context.getBindManager().getParameterMetaData(), limit, offset, orderBy, groupBy, parallelIteratorFactory, dynamicFilter, dataPlan); this.having = having; this.aggregators = context.getAggregationManager().getAggregators(); boolean hasSerialHint = statement.getHint().hasHint(HintNode.Hint.SERIAL); boolean canBeExecutedSerially = ScanUtil.canQueryBeExecutedSerially(table.getTable(), orderBy, context); if (hasSerialHint && !canBeExecutedSerially) { logger.warn("This query cannot be executed serially. Ignoring the hint"); } this.isSerial = hasSerialHint && canBeExecutedSerially; }
public ClientAggregatePlan(StatementContext context, FilterableStatement statement, TableRef table, RowProjector projector, Integer limit, Integer offset, Expression where, OrderBy orderBy, GroupBy groupBy, Expression having, QueryPlan delegate) { super(context, statement, table, projector, limit, offset, where, orderBy, delegate); this.groupBy = groupBy; this.having = having; this.clientAggregators = context.getAggregationManager().getAggregators(); // We must deserialize rather than clone based off of client aggregators because // upon deserialization we create the server-side aggregators instead of the client-side // aggregators. We use the Configuration directly here to avoid the expense of creating // another one. this.serverAggregators = ServerAggregators.deserialize(context.getScan() .getAttribute(BaseScannerRegionObserver.AGGREGATORS), context.getConnection().getQueryServices().getConfiguration(), null); // Extract hash aggregate hint, if any. HintNode hints = statement.getHint(); useHashAgg = hints != null && hints.hasHint(HintNode.Hint.HASH_AGGREGATE); }
@Test public void testNoAggregatorForOrderBy() throws SQLException { Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); conn.createStatement().execute("create table test (pk1 integer not null, pk2 integer not null, constraint pk primary key (pk1,pk2))"); StatementContext context = compileStatement("select count(distinct pk1) from test order by count(distinct pk2)"); assertEquals(1, context.getAggregationManager().getAggregators().getAggregatorCount()); context = compileStatement("select sum(pk1) from test order by count(distinct pk2)"); assertEquals(1, context.getAggregationManager().getAggregators().getAggregatorCount()); context = compileStatement("select min(pk1) from test order by count(distinct pk2)"); assertEquals(1, context.getAggregationManager().getAggregators().getAggregatorCount()); context = compileStatement("select max(pk1) from test order by count(distinct pk2)"); assertEquals(1, context.getAggregationManager().getAggregators().getAggregatorCount()); // here the ORDER BY is not optimized away context = compileStatement("select avg(pk1) from test order by count(distinct pk2)"); assertEquals(2, context.getAggregationManager().getAggregators().getAggregatorCount()); }
ClientAggregators aggregators = aggregationManager.getAggregators(); return aggregators;
private AggregatePlan(StatementContext context, FilterableStatement statement, TableRef table, RowProjector projector, Integer limit, Integer offset, OrderBy orderBy, ParallelIteratorFactory parallelIteratorFactory, GroupBy groupBy, Expression having, Expression dynamicFilter, QueryPlan dataPlan) throws SQLException { super(context, statement, table, projector, context.getBindManager().getParameterMetaData(), limit, offset, orderBy, groupBy, parallelIteratorFactory, dynamicFilter, dataPlan); this.having = having; this.aggregators = context.getAggregationManager().getAggregators(); boolean hasSerialHint = statement.getHint().hasHint(HintNode.Hint.SERIAL); boolean canBeExecutedSerially = ScanUtil.canQueryBeExecutedSerially(table.getTable(), orderBy, context); if (hasSerialHint && !canBeExecutedSerially) { logger.warn("This query cannot be executed serially. Ignoring the hint"); } this.isSerial = hasSerialHint && canBeExecutedSerially; }
private AggregatePlan(StatementContext context, FilterableStatement statement, TableRef table, RowProjector projector, Integer limit, Integer offset, OrderBy orderBy, ParallelIteratorFactory parallelIteratorFactory, GroupBy groupBy, Expression having, Expression dynamicFilter, QueryPlan dataPlan) throws SQLException { super(context, statement, table, projector, context.getBindManager().getParameterMetaData(), limit, offset, orderBy, groupBy, parallelIteratorFactory, dynamicFilter, dataPlan); this.having = having; this.aggregators = context.getAggregationManager().getAggregators(); boolean hasSerialHint = statement.getHint().hasHint(HintNode.Hint.SERIAL); boolean canBeExecutedSerially = ScanUtil.canQueryBeExecutedSerially(table.getTable(), orderBy, context); if (hasSerialHint && !canBeExecutedSerially) { logger.warn("This query cannot be executed serially. Ignoring the hint"); } this.isSerial = hasSerialHint && canBeExecutedSerially; }
public ClientAggregatePlan(StatementContext context, FilterableStatement statement, TableRef table, RowProjector projector, Integer limit, Integer offset, Expression where, OrderBy orderBy, GroupBy groupBy, Expression having, QueryPlan delegate) { super(context, statement, table, projector, limit, offset, where, orderBy, delegate); this.groupBy = groupBy; this.having = having; this.clientAggregators = context.getAggregationManager().getAggregators(); // We must deserialize rather than clone based off of client aggregators because // upon deserialization we create the server-side aggregators instead of the client-side // aggregators. We use the Configuration directly here to avoid the expense of creating // another one. this.serverAggregators = ServerAggregators.deserialize(context.getScan() .getAttribute(BaseScannerRegionObserver.AGGREGATORS), context.getConnection().getQueryServices().getConfiguration(), null); }
public ClientAggregatePlan(StatementContext context, FilterableStatement statement, TableRef table, RowProjector projector, Integer limit, Integer offset, Expression where, OrderBy orderBy, GroupBy groupBy, Expression having, QueryPlan delegate) { super(context, statement, table, projector, limit, offset, where, orderBy, delegate); this.groupBy = groupBy; this.having = having; this.clientAggregators = context.getAggregationManager().getAggregators(); // We must deserialize rather than clone based off of client aggregators because // upon deserialization we create the server-side aggregators instead of the client-side // aggregators. We use the Configuration directly here to avoid the expense of creating // another one. this.serverAggregators = ServerAggregators.deserialize(context.getScan() .getAttribute(BaseScannerRegionObserver.AGGREGATORS), context.getConnection().getQueryServices().getConfiguration(), null); // Extract hash aggregate hint, if any. HintNode hints = statement.getHint(); useHashAgg = hints != null && hints.hasHint(HintNode.Hint.HASH_AGGREGATE); }