private boolean collectJoinBatches(Query query) { if (query.isUnion()) { SelectUnion union = (SelectUnion) query; return collectJoinBatches(union.getLeft()) && collectJoinBatches(union.getRight()); } Select select = (Select) query; JoinBatch jb = select.getJoinBatch(); if (jb == null) { onlyBatchedQueries = false; } else { if (jb.getLookupBatch(0) == null) { // we are top sub-query return false; } assert !jb.batchedSubQuery; jb.batchedSubQuery = true; if (joinBatches == null) { joinBatches = New.arrayList(); filters = New.arrayList(); } filters.add(jb.filters[0]); joinBatches.add(jb); } return true; }
/** * Create index lookup batch for a view index. * * @param viewIndex view index * @return index lookup batch or {@code null} if batching is not supported * for this query */ public static IndexLookupBatch createViewIndexLookupBatch(ViewIndex viewIndex) { Query query = viewIndex.getQuery(); if (query.isUnion()) { ViewIndexLookupBatchUnion unionBatch = new ViewIndexLookupBatchUnion(viewIndex); return unionBatch.initialize() ? unionBatch : null; } JoinBatch jb = ((Select) query).getJoinBatch(); if (jb == null || jb.getLookupBatch(0) == null) { // our sub-query is not batched or is top batched sub-query return null; } assert !jb.batchedSubQuery; jb.batchedSubQuery = true; return jb.viewIndexLookupBatch(viewIndex); }
List<CollocationModel> unions, boolean validate) { if (qry.isUnion()) { if (unions == null) unions = new ArrayList<>();
/** * @param qry Query. * @param expCol Expression column. * @param validate Query validation flag. * @return {@code true} It it is an affinity column. */ private static boolean isAffinityColumn(Query qry, ExpressionColumn expCol, boolean validate) { if (qry.isUnion()) { SelectUnion union = (SelectUnion)qry; return isAffinityColumn(union.getLeft(), expCol, validate) && isAffinityColumn(union.getRight(), expCol, validate); } Expression exp = qry.getExpressions().get(expCol.getColumn().getColumnId()).getNonAliasExpression(); if (exp instanceof ExpressionColumn) { expCol = (ExpressionColumn)exp; return isAffinityColumn(expCol.getTableFilter(), expCol, validate); } return false; }
if (isUnion()) {
query.setNeverLazy(true); if (!query.isUnion()) { throw DbException.get(ErrorCode.SYNTAX_ERROR_2, "recursive queries without UNION");
private boolean collectJoinBatches(Query query) { if (query.isUnion()) { SelectUnion union = (SelectUnion) query; return collectJoinBatches(union.getLeft()) && collectJoinBatches(union.getRight()); } Select select = (Select) query; JoinBatch jb = select.getJoinBatch(); if (jb == null) { onlyBatchedQueries = false; } else { if (jb.getLookupBatch(0) == null) { // we are top sub-query return false; } assert !jb.batchedSubQuery; jb.batchedSubQuery = true; if (joinBatches == null) { joinBatches = New.arrayList(); filters = New.arrayList(); } filters.add(jb.filters[0]); joinBatches.add(jb); } return true; }
private boolean collectJoinBatches(Query query) { if (query.isUnion()) { SelectUnion union = (SelectUnion) query; return collectJoinBatches(union.getLeft()) && collectJoinBatches(union.getRight()); } Select select = (Select) query; JoinBatch jb = select.getJoinBatch(); if (jb == null) { onlyBatchedQueries = false; } else { if (jb.getLookupBatch(0) == null) { // we are top sub-query return false; } assert !jb.batchedSubQuery; jb.batchedSubQuery = true; if (joinBatches == null) { joinBatches = New.arrayList(); filters = New.arrayList(); } filters.add(jb.filters[0]); joinBatches.add(jb); } return true; }
List<GridH2CollocationModel> unions, boolean validate) { if (qry.isUnion()) { if (unions == null) unions = new ArrayList<>();
/** * Create index lookup batch for a view index. * * @param viewIndex view index * @return index lookup batch or {@code null} if batching is not supported * for this query */ public static IndexLookupBatch createViewIndexLookupBatch(ViewIndex viewIndex) { Query query = viewIndex.getQuery(); if (query.isUnion()) { ViewIndexLookupBatchUnion unionBatch = new ViewIndexLookupBatchUnion(viewIndex); return unionBatch.initialize() ? unionBatch : null; } JoinBatch jb = ((Select) query).getJoinBatch(); if (jb == null || jb.getLookupBatch(0) == null) { // our sub-query is not batched or is top batched sub-query return null; } assert !jb.batchedSubQuery; jb.batchedSubQuery = true; return jb.viewIndexLookupBatch(viewIndex); }
/** * Create index lookup batch for a view index. * * @param viewIndex view index * @return index lookup batch or {@code null} if batching is not supported * for this query */ public static IndexLookupBatch createViewIndexLookupBatch(ViewIndex viewIndex) { Query query = viewIndex.getQuery(); if (query.isUnion()) { ViewIndexLookupBatchUnion unionBatch = new ViewIndexLookupBatchUnion(viewIndex); return unionBatch.initialize() ? unionBatch : null; } JoinBatch jb = ((Select) query).getJoinBatch(); if (jb == null || jb.getLookupBatch(0) == null) { // our sub-query is not batched or is top batched sub-query return null; } assert !jb.batchedSubQuery; jb.batchedSubQuery = true; return jb.viewIndexLookupBatch(viewIndex); }
/** * @param qry Query. * @param expCol Expression column. * @param validate Query validation flag. * @return {@code true} It it is an affinity column. */ private static boolean isAffinityColumn(Query qry, ExpressionColumn expCol, boolean validate) { if (qry.isUnion()) { SelectUnion union = (SelectUnion)qry; return isAffinityColumn(union.getLeft(), expCol, validate) && isAffinityColumn(union.getRight(), expCol, validate); } Expression exp = qry.getExpressions().get(expCol.getColumn().getColumnId()).getNonAliasExpression(); if (exp instanceof ExpressionColumn) { expCol = (ExpressionColumn)exp; return isAffinityColumn(expCol.getTableFilter(), expCol, validate); } return false; }
query = (Query) parser.prepare(querySQL); if (!query.isUnion()) { throw DbException.get(ErrorCode.SYNTAX_ERROR_2, "recursive queries without UNION ALL");
query = (Query) parser.prepare(querySQL); if (!query.isUnion()) { throw DbException.get(ErrorCode.SYNTAX_ERROR_2, "recursive queries without UNION ALL");