public static Optional<PrimaryKey> getPrimaryKey(DatabaseMetaData metaData, TablePath tablePath)
            throws SQLException {
        // According to the Javadoc of java.sql.DatabaseMetaData#getPrimaryKeys,
        // the returned primary key columns are ordered by COLUMN_NAME, not by KEY_SEQ.
        // We need to sort them based on the KEY_SEQ value.
        // seq -> column name
        List<Pair<Integer, String>> primaryKeyColumns = new ArrayList<>();
        String pkName = null;
        try (ResultSet rs =
                metaData.getPrimaryKeys(
                        tablePath.getDatabaseName(),
                        tablePath.getSchemaName(),
                        tablePath.getTableName())) {

            while (rs.next()) {
                String columnName = rs.getString("COLUMN_NAME");
                // all the PK_NAME should be the same
                pkName = cleanKeyName(rs.getString("PK_NAME"));
                int keySeq = rs.getInt("KEY_SEQ");
                // KEY_SEQ is 1-based index
                primaryKeyColumns.add(Pair.of(keySeq, columnName));
            }
        }
        // initialize size
        List<String> pkFields =
                primaryKeyColumns.stream()
                        .sorted(Comparator.comparingInt(Pair::getKey))
                        .map(Pair::getValue)
                        .distinct()
                        .collect(Collectors.toList());
        if (CollectionUtils.isEmpty(pkFields)) {
            return Optional.empty();
        }
        return Optional.of(PrimaryKey.of(pkName, pkFields));
    }
@Test
    void testPrimaryKeysNameWithOutSpecialChar() throws SQLException {
        Optional<PrimaryKey> primaryKey =
                CatalogUtils.getPrimaryKey(new TestDatabaseMetaData(), TablePath.of("test.test"));
        Assertions.assertEquals("testfdawe_", primaryKey.get().getPrimaryKey());
    }