You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@seatunnel.apache.org by "Copilot (via GitHub)" <gi...@apache.org> on 2025/06/26 02:47:40 UTC

Re: [PR] [Fix][Connector-V2] Support starrocks column default value [seatunnel]

Copilot commented on code in PR #9503:
URL: https://github.com/apache/seatunnel/pull/9503#discussion_r2167990198


##########
seatunnel-connectors-v2/connector-starrocks/src/main/java/org/apache/seatunnel/connectors/seatunnel/starrocks/catalog/StarRocksCatalog.java:
##########
@@ -154,35 +153,70 @@ public CatalogTable getTable(TablePath tablePath)
             Optional<PrimaryKey> primaryKey =
                     getPrimaryKey(tablePath.getDatabaseName(), tablePath.getTableName());
 
-            PreparedStatement ps =
-                    conn.prepareStatement(
-                            String.format(
-                                    "SELECT * FROM %s WHERE 1 = 0;",
-                                    tablePath.getFullNameWithQuoted()));
-
-            ResultSetMetaData tableMetaData = ps.getMetaData();
+            final String tableSchemaQuery =
+                    "SELECT `COLUMN_NAME`, `DATA_TYPE`, `COLUMN_SIZE`,  "
+                            + "`IS_NULLABLE`, `COLUMN_COMMENT`, `COLUMN_DEFAULT`, `NUMERIC_PRECISION`, `NUMERIC_SCALE` FROM `information_schema`.`COLUMNS` "
+                            + "WHERE `TABLE_SCHEMA`=? AND `TABLE_NAME`=?;";
 
+            PreparedStatement ps = conn.prepareStatement(tableSchemaQuery);
+            ps.setObject(1, tablePath.getDatabaseName());
+            ps.setObject(2, tablePath.getTableName());
             TableSchema.Builder builder = TableSchema.builder();
+            ResultSet resultSet = ps.executeQuery();
+            Iterator<ResultSet> resultIterator =
+                    new Iterator<ResultSet>() {
+                        @Override
+                        public boolean hasNext() {
+                            try {
+                                return !resultSet.isLast();

Review Comment:
   Using resultSet.isLast() in hasNext() may cause the last row of the ResultSet to be skipped. Consider iterating using a while(resultSet.next()) loop or adjusting the iterator logic to ensure that all rows are processed.
   ```suggestion
                           private boolean hasNext = advanceCursor();
   
                           private boolean advanceCursor() {
                               try {
                                   return resultSet.next();
   ```



-- 
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: commits-unsubscribe@seatunnel.apache.org

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