shishkovilja commented on code in PR #10316:
URL: https://github.com/apache/ignite/pull/10316#discussion_r1001058690


##########
modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/jdbc/JdbcMetadataInfo.java:
##########
@@ -227,32 +232,38 @@ public SortedSet<String> getSchemasMeta(String 
schemaNamePtrn) {
 
     /**
      * See {@link DatabaseMetaData#getIndexInfo(String, String, String, 
boolean, boolean)} for details.
+     * There are some tips:
+     * <p>
+     * Extra sorting by TABLE_NAME column is performed for the cases when 
information about multiple tables is requested.
+     * Thus, sorting order is: TABLE_NAME -> NON_UNIQUE -> TYPE -> INDEX_NAME 
-> ORDINAL_POSITION.
+     * <p>
+     * Ignite has only one possible CATALOG_NAME, it is handled on the client 
(driver) side.
+     * <p>
+     * Ignite has the only unique indexes - primary key indexes.
+     * <p>
+     * Parameters {@code unique}, {@code approximate} are ignored.
      *
-     * Ignite has only one possible CATALOG_NAME, it is handled on the client 
(driver) side. Parameters {@code unique}
-     * {@code approximate} are ignored.
-     *
-     * @return Sorted by index name collection of index info, filtered 
according to specified criterias.
+     * @return Sorted index metadata collection, filtered according to 
specified criterias.
      */
     public SortedSet<JdbcIndexMeta> getIndexesMeta(String schemaNamePtrn, 
String tblNamePtrn) {
-        final Comparator<JdbcIndexMeta> byIndexName = new 
Comparator<JdbcIndexMeta>() {
-            @Override public int compare(JdbcIndexMeta o1, JdbcIndexMeta o2) {
-                return o1.indexName().compareTo(o2.indexName());
-            }
-        };
+        Comparator<JdbcIndexMeta> metaComparator = 
Comparator.comparing(JdbcIndexMeta::schemaName)
+            .thenComparing(JdbcIndexMeta::tableName)
+            .thenComparing(meta -> 
!meta.indexName().startsWith(PRIMARY_KEY_INDEX))
+            .thenComparing(JdbcIndexMeta::indexName);
 
-        TreeSet<JdbcIndexMeta> meta = new TreeSet<>(byIndexName);
+        TreeSet<JdbcIndexMeta> meta = new TreeSet<>(metaComparator);
 
-        for (String cacheName : ctx.cache().publicCacheNames()) {
-            for (GridQueryTypeDescriptor table : ctx.query().types(cacheName)) 
{
-                if (!matches(table.schemaName(), schemaNamePtrn))
-                    continue;
+        SchemaManager schemaMgr = ctx.query().schemaManager();
 
-                if (!matches(table.tableName(), tblNamePtrn))
-                    continue;
+        Collection<TableInformation> tablesInfo = 
schemaMgr.tablesInformation(schemaNamePtrn, tblNamePtrn, TYPE_TABLE);

Review Comment:
   Good point! I'll prepare a fix soon.



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