zstan commented on code in PR #5380:
URL: https://github.com/apache/ignite-3/pull/5380#discussion_r1990595861


##########
modules/catalog-dsl/src/integrationTest/java/org/apache/ignite/internal/catalog/ItCatalogDslTest.java:
##########
@@ -398,6 +405,48 @@ public void createAndGetDefinitionTest() {
         }
     }
 
+    @Test
+    public void tableDefinitionWithIndexes() {
+        sql("CREATE TABLE t (id int primary key, col1 varchar, col2 int)");
+        sql("CREATE INDEX t_sorted ON t USING SORTED (col2 DESC, col1)");
+        sql("CREATE INDEX t_hash ON t USING HASH (col1, col2)");
+
+        TableDefinition table = 
catalog().tableDefinition(QualifiedName.of("PUBLIC", "t"));
+
+        List<IndexDefinition> indexes = table.indexes();
+        assertNotNull(indexes);
+
+        Map<String, IndexDefinition> indexMap = indexes.stream()
+                .collect(Collectors.toMap(IndexDefinition::name, 
Function.identity()));
+
+        assertEquals(Set.of("T_SORTED", "T_HASH"), indexMap.keySet());
+
+        // primary index
+        {
+            assertEquals(IndexType.HASH, table.primaryKeyType());
+            assertEquals(List.of(ColumnSorted.column("ID")), 
table.primaryKeyColumns());
+        }
+        // sorted index
+        {
+            IndexDefinition index = indexMap.get("T_SORTED");
+            assertEquals("T_SORTED", index.name());

Review Comment:
   redundant check



##########
modules/catalog-dsl/src/test/java/org/apache/ignite/internal/catalog/sql/QueryPartTest.java:
##########
@@ -155,40 +155,34 @@ void indexColumnPart() {
         assertThat(sql(column), is("col1 desc nulls last"));
     }
 
-    @Test
-    void indexColumnParseSimple() {
-        assertThat(parseIndexColumnList("col1"), contains(column("col1")));
-        assertThat(parseIndexColumnList("col1, col2"), 
contains(column("col1"), column("col2")));
-    }
-
     @Test
     void indexColumnParseSorted() {
-        assertThat(parseIndexColumnList("col1"), contains(column("col1", 
SortOrder.DEFAULT)));
-        assertThat(parseIndexColumnList("COL2_UPPER_CASE ASC"), 
contains(column("COL2_UPPER_CASE", SortOrder.ASC)));
-        assertThat(parseIndexColumnList("col3 ASC    nUlls First  "), 
contains(column("col3", SortOrder.ASC_NULLS_FIRST)));
-        assertThat(parseIndexColumnList(" col4   asc  nulls  last "), 
contains(column("col4", SortOrder.ASC_NULLS_LAST)));
-        assertThat(parseIndexColumnList("col5 desc"), contains(column("col5", 
SortOrder.DESC)));
-        assertThat(parseIndexColumnList("col6 desc nulls first"), 
contains(column("col6", SortOrder.DESC_NULLS_FIRST)));
-        assertThat(parseIndexColumnList("col7 desc nulls last"), 
contains(column("col7", SortOrder.DESC_NULLS_LAST)));
-        assertThat(parseIndexColumnList("col8 nulls first"), 
contains(column("col8", SortOrder.NULLS_FIRST)));
-        assertThat(parseIndexColumnList("col9 nulls last"), 
contains(column("col9", SortOrder.NULLS_LAST)));
+        assertEquals(parseColumn("col1"), column("col1", SortOrder.DEFAULT));

Review Comment:
   plz change expected vs actual:
   ```suggestion
           assertEquals(column("col1", SortOrder.DEFAULT), parseColumn("col1"));
   ```



##########
modules/catalog-dsl/src/integrationTest/java/org/apache/ignite/internal/catalog/ItCatalogDslTest.java:
##########
@@ -398,6 +405,48 @@ public void createAndGetDefinitionTest() {
         }
     }
 
+    @Test
+    public void tableDefinitionWithIndexes() {
+        sql("CREATE TABLE t (id int primary key, col1 varchar, col2 int)");
+        sql("CREATE INDEX t_sorted ON t USING SORTED (col2 DESC, col1)");
+        sql("CREATE INDEX t_hash ON t USING HASH (col1, col2)");
+
+        TableDefinition table = 
catalog().tableDefinition(QualifiedName.of("PUBLIC", "t"));
+
+        List<IndexDefinition> indexes = table.indexes();
+        assertNotNull(indexes);
+
+        Map<String, IndexDefinition> indexMap = indexes.stream()
+                .collect(Collectors.toMap(IndexDefinition::name, 
Function.identity()));
+
+        assertEquals(Set.of("T_SORTED", "T_HASH"), indexMap.keySet());
+
+        // primary index
+        {
+            assertEquals(IndexType.HASH, table.primaryKeyType());
+            assertEquals(List.of(ColumnSorted.column("ID")), 
table.primaryKeyColumns());
+        }
+        // sorted index
+        {
+            IndexDefinition index = indexMap.get("T_SORTED");
+            assertEquals("T_SORTED", index.name());
+            assertEquals(IndexType.SORTED, index.type());
+            assertEquals(List.of(
+                            ColumnSorted.column("COL2", 
SortOrder.DESC_NULLS_FIRST),
+                            ColumnSorted.column("COL1", 
SortOrder.ASC_NULLS_LAST)
+                    ),
+                    index.columns()
+            );
+        }
+        // hash index
+        {
+            IndexDefinition index = indexMap.get("T_HASH");
+            assertEquals("T_HASH", index.name());

Review Comment:
   the same as above



##########
modules/catalog-dsl/src/main/java/org/apache/ignite/internal/catalog/sql/SelectFromView.java:
##########
@@ -53,16 +53,23 @@ class SelectFromView<T> extends 
AbstractCatalogQuery<List<T>> {
     public CompletableFuture<List<T>> executeAsync() {
         return sql.executeAsync(null, toString()).thenCompose(resultSet -> {

Review Comment:
   can we change it like :
   `return collectResults(sql, toString(), mapper);`



-- 
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: notifications-unsubscr...@ignite.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to