diff --git a/catalogs/catalog-jdbc-common/src/main/java/com/datastrato/gravitino/catalog/jdbc/operation/JdbcTableOperations.java b/catalogs/catalog-jdbc-common/src/main/java/com/datastrato/gravitino/catalog/jdbc/operation/JdbcTableOperations.java index 233de2a265e..7ba2288230f 100644 --- a/catalogs/catalog-jdbc-common/src/main/java/com/datastrato/gravitino/catalog/jdbc/operation/JdbcTableOperations.java +++ b/catalogs/catalog-jdbc-common/src/main/java/com/datastrato/gravitino/catalog/jdbc/operation/JdbcTableOperations.java @@ -265,6 +265,7 @@ protected List getIndexes(String databaseName, String tableName, Database ResultSet indexInfo = getIndexInfo(databaseName, tableName, metaData); while (indexInfo.next()) { String indexName = indexInfo.getString("INDEX_NAME"); + // The primary key is also the unique key, so we need to filter the primary key here. if (!indexInfo.getBoolean("NON_UNIQUE") && !primaryIndexNames.contains(indexName)) { jdbcIndexBeans.add( new JdbcIndexBean( diff --git a/integration-test/src/test/java/com/datastrato/gravitino/integration/test/catalog/jdbc/mysql/CatalogMysqlIT.java b/integration-test/src/test/java/com/datastrato/gravitino/integration/test/catalog/jdbc/mysql/CatalogMysqlIT.java index f7e97f48259..9318843c7f7 100644 --- a/integration-test/src/test/java/com/datastrato/gravitino/integration/test/catalog/jdbc/mysql/CatalogMysqlIT.java +++ b/integration-test/src/test/java/com/datastrato/gravitino/integration/test/catalog/jdbc/mysql/CatalogMysqlIT.java @@ -589,8 +589,8 @@ void testCreateTableIndex() { Indexes.unique("u2_key", new String[][] {{"col_3"}, {"col_4"}}), Indexes.unique("u3_key", new String[][] {{"col_5"}, {"col_4"}}), Indexes.unique("u4_key", new String[][] {{"col_2"}, {"col_3"}, {"col_4"}}), - Indexes.unique("u5_key", new String[][] {{"col_2"}, {"col_3"}, {"col_4"}}), - Indexes.unique("u6_key", new String[][] {{"col_1"}, {"col_2"}, {"col_3"}, {"col_4"}}), + Indexes.unique("u5_key", new String[][] {{"col_3"}, {"col_2"}, {"col_4"}}), + Indexes.unique("u6_key", new String[][] {{"col_3"}, {"col_4"}, {"col_1"}, {"col_2"}}), }; NameIdentifier tableIdentifier =