JingsongLi commented on a change in pull request #9195: 
[FLINK-13289][table-planner-blink] Blink-planner should setKeyFields to upsert 
table sink
URL: https://github.com/apache/flink/pull/9195#discussion_r306741929
 
 

 ##########
 File path: 
flink-table/flink-table-planner-blink/src/main/scala/org/apache/flink/table/plan/util/UpdatingPlanChecker.scala
 ##########
 @@ -39,14 +40,21 @@ object UpdatingPlanChecker {
   }
 
   /** Extracts the unique keys of the table produced by the plan. */
-  def getUniqueKeyFields(plan: RelNode): Option[Array[String]] = {
-    getUniqueKeyGroups(plan).map(_.map(_._1).toArray)
-  }
-
-  /** Extracts the unique keys and groups of the table produced by the plan. */
-  def getUniqueKeyGroups(plan: RelNode): Option[Seq[(String, String)]] = {
-    val keyExtractor = new UniqueKeyExtractor
-    keyExtractor.visit(plan)
+  def getUniqueKeys(relNode: RelNode, planner: StreamPlanner): 
Array[Array[String]] = {
+    val rowType = relNode.getRowType
+    val fmq = 
FlinkRelMetadataQuery.reuseOrCreate(planner.getRelBuilder.getCluster.getMetadataQuery)
+    val uniqueKeys = fmq.getUniqueKeys(relNode)
+    if (uniqueKeys != null) {
+      uniqueKeys.filter(_.nonEmpty).toList.map { uniqueKey =>
+        val keys = new util.HashSet[String]()
 
 Review comment:
   I'll remove `HashSet`.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to