Hisoka-X commented on code in PR #7832:
URL: https://github.com/apache/seatunnel/pull/7832#discussion_r1802254458


##########
seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/catalog/oceanbase/OceanBaseMySqlCatalog.java:
##########
@@ -217,4 +218,49 @@ public String getExistDataSql(TablePath tablePath) {
                 "SELECT * FROM `%s`.`%s` LIMIT 1;",
                 tablePath.getDatabaseName(), tablePath.getTableName());
     }
+
+    public CatalogTable getCatalogTable(Connection defaultConnection, String 
sqlQuery)

Review Comment:
   how about put this part into `public CatalogTable getTable(String sqlQuery) 
throws SQLException {`?



##########
seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/catalog/oceanbase/OceanBaseMySqlCatalog.java:
##########
@@ -217,4 +218,49 @@ public String getExistDataSql(TablePath tablePath) {
                 "SELECT * FROM `%s`.`%s` LIMIT 1;",
                 tablePath.getDatabaseName(), tablePath.getTableName());
     }
+
+    public CatalogTable getCatalogTable(Connection defaultConnection, String 
sqlQuery)
+            throws SQLException {
+        TableSchema.Builder schemaBuilder = TableSchema.builder();
+        String tableName = null;
+        String databaseName = null;
+        String schemaName = null;
+        String catalogName = "jdbc_catalog";
+        try {
+            Statement statement = defaultConnection.createStatement();
+            ResultSet resultSet = statement.executeQuery(sqlQuery);
+            ResultSetMetaData resultSetMetaData = resultSet.getMetaData();
+            tableName = resultSetMetaData.getTableName(1);
+            databaseName = resultSetMetaData.getCatalogName(1);
+            schemaName = resultSetMetaData.getSchemaName(1);
+            catalogName = resultSetMetaData.getCatalogName(1);
+        } catch (SQLException ignored) {
+        }
+        databaseName = StringUtils.isBlank(databaseName) ? null : databaseName;
+        schemaName = StringUtils.isBlank(schemaName) ? null : schemaName;
+        TablePath tablePath =
+                StringUtils.isBlank(tableName)
+                        ? TablePath.DEFAULT
+                        : TablePath.of(databaseName, schemaName, tableName);
+        PreparedStatement ps = 
defaultConnection.prepareStatement(getSelectColumnsSql(tablePath));
+        ResultSet resultSet = ps.executeQuery();
+        ResultSet primaryKeys =

Review Comment:
   please add try resource, we should close it after used.



##########
seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/catalog/oceanbase/OceanBaseMySqlCatalog.java:
##########
@@ -217,4 +218,49 @@ public String getExistDataSql(TablePath tablePath) {
                 "SELECT * FROM `%s`.`%s` LIMIT 1;",
                 tablePath.getDatabaseName(), tablePath.getTableName());
     }
+
+    public CatalogTable getCatalogTable(Connection defaultConnection, String 
sqlQuery)
+            throws SQLException {
+        TableSchema.Builder schemaBuilder = TableSchema.builder();
+        String tableName = null;
+        String databaseName = null;
+        String schemaName = null;
+        String catalogName = "jdbc_catalog";
+        try {
+            Statement statement = defaultConnection.createStatement();
+            ResultSet resultSet = statement.executeQuery(sqlQuery);

Review Comment:
   ditto



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