!227 fix: Starrocks主键查询问题修复

* fix: Starrocks主键查询问题修复
This commit is contained in:
Kingkazuma
2024-12-22 14:12:53 +00:00
committed by inrgihc
parent 52a955d9c8
commit 9720448233

View File

@@ -166,8 +166,16 @@ public class StarrocksMetadataQueryProvider extends AbstractMetadataProvider {
@Override
public List<String> queryTablePrimaryKeys(Connection connection, String schemaName, String tableName) {
List<String> ret = new ArrayList<>();
try (ResultSet primaryKeys = connection.getMetaData()
.getPrimaryKeys(schemaName, null, tableName)) {
try {
Statement statement = connection.createStatement();
String sql = String.format(" SELECT * \n" +
" from information_schema.columns\n" +
" where TABLE_SCHEMA=\"%s\" and TABLE_NAME=\"%s\"\n" +
" and TABLE_CATALOG is null\n" +
" and COLUMN_KEY is not null;",
schemaName, tableName
);
ResultSet primaryKeys = statement.executeQuery(sql);
while (primaryKeys.next()) {
ret.add(primaryKeys.getString("COLUMN_NAME"));
}