Kyofin commented on code in PR #8654:
URL: https://github.com/apache/inlong/pull/8654#discussion_r1303716609


##########
inlong-sort/sort-flink/sort-flink-v1.13/sort-connectors/jdbc/src/main/java/org/apache/inlong/sort/jdbc/dialect/PostgresDialect.java:
##########
@@ -38,25 +38,19 @@ public class PostgresDialect extends AbstractJdbcDialect {
 
     private static final long serialVersionUID = 1L;
 
-    private static final String QUERY_PRIMARY_KEY_SQL = "SELECT\n" +
-            "\tstring_agg (DISTINCT t3.attname, ',') AS " + PRIMARY_KEY_COLUMN 
+ ",\n" +
-            "    \tt4.tablename AS tableName\n" +
-            "FROM\n" +
-            "\tpg_constraint t1\n" +
-            "INNER JOIN pg_class t2 ON t1.conrelid = t2.oid\n" +
-            "INNER JOIN pg_attribute t3 ON t3.attrelid = t2.oid\n" +
-            "AND array_position (t1.conkey, t3.attnum) is not null\n" +
-            "INNER JOIN pg_tables t4 on t4.tablename = t2.relname\n" +
-            "INNER JOIN pg_index t5 ON t5.indrelid = t2.oid\n" +
-            "AND t3.attnum = ANY (t5.indkey)\n" +
-            "LEFT JOIN pg_description t6 on t6.objoid = t3.attrelid\n" +
-            "and t6.objsubid = t3.attnum\n" +
-            "WHERE\n" +
-            "\tt1.contype = 'p'\n" +
-            "AND length (t3.attname) > 0\n" +
-            "AND t2.oid = ?::regclass\n" +
-            "group by\n" +
-            "\tt4.tablename";
+    private static final String QUERY_PRIMARY_KEY_SQL = "SELECT\n"
+            + " string_agg(pg_attribute.attname, ',') AS pkColumn,\n"

Review Comment:
   good job !
   When only querying the primary key, this way is indeed more concise.
   <img width="878" alt="image" 
src="https://github.com/apache/inlong/assets/18548053/07ce5efd-b796-44a3-a2a0-edf091fc07a4";>
   



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