xtern commented on code in PR #6005: URL: https://github.com/apache/ignite-3/pull/6005#discussion_r2137961820
########## modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/exec/ExecutionServiceImpl.java: ########## @@ -522,13 +524,56 @@ private AsyncDataCursor<InternalSqlRow> executeKill( return new IteratorToDataCursorAdapter<>(ret, Runnable::run); } - @SuppressWarnings("MethodMayBeStatic") - private AsyncDataCursor<InternalSqlRow> executeExplain(ExplainPlan plan) { - String planString = plan.plan().explain(); + private AsyncDataCursor<InternalSqlRow> executeExplain( + SqlOperationContext operationContext, + ExplainPlan plan + ) { + switch (plan.mode()) { + case PLAN: { + String planString = plan.plan().explain(); + + InternalSqlRow res = new InternalSqlRowSingleString(planString); + + return new IteratorToDataCursorAdapter<>(List.of(res).iterator()); + } + case MAPPING: + if (plan.plan() instanceof MultiStepPlan) { + QueryTransactionContext txContext = operationContext.txContext(); + + assert txContext != null; + + boolean readOnly = plan.type().implicitTransactionReadOnlyMode(); + QueryTransactionWrapper txWrapper = txContext.explicitTx(); + if (txWrapper != null) { + InternalTransaction tx = txWrapper.unwrap(); + readOnly = tx.isReadOnly(); + } + + Predicate<String> nodeExclusionFilter = operationContext.nodeExclusionFilter(); - InternalSqlRow res = new InternalSqlRowSingleString(planString); + MappingParameters mappingParameters = + MappingParameters.create(operationContext.parameters(), readOnly, nodeExclusionFilter); - return new IteratorToDataCursorAdapter<>(List.of(res).iterator()); + CompletableFuture<List<MappedFragment>> mapping = mappingService.map((MultiStepPlan) plan.plan(), mappingParameters); + + CompletableFuture<InternalSqlRow> fragments = FragmentPrinter.fragmentsToString(mapping); + + CompletableFuture<Iterator<InternalSqlRow>> fragments0 = fragments.thenApply(List::of) + .thenApply(List::iterator); Review Comment: I prefer to make `String fragmentsToString()` public and remove `CompletableFuture<InternalSqlRow> fragmentsToString(CompletableFuture<List<MappedFragment>> fragments)` ```suggestion CompletableFuture<Iterator<InternalSqlRow>> fragments0 = mappingService.map((MultiStepPlan) plan.plan(), mappingParameters) .thenApply(FragmentPrinter::fragmentsToString) .thenApply(InternalSqlRowSingleString::new) .thenApply(InternalSqlRow.class::cast) .thenApply(List::of) .thenApply(List::iterator); ``` or simple ``` CompletableFuture<Iterator<InternalSqlRow>> fragments0 = mappingService.map((MultiStepPlan) plan.plan(), mappingParameters) .thenApply( fragments -> { String fragmentsString = FragmentPrinter.fragmentsToString(fragments); InternalSqlRow row = new InternalSqlRowSingleString(fragmentsString); return List.of(row).iterator(); } ); ``` -- 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-unsubscr...@ignite.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org