@Test public void testOrderByWithNoProjection() throws SQLException { Connection conn = DriverManager.getConnection(getUrl()); try { conn.createStatement().execute("create table x (id integer primary key, A.i1 integer," + " B.i2 integer)"); Scan scan = projectQuery("select A.i1 from X group by i1 order by avg(B.i2) " + "desc"); ServerAggregators aggregators = ServerAggregators.deserialize(scan.getAttribute (BaseScannerRegionObserver.AGGREGATORS), null, null); assertEquals(2,aggregators.getAggregatorCount()); } finally { conn.close(); } }
@Test public void testCountAggregatorFirst() throws Exception { String[] queries = new String[] { "SELECT sum(2.5),organization_id FROM atable GROUP BY organization_id,entity_id", "SELECT avg(a_integer) FROM atable GROUP BY organization_id,substr(entity_id,1,3),entity_id", "SELECT count(a_string) FROM atable GROUP BY substr(organization_id,1),entity_id", "SELECT min('foo') FROM atable GROUP BY entity_id,organization_id", "SELECT min('foo'),sum(a_integer),avg(2.5),4.5,max(b_string) FROM atable GROUP BY substr(organization_id,1),entity_id", "SELECT sum(2.5) FROM atable", "SELECT avg(a_integer) FROM atable", "SELECT count(a_string) FROM atable", "SELECT min('foo') FROM atable LIMIT 5", "SELECT min('foo'),sum(a_integer),avg(2.5),4.5,max(b_string) FROM atable", }; List<Object> binds = Collections.emptyList(); String query = null; try { for (int i = 0; i < queries.length; i++) { query = queries[i]; Scan scan = compileQuery(query, binds); ServerAggregators aggregators = ServerAggregators.deserialize(scan.getAttribute(BaseScannerRegionObserver.AGGREGATORS), null, null); Aggregator aggregator = aggregators.getAggregators()[0]; assertTrue(aggregator instanceof CountAggregator); } } catch (Exception e) { throw new Exception(query, e); } }
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); }
final TenantCache tenantCache = GlobalCache.getTenantCache(env, ScanUtil.getTenantId(scan)); try (MemoryChunk em = tenantCache.getMemoryManager().allocate(0)) { aggregators = ServerAggregators.deserialize( scan.getAttribute(BaseScannerRegionObserver.AGGREGATORS), conf, em); rowAggregators = aggregators.getAggregators();
try (MemoryChunk em = tenantCache.getMemoryManager().allocate(0)) { ServerAggregators aggregators = ServerAggregators.deserialize(scan .getAttribute(BaseScannerRegionObserver.AGGREGATORS), c .getEnvironment().getConfiguration(), em);
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); }
final TenantCache tenantCache = GlobalCache.getTenantCache(env, ScanUtil.getTenantId(scan)); try (MemoryChunk em = tenantCache.getMemoryManager().allocate(0)) { aggregators = ServerAggregators.deserialize( scan.getAttribute(BaseScannerRegionObserver.AGGREGATORS), conf, em); rowAggregators = aggregators.getAggregators();
final TenantCache tenantCache = GlobalCache.getTenantCache(env, ScanUtil.getTenantId(scan)); try (MemoryChunk em = tenantCache.getMemoryManager().allocate(0)) { aggregators = ServerAggregators.deserialize( scan.getAttribute(BaseScannerRegionObserver.AGGREGATORS), conf, em); rowAggregators = aggregators.getAggregators();
try (MemoryChunk em = tenantCache.getMemoryManager().allocate(0)) { ServerAggregators aggregators = ServerAggregators.deserialize(scan .getAttribute(BaseScannerRegionObserver.AGGREGATORS), c .getEnvironment().getConfiguration(), em);
try (MemoryChunk em = tenantCache.getMemoryManager().allocate(0)) { ServerAggregators aggregators = ServerAggregators.deserialize(scan .getAttribute(BaseScannerRegionObserver.AGGREGATORS), c .getEnvironment().getConfiguration(), em);