xuyangzhong commented on code in PR #26632:
URL: https://github.com/apache/flink/pull/26632#discussion_r2136986005


##########
flink-table/flink-table-api-java/src/main/java/org/apache/flink/table/catalog/CatalogManager.java:
##########
@@ -1881,7 +1881,8 @@ public ResolvedCatalogView resolveCatalogView(CatalogView 
view) {
                                                                             
.get(i)))
                                     .collect(Collectors.toList()),
                             resolvedSchema.getWatermarkSpecs(),
-                            resolvedSchema.getPrimaryKey().orElse(null));
+                            resolvedSchema.getPrimaryKey().orElse(null),
+                            Collections.emptyList());

Review Comment:
   Should we use `resolvedSchema.getIndexes()`?



##########
flink-table/flink-table-common/src/main/java/org/apache/flink/table/catalog/Index.java:
##########
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.table.catalog;
+
+import org.apache.flink.annotation.PublicEvolving;
+
+import java.util.List;
+
+/**
+ * An index is a copy of selected columns of data, from a table, that is 
designed to enable very
+ * efficient search. An index normally includes a "key" or direct link to the 
original row of data
+ * from which it was copied, to allow the complete row to be retrieved 
efficiently.
+ *
+ * <p>Currently, this interface is only exposed to developers. In the future, 
when we introduce

Review Comment:
   Because you have already used `PublicEvolving` instead of `Experimental`, 
this comment can be deleted



##########
flink-table/flink-table-common/src/test/java/org/apache/flink/table/catalog/CatalogPropertiesUtilTest.java:
##########
@@ -111,7 +111,8 @@ public void testCatalogTableSerde() {
         final UniqueConstraint primaryKey =
                 UniqueConstraint.primaryKey("PK_f1", 
Collections.singletonList("f1"));
         final ResolvedSchema schema =
-                new ResolvedSchema(columns, Collections.emptyList(), 
primaryKey);
+                new ResolvedSchema(
+                        columns, Collections.emptyList(), primaryKey, 
Collections.emptyList());

Review Comment:
   Could you please add index in this test `testCatalogTableSerde`?
   
   Actually it will fail because you don't adapt this change on 
`CatalogPropertiesUtil`.



##########
flink-table/flink-table-common/src/main/java/org/apache/flink/table/utils/TableSchemaUtils.java:
##########
@@ -126,7 +127,8 @@ public static ResolvedSchema 
removeTimeAttributeFromResolvedSchema(
                         .map(col -> 
col.copy(DataTypeUtils.removeTimeAttribute(col.getDataType())))
                         .collect(Collectors.toList()),
                 resolvedSchema.getWatermarkSpecs(),
-                resolvedSchema.getPrimaryKey().orElse(null));
+                resolvedSchema.getPrimaryKey().orElse(null),
+                Collections.emptyList());

Review Comment:
   use `resolvedSchema.getIndexes()`



##########
flink-table/flink-table-common/src/test/java/org/apache/flink/table/utils/TableSchemaUtilsTest.java:
##########
@@ -101,7 +101,8 @@ void testRemoveTimeAttribute() {
                                 Column.metadata("metadata-1", DataTypes.INT(), 
"metadata", false)),
                         Collections.singletonList(
                                 WatermarkSpec.of("t", 
ResolvedExpressionMock.of(rowTimeType, "t"))),
-                        UniqueConstraint.primaryKey("test-pk", 
Collections.singletonList("id")));
+                        UniqueConstraint.primaryKey("test-pk", 
Collections.singletonList("id")),
+                        Collections.emptyList());

Review Comment:
   Add index and test it by the way.



##########
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/plan/nodes/exec/serde/ResolvedCatalogTableSerdeTest.java:
##########
@@ -93,7 +93,8 @@ class ResolvedCatalogTableSerdeTest {
                             Column.metadata("e", DataTypes.DOUBLE(), null, 
false),
                             Column.computed("f", REX_NODE_EXPRESSION)),
                     Collections.singletonList(WatermarkSpec.of("b", 
REX_NODE_EXPRESSION)),
-                    UniqueConstraint.primaryKey("myPrimaryKey", 
Arrays.asList("a", "c")));
+                    UniqueConstraint.primaryKey("myPrimaryKey", 
Arrays.asList("a", "c")),
+                    Collections.emptyList());

Review Comment:
   Add an index here to verify it by the following tests



##########
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/plan/nodes/exec/serde/ResolvedCatalogTableSerdeTest.java:
##########
@@ -93,7 +93,8 @@ class ResolvedCatalogTableSerdeTest {
                             Column.metadata("e", DataTypes.DOUBLE(), null, 
false),
                             Column.computed("f", REX_NODE_EXPRESSION)),
                     Collections.singletonList(WatermarkSpec.of("b", 
REX_NODE_EXPRESSION)),
-                    UniqueConstraint.primaryKey("myPrimaryKey", 
Arrays.asList("a", "c")));
+                    UniqueConstraint.primaryKey("myPrimaryKey", 
Arrays.asList("a", "c")),
+                    Collections.emptyList());

Review Comment:
   If we add index here, is it not necessary to add the new test 
`ResolvedSchemaJsonSerdeTest`, right?



##########
flink-table/flink-table-common/src/main/java/org/apache/flink/table/api/Schema.java:
##########
@@ -1043,4 +1126,53 @@ public int hashCode() {
             return Objects.hash(super.hashCode(), columnNames);
         }
     }
+
+    /** Declaration of an index that will be resolved to {@link Index} during 
schema resolution. */
+    @Experimental

Review Comment:
   ditto, remove the `Experimental`



-- 
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: issues-unsubscr...@flink.apache.org

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

Reply via email to