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/06 13:55:39 UTC

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

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


##########
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:
   Do we need to throw exception?



-- 
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