/** * The method validates the statement passed to the query plan. List of conditions are * <ol> * <li>Is a SELECT statement</li> * <li>doesn't contain ORDER BY expression</li> * <li>doesn't contain LIMIT</li> * <li>doesn't contain GROUP BY expression</li> * <li>doesn't contain DISTINCT</li> * <li>doesn't contain AGGREGATE functions</li> * </ol> * @param queryPlan * @return */ private boolean isValidStatement(final QueryPlan queryPlan) { if(queryPlan.getStatement().getOperation() != PhoenixStatement.Operation.QUERY) { throw new IllegalArgumentException("Query passed isn't a SELECT statement"); } if(!queryPlan.getOrderBy().getOrderByExpressions().isEmpty() || queryPlan.getLimit() != null || (queryPlan.getGroupBy() != null && !queryPlan.getGroupBy().isEmpty()) || queryPlan.getStatement().isDistinct() || queryPlan.getStatement().isAggregate()) { throw new IllegalArgumentException("SELECT statement shouldn't contain DISTINCT or ORDER BY or LIMIT or GROUP BY expressions"); } return true; }
if (statement.getHint().hasHint(Hint.SEEK_TO_COLUMN)) { if (statement.getHint().hasHint(Hint.NO_SEEK_TO_COLUMN)) { if (!statement.isAggregate() && filteredColumnNotInProjection) { ScanUtil.andFilterAtEnd(scan, trackedColumnsBitset != null ? new EncodedQualifiersColumnProjectionFilter(SchemaUtil.getEmptyColumnFamily(table), trackedColumnsBitset, conditionOnlyCfs, table.getEncodingScheme()) : new ColumnProjectionFilter(SchemaUtil.getEmptyColumnFamily(table),
public static Integer compile(StatementContext context, FilterableStatement statement) throws SQLException { LimitNode limitNode = statement.getLimit(); if (limitNode == null) { return null; } LimitParseNodeVisitor visitor = new LimitParseNodeVisitor(context); limitNode.getLimitParseNode().accept(visitor); return visitor.getLimit(); }
public CursorFetchPlan(QueryPlan cursorQueryPlan,String cursorName) { super(cursorQueryPlan); this.isAggregate = delegate.getStatement().isAggregate() || delegate.getStatement().isDistinct(); this.cursorName = cursorName; }
public SerialIterators(QueryPlan plan, Integer perScanLimit, Integer offset, ParallelIteratorFactory iteratorFactory, ParallelScanGrouper scanGrouper, Scan scan, Map<ImmutableBytesPtr,ServerCache> caches, QueryPlan dataPlan) throws SQLException { super(plan, perScanLimit, offset, scanGrouper, scan, caches, dataPlan); this.offset = offset; // must be a offset or a limit specified or a SERIAL hint Preconditions.checkArgument( offset != null || perScanLimit != null || plan.getStatement().getHint().hasHint(HintNode.Hint.SERIAL)); this.iteratorFactory = iteratorFactory; }
@Override public Operation getOperation() { return statement.getOperation(); }
if(this.plan.getStatement().getTableSamplingRate()!=null){ buf.append(plan.getStatement().getTableSamplingRate()/100D).append("-").append("SAMPLED ");
public static Integer compile(StatementContext context, FilterableStatement statement) throws SQLException { OffsetNode offsetNode = statement.getOffset(); if (offsetNode == null) { return null; } OffsetParseNodeVisitor visitor = new OffsetParseNodeVisitor(context); offsetNode.getOffsetParseNode().accept(visitor); return visitor.getOffset(); }
ParseNode where = statement.getWhere(); if (subqueryNodes != null) { // if the subqueryNodes passed in is null, we assume there will be no sub-queries in the WHERE clause. SubqueryParseNodeVisitor subqueryVisitor = new SubqueryParseNodeVisitor(context, subqueryNodes);
planSteps.add("CLIENT AFTER-AGGREGATION FILTER BY " + having.toString()); if (statement.isDistinct() && statement.isAggregate()) { planSteps.add("CLIENT DISTINCT ON " + projector.toString());
private static boolean isSerial(StatementContext context, FilterableStatement statement, TableRef tableRef, OrderBy orderBy, boolean isDataWithinThreshold) throws SQLException { if (isDataWithinThreshold) { PTable table = tableRef.getTable(); boolean hasSerialHint = statement.getHint().hasHint(HintNode.Hint.SERIAL); boolean canBeExecutedSerially = ScanUtil.canQueryBeExecutedSerially(table, orderBy, context); if (!canBeExecutedSerially) { if (hasSerialHint) { logger.warn("This query cannot be executed serially. Ignoring the hint"); } return false; } return true; } return false; }
@Override public Operation getOperation() { return statement.getOperation(); }
if (stream != null) Closeables.closeQuietly(stream); sampleScans(parallelScans,this.plan.getStatement().getTableSamplingRate()); return parallelScans;
public static Integer compile(StatementContext context, FilterableStatement statement) throws SQLException { OffsetNode offsetNode = statement.getOffset(); if (offsetNode == null) { return null; } OffsetParseNodeVisitor visitor = new OffsetParseNodeVisitor(context); offsetNode.getOffsetParseNode().accept(visitor); return visitor.getOffset(); }
ParseNode where = statement.getWhere(); if (subqueryNodes != null) { // if the subqueryNodes passed in is null, we assume there will be no sub-queries in the WHERE clause. SubqueryParseNodeVisitor subqueryVisitor = new SubqueryParseNodeVisitor(context, subqueryNodes);
&& ( ( statement.isDistinct() && ! statement.isAggregate() ) || ( ! statement.isDistinct() && ( context.getAggregationManager().isEmpty() || BaseScannerRegionObserver.KEY_ORDERED_GROUP_BY_EXPRESSIONS.equals(groupBy.getScanAttribName()) ) ) ) ) { if (statement.isDistinct() && statement.isAggregate()) { // Dedup on client if select distinct and aggregation aggResultIterator = new DistinctAggregatingResultIterator(aggResultIterator, getProjector());
/** * The method validates the statement passed to the query plan. List of conditions are * <ol> * <li>Is a SELECT statement</li> * <li>doesn't contain ORDER BY expression</li> * <li>doesn't contain LIMIT</li> * <li>doesn't contain GROUP BY expression</li> * <li>doesn't contain DISTINCT</li> * <li>doesn't contain AGGREGATE functions</li> * </ol> * @param queryPlan * @return */ private boolean isValidStatement(final QueryPlan queryPlan) { if(queryPlan.getStatement().getOperation() != PhoenixStatement.Operation.QUERY) { throw new IllegalArgumentException("Query passed isn't a SELECT statement"); } if(!queryPlan.getOrderBy().getOrderByExpressions().isEmpty() || queryPlan.getLimit() != null || (queryPlan.getGroupBy() != null && !queryPlan.getGroupBy().isEmpty()) || queryPlan.getStatement().isDistinct() || queryPlan.getStatement().isAggregate()) { throw new IllegalArgumentException("SELECT statement shouldn't contain DISTINCT or ORDER BY or LIMIT or GROUP BY expressions"); } return true; }
if (scanRanges == ScanRanges.NOTHING && !getStatement().isAggregate()) { return getWrappedIterator(caches, ResultIterator.EMPTY_ITERATOR); QueryServicesOptions.DEFAULT_SMALL_SCAN_THRESHOLD); if (statement.getHint().hasHint(Hint.SMALL) || (scanRanges.isPointLookup() && scanRanges.getPointLookupCount() < smallScanThreshold)) { scan.setSmall(true);
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; }
@Override public Operation getOperation() { return statement.getOperation(); }