AMashenkov commented on code in PR #6593:
URL: https://github.com/apache/ignite-3/pull/6593#discussion_r2398539540


##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/prepare/PrepareServiceImpl.java:
##########
@@ -415,29 +457,72 @@ private CompletableFuture<QueryPlan> prepareExplain(
         }
 
         return result.thenApply(plan -> {
-            assert plan instanceof ExplainablePlan : plan == null ? "<null>" : 
plan.getClass().getCanonicalName();
+            QueryPlan queryPlan = plan.queryPlan;
+            assert queryPlan instanceof ExplainablePlan : queryPlan == null ? 
"<null>" : queryPlan.getClass().getCanonicalName();
 
             SqlLiteral literal = (SqlLiteral) explainMode;
 
             IgniteSqlExplainMode mode = 
literal.symbolValue(IgniteSqlExplainMode.class);
 
             assert mode != null;
 
-            return new ExplainPlan(nextPlanId(), (ExplainablePlan) plan, mode);
+            return new ExplainPlan(nextPlanId(), (ExplainablePlan) queryPlan, 
mode);
         });
     }
 
     private static boolean single(SqlNode sqlNode) {
         return !(sqlNode instanceof SqlNodeList);
     }
 
-    private CompletableFuture<QueryPlan> prepareQuery(
+    private CompletableFuture<PlanInfo> prepareQuery(
             ParsedResult parsedResult,
             PlanningContext ctx
     ) {
-        // First validate statement
+        return validateQuery(parsedResult, ctx).thenCompose(stmt -> {
+            if (!ctx.explicitTx()) {
+                // Try to produce a fast plan, if successful, then return that 
plan w/o caching it.
+                QueryPlan fastPlan = tryOptimizeFast(stmt, ctx);
+                if (fastPlan != null) {
+                    return 
CompletableFuture.completedFuture(PlanInfo.create(fastPlan));
+                }
+            }
+
+            // Use parameter metadata to compute a cache key.
+            CacheKey cacheKey = 
createCacheKeyFromParameterMetadata(stmt.parsedResult, ctx, 
stmt.parameterMetadata, ctx.defaultSchema());
+
+            return cache.get(cacheKey, k -> CompletableFuture.supplyAsync(() 
-> buildQueryPlan(stmt, ctx,
+                    () -> cache.invalidate(cacheKey)), planningPool));
+        });
+    }
+
+    private CompletableFuture<PlanInfo> rebuildQueryPlan(

Review Comment:
   Seems, you never use the result.
   Can it be `CompletableFuture<Void>`?



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to