You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@seatunnel.apache.org by GitBox <gi...@apache.org> on 2023/01/09 06:22:04 UTC

[GitHub] [incubator-seatunnel] EricJoy2048 commented on a diff in pull request #3885: [Feature][API] add savemode feature API

EricJoy2048 commented on code in PR #3885:
URL: https://github.com/apache/incubator-seatunnel/pull/3885#discussion_r1064311301


##########
seatunnel-api/src/main/java/org/apache/seatunnel/api/table/factory/FactoryUtil.java:
##########
@@ -174,4 +180,34 @@ public static OptionRule sourceFullOptionRule(@NonNull Factory factory) {
         sourceOptionRule.getOptionalOptions().addAll(sourceCommonOptionRule.getOptionalOptions());
         return sourceOptionRule;
     }
+
+    /**
+     * This method is called by SeaTunnel Web to get the full option rule of a sink.
+     * @return
+     */
+    public static OptionRule sinkFullOptionRule(@NonNull TableSinkFactory factory) {
+        OptionRule sinkOptionRule = factory.optionRule();
+        if (sinkOptionRule == null) {
+            throw new FactoryException("sinkOptionRule can not be null");
+        }
+
+        try {
+            TableSink sink = factory.createSink(null);
+            if (SupportDataSaveMode.class.isAssignableFrom(sink.getClass())) {
+                SupportDataSaveMode supportDataSaveModeSink = (SupportDataSaveMode) sink;
+                Option<DataSaveMode> saveMode =
+                    Options.key(SinkCommonOptions.DATA_SAVE_MODE)
+                        .singleChoice(DataSaveMode.class, supportDataSaveModeSink.supportedDataSaveModeValues())
+                        .noDefaultValue()
+                        .withDescription("data save mode");
+                OptionRule sinkCommonOptionRule =
+                    OptionRule.builder().required(saveMode).build();
+                sinkOptionRule.getOptionalOptions().addAll(sinkCommonOptionRule.getOptionalOptions());
+            }
+        } catch (UnsupportedOperationException e) {
+            LOG.warn("Add save mode option need sink connector support create sink by TableSinkFactory");
+        }

Review Comment:
   I suggest not. Because It means all connectors need update when throw exception here. We can do it after all connector modify finished.



-- 
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: commits-unsubscribe@seatunnel.apache.org

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