You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ignite.apache.org by GitBox <gi...@apache.org> on 2022/01/26 07:10:06 UTC

[GitHub] [ignite] alex-plekhanov commented on a change in pull request #9671: IGNITE-16111 Index rebuild handling

alex-plekhanov commented on a change in pull request #9671:
URL: https://github.com/apache/ignite/pull/9671#discussion_r792358729



##########
File path: modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/exec/LogicalRelImplementor.java
##########
@@ -298,13 +301,101 @@ public LogicalRelImplementor(
         Supplier<Row> upper = upperCond == null ? null : expressionFactory.rowSource(upperCond);
         Function<Row, Row> prj = projects == null ? null : expressionFactory.project(projects, rowType);
 
+        ColocationGroup grp = ctx.group(rel.sourceId());
+
         IgniteIndex idx = tbl.getIndex(rel.indexName());
 
-        ColocationGroup group = ctx.group(rel.sourceId());
+        if (idx != null) {
+            Iterable<Row> rowsIter = idx.scan(ctx, grp, filters, lower, upper, prj, requiredColumns);
+
+            return new ScanNode<>(ctx, rowType, rowsIter);
+        }
+        else {
+            // Index was invalidated after planning, workaround through table-scan -> sort -> index spool.
+            RelCollation collation = TraitUtils.collation(rel);
+
+            boolean filterHasCorrelation = condition != null && RexUtils.hasCorrelation(condition);
+            boolean projectHasCorrelation = projects != null && RexUtils.hasCorrelation(projects);
+            boolean spoolNodeRequired = projectHasCorrelation || filterHasCorrelation;
+            boolean projNodeRequired = projects != null && spoolNodeRequired;
+            boolean hasCollation = collation != null && !collation.getFieldCollations().isEmpty();
+
+            Iterable<Row> rowsIter = tbl.scan(
+                ctx,
+                grp,
+                filterHasCorrelation ? null : filters,
+                projNodeRequired ? null : prj,
+                requiredColumns
+            );
 
-        Iterable<Row> rowsIter = idx.scan(ctx, group, filters, lower, upper, prj, requiredColumns);
+            Node<Row> node = new ScanNode<>(ctx, rowType, rowsIter);
 
-        return new ScanNode<>(ctx, rowType, rowsIter);
+            if (hasCollation || spoolNodeRequired) {

Review comment:
       Comment added




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org