You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2021/10/29 09:40:52 UTC

[GitHub] [flink] godfreyhe commented on a change in pull request #15744: [FLINK-22113][table-planner-blink] Implement the column uniqueness checking for TableSourceTable

godfreyhe commented on a change in pull request #15744:
URL: https://github.com/apache/flink/pull/15744#discussion_r739087566



##########
File path: flink-table/flink-table-planner-blink/src/main/scala/org/apache/flink/table/planner/plan/metadata/FlinkRelMdColumnUniqueness.scala
##########
@@ -81,9 +80,29 @@ class FlinkRelMdColumnUniqueness private extends MetadataHandler[BuiltInMetadata
       return false
     }
 
-    // TODO get uniqueKeys from TableSchema of TableSource
-
     relOptTable match {
+      case sourceTable: TableSourceTable =>
+        val catalogTable = sourceTable.catalogTable
+        catalogTable match {
+          case act: CatalogTable =>
+            val schema = act.getSchema
+            val builder = ImmutableSet.builder[ImmutableBitSet]()
+            if (schema.getPrimaryKey.isPresent) {
+              val columns = schema.getFieldNames
+              val columnIndices = schema.getPrimaryKey.get().getColumns map { c =>
+                columns.indexOf(c)
+              }

Review comment:
       The logic may be wrong if part of primary key is projected. please refer to FlinkRelMdUniqueKeys#getTableUniqueKeys(RelOptTable) to correct the logic




-- 
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-unsubscribe@flink.apache.org

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