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 is wrong when parts of primary keys are 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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]