wangzhigang1999 commented on code in PR #7400:
URL: https://github.com/apache/kyuubi/pull/7400#discussion_r3109325522


##########
externals/kyuubi-data-agent-engine/src/main/java/org/apache/kyuubi/engine/dataagent/tool/sql/SqlExecutor.java:
##########
@@ -0,0 +1,137 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.kyuubi.engine.dataagent.tool.sql;
+
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.ResultSetMetaData;
+import java.sql.Statement;
+import javax.sql.DataSource;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Shared JDBC execution + result formatting for SQL tools. Owned by {@link 
RunSelectQueryTool} and
+ * {@link RunMutationQueryTool}; not part of the public tool API.
+ */
+final class SqlExecutor {
+
+  private static final Logger LOG = LoggerFactory.getLogger(SqlExecutor.class);
+
+  private SqlExecutor() {}
+
+  /**
+   * Execute the given SQL and return a markdown-formatted result string. 
Errors are caught and
+   * returned as a one-line "Error: ..." message so the LLM can self-correct.
+   *
+   * <p><b>No client-side row cap.</b> The tool deliberately does not call 
{@link
+   * Statement#setMaxRows(int)}. Result-size discipline is delegated to the 
LLM via the system
+   * prompt, which requires every read query to include an explicit {@code 
LIMIT} (or equivalent
+   * pagination). Adding a hidden client-side cap here would silently truncate 
the LLM's view of the
+   * data and create magic numbers that are impossible to tune across 
deployments.
+   *

Review Comment:
   PR description updated. No cap here by design — a context middleware at a 
higher layer will keep tool outputs from blowing the window.   



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to