wuchong 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_r306794305
##########
File path:
flink-table/flink-table-planner-blink/src/main/scala/org/apache/flink/table/planner/plan/nodes/physical/stream/StreamExecSink.scala
##########
@@ -97,6 +97,22 @@ class StreamExecSink[T](
// check for append only table
val isAppendOnlyTable = UpdatingPlanChecker.isAppendOnly(this)
upsertSink.setIsAppendOnly(isAppendOnlyTable)
+
+ // extract unique key fields
+ // Now we pick shortest one to sink
+ // TODO UpsertStreamTableSink setKeyFields interface should be
Array[Array[String]]
+ val tableKeys: Option[Array[String]] =
+ UpdatingPlanChecker.getUniqueKeys(getInput,
planner).sortBy(_.length).headOption
Review comment:
There is a potential NPE at this line. Because
`UpdatingPlanChecker.getUniqueKeys` may return `null`.
What about returning `Option[Array[String]]` like flink planner? We can move
the sortBy and headOption into it.
----------------------------------------------------------------
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:
[email protected]
With regards,
Apache Git Services