valepakh commented on code in PR #7499:
URL: https://github.com/apache/ignite-3/pull/7499#discussion_r2852258734


##########
modules/cli/src/main/java/org/apache/ignite/internal/cli/commands/Options.java:
##########
@@ -360,5 +360,6 @@ public static final class Constants {
 
         /** No truncate option description. */
         public static final String NO_TRUNCATE_OPTION_DESC = "Disable column 
truncation, show full content";
+

Review Comment:
   ```suggestion
   ```



##########
modules/cli/src/main/java/org/apache/ignite/internal/cli/commands/sql/SqlExecReplCommand.java:
##########
@@ -243,17 +255,286 @@ private CallExecutionPipelineProvider 
provider(SqlManager sqlManager) {
                 plain
         );
 
-        // Use CommandLineContextProvider to get the current REPL's output 
writer,
-        // not the outer command's writer. This ensures SQL output goes through
-        // the nested REPL's output capture for proper pager support.
-        return CallExecutionPipeline.builder(new SqlQueryCall(sqlManager))
-                .inputProvider(() -> new StringCallInput(line))
-                .output(CommandLineContextProvider.getContext().out())
-                .errOutput(CommandLineContextProvider.getContext().err())
-                .decorator(new SqlQueryResultDecorator(plain, timed, 
truncationConfig))
-                .verbose(verbose)
-                .exceptionHandler(SqlExceptionHandler.INSTANCE)
-                .build();
+        int pageSize = getPageSize();
+
+        PagerSupport pagerSupport = new PagerSupport(terminal, 
configManagerProvider);
+
+        // Return a pipeline that fetches SQL results in pages and streams 
them to the terminal
+        return new PagedSqlExecutionPipeline(sqlManager, line, pageSize, 
truncationConfig, pagerSupport);
+    }
+
+    private int getPageSize() {
+        String configValue = 
configManagerProvider.get().getCurrentProperty(CliConfigKeys.SQL_DISPLAY_PAGE_SIZE.value());
+        if (configValue != null && !configValue.isEmpty()) {
+            try {
+                int pageSize = Integer.parseInt(configValue);
+                if (pageSize <= 0) {
+                    LOG.warn("SQL display page size must be positive, got: {}, 
using default: {}",
+                            pageSize, DEFAULT_SQL_DISPLAY_PAGE_SIZE);
+                    return DEFAULT_SQL_DISPLAY_PAGE_SIZE;
+                }
+                return pageSize;
+            } catch (NumberFormatException e) {
+                LOG.warn("Invalid SQL display page size in config '{}', using 
default: {}",
+                        configValue, DEFAULT_SQL_DISPLAY_PAGE_SIZE);
+            }
+        }
+        return DEFAULT_SQL_DISPLAY_PAGE_SIZE;
+    }
+
+    /**
+     * A custom pipeline for paged SQL execution that streams results 
continuously to the terminal.
+     */
+    private class PagedSqlExecutionPipeline implements 
CallExecutionPipeline<StringCallInput, Object> {

Review Comment:
   Let's extract this class



-- 
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