hequn8128 commented on a change in pull request #6236: [FLINK-9699] [table] Add
api to replace registered table
URL: https://github.com/apache/flink/pull/6236#discussion_r241972726
##########
File path:
flink-libraries/flink-table/src/main/scala/org/apache/flink/table/api/TableEnvironment.scala
##########
@@ -564,7 +601,70 @@ abstract class TableEnvironment(val config: TableConfig) {
name: String,
fieldNames: Array[String],
fieldTypes: Array[TypeInformation[_]],
- tableSink: TableSink[_]): Unit
+ tableSink: TableSink[_]): Unit = {
+ registerTableSinkInternal(name, fieldNames, fieldTypes, tableSink, false)
+ }
+
+ /**
+ * Registers or replace an external [[TableSink]] with given field names
and types in this
+ * [[TableEnvironment]]'s catalog.
+ * Registered sink tables can be referenced in SQL DML statements.
+ *
+ * @param name The name under which the [[TableSink]] is registered.
+ * @param fieldNames The field names to register with the [[TableSink]].
+ * @param fieldTypes The field types to register with the [[TableSink]].
+ * @param tableSink The [[TableSink]] to register.
+ */
+ def registerOrReplaceTableSink(
+ name: String,
+ fieldNames: Array[String],
+ fieldTypes: Array[TypeInformation[_]],
+ tableSink: TableSink[_]): Unit = {
+ registerTableSinkInternal(name, fieldNames, fieldTypes, tableSink, true)
+ }
+
+ /**
+ * Registers or replace an external [[TableSink]] with given field names
and types in this
+ * [[TableEnvironment]]'s catalog.
+ * Registered sink tables can be referenced in SQL DML statements.
+ *
+ * @param name The name under which the [[TableSink]] is registered.
+ * @param fieldNames The field names to register with the [[TableSink]].
+ * @param fieldTypes The field types to register with the [[TableSink]].
+ * @param tableSink The [[TableSink]] to register.
+ * @param replace Whether replace this [[TableSink]].
+ */
+ protected def registerTableSinkInternal(
+ name: String,
+ fieldNames: Array[String],
+ fieldTypes: Array[TypeInformation[_]],
+ tableSink: TableSink[_],
+ replace: Boolean): Unit
+
+ /**
+ * Registers an external [[TableSink]] with already configured field names
and field types in
+ * this [[TableEnvironment]]'s catalog.
+ * Registered sink tables can be referenced in SQL DML statements.
+ *
+ * @param name The name under which the [[TableSink]] is registered.
+ * @param configuredSink The configured [[TableSink]] to register.
+ */
+ def registerTableSink(name: String, configuredSink: TableSink[_]): Unit = {
+ registerTableSinkInternal(name, configuredSink, false)
+ }
+
+ /**
+ * Registers or replace an external [[TableSink]] with already configured
field names and
+ * field types in this [[TableEnvironment]]'s catalog.
+ * Registered sink tables can be referenced in SQL DML statements.
+ *
+ * @param name The name under which the [[TableSink]] is registered.
+ * @param configuredSink The configured [[TableSink]] to register.
+ */
+ def registerOrReplaceTableSink(name: String, configuredSink: TableSink[_]):
Unit = {
+ registerTableSinkInternal(name, configuredSink, true)
+ }
+
Review comment:
avoid two blank lines.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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