lirui-apache commented on a change in pull request #12062:
URL: https://github.com/apache/flink/pull/12062#discussion_r425783007



##########
File path: 
flink-table/flink-table-runtime-blink/src/main/java/org/apache/flink/table/filesystem/FileSystemOptions.java
##########
@@ -88,4 +88,48 @@
                                                        " If timestamp in 
partition is year, month, day, hour," +
                                                        " can configure: 
'$year-$month-$day $hour:00:00'." +
                                                        " If timestamp in 
partition is dt and hour, can configure: '$dt $hour:00:00'.");
+
+       public static final ConfigOption<String> SINK_PARTITION_COMMIT_TRIGGER =
+                       key("sink.partition-commit.trigger")
+                                       .stringType()
+                                       .defaultValue("partition-time")
+                                       .withDescription("Trigger type for 
partition commit:" +
+                                                       " 'partition-time': 
extract time from partition," +
+                                                       " if 'watermark' > 
'partition-time' + 'delay', will commit the partition." +
+                                                       " 'process-time': use 
processing time, if 'current processing time' > " +
+                                                       "'partition creation 
time' + 'delay', will commit the partition.");

Review comment:
       I think we should explain how "partition creation time" is determined.

##########
File path: 
flink-table/flink-table-runtime-blink/src/main/java/org/apache/flink/table/filesystem/FileSystemOptions.java
##########
@@ -88,4 +88,48 @@
                                                        " If timestamp in 
partition is year, month, day, hour," +
                                                        " can configure: 
'$year-$month-$day $hour:00:00'." +
                                                        " If timestamp in 
partition is dt and hour, can configure: '$dt $hour:00:00'.");
+
+       public static final ConfigOption<String> SINK_PARTITION_COMMIT_TRIGGER =
+                       key("sink.partition-commit.trigger")
+                                       .stringType()
+                                       .defaultValue("partition-time")
+                                       .withDescription("Trigger type for 
partition commit:" +
+                                                       " 'partition-time': 
extract time from partition," +
+                                                       " if 'watermark' > 
'partition-time' + 'delay', will commit the partition." +
+                                                       " 'process-time': use 
processing time, if 'current processing time' > " +
+                                                       "'partition creation 
time' + 'delay', will commit the partition.");
+
+       public static final ConfigOption<Duration> SINK_PARTITION_COMMIT_DELAY =
+                       key("sink.partition-commit.delay")
+                                       .durationType()
+                                       .defaultValue(Duration.ofMillis(0))
+                                       .withDescription("The partition will 
not commit until the delay time." +
+                                                       " if it is a day 
partition, should be '1 d'," +
+                                                       " if it is a hour 
partition, should be '1 h'");
+
+       public static final ConfigOption<String> 
SINK_PARTITION_COMMIT_POLICY_KIND =
+                       key("sink.partition-commit.policy.kind")
+                                       .stringType()
+                                       .noDefaultValue()
+                                       .withDescription("Policy to commit a 
partition is to notify the downstream" +
+                                                       " application that the 
partition has finished writing, the partition" +
+                                                       " is ready to be read." 
+
+                                                       " metastore: add 
partition to metastore." +
+                                                       " success-file: add 
'_success' file to directory." +
+                                                       " Both can be 
configured at the same time: 'metastore,success-file'." +
+                                                       " custom: use policy 
class to create a commit policy." +
+                                                       " Support to configure 
multiple policies: 'metastore,success-file'.");
+
+       public static final ConfigOption<String> 
SINK_PARTITION_COMMIT_POLICY_CLASS =
+                       key("sink.partition-commit.policy.class")
+                                       .stringType()
+                                       .noDefaultValue()
+                                       .withDescription("The partition commit 
policy class for implement PartitionCommitPolicy interface.");

Review comment:
       Does this only work custom commit policy? If so it should be mentioned 
in the description and reflected in the config name.

##########
File path: 
flink-table/flink-table-runtime-blink/src/main/java/org/apache/flink/table/filesystem/PartitionCommitPolicy.java
##########
@@ -0,0 +1,124 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.table.filesystem;
+
+import org.apache.flink.annotation.Experimental;
+import org.apache.flink.core.fs.FileSystem;
+import org.apache.flink.core.fs.Path;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.stream.Collectors;
+
+/**
+ * Policy for commit a partition.
+ *
+ * <p>The implemented commit method needs to be reentrant because the same 
partition may be

Review comment:
       ```suggestion
    * <p>The implemented commit method needs to be idempotent because the same 
partition may be
   ```

##########
File path: 
flink-table/flink-table-runtime-blink/src/main/java/org/apache/flink/table/filesystem/FileSystemOptions.java
##########
@@ -88,4 +88,48 @@
                                                        " If timestamp in 
partition is year, month, day, hour," +
                                                        " can configure: 
'$year-$month-$day $hour:00:00'." +
                                                        " If timestamp in 
partition is dt and hour, can configure: '$dt $hour:00:00'.");
+
+       public static final ConfigOption<String> SINK_PARTITION_COMMIT_TRIGGER =
+                       key("sink.partition-commit.trigger")
+                                       .stringType()
+                                       .defaultValue("partition-time")
+                                       .withDescription("Trigger type for 
partition commit:" +
+                                                       " 'partition-time': 
extract time from partition," +
+                                                       " if 'watermark' > 
'partition-time' + 'delay', will commit the partition." +
+                                                       " 'process-time': use 
processing time, if 'current processing time' > " +
+                                                       "'partition creation 
time' + 'delay', will commit the partition.");
+
+       public static final ConfigOption<Duration> SINK_PARTITION_COMMIT_DELAY =
+                       key("sink.partition-commit.delay")
+                                       .durationType()
+                                       .defaultValue(Duration.ofMillis(0))
+                                       .withDescription("The partition will 
not commit until the delay time." +
+                                                       " if it is a day 
partition, should be '1 d'," +
+                                                       " if it is a hour 
partition, should be '1 h'");
+
+       public static final ConfigOption<String> 
SINK_PARTITION_COMMIT_POLICY_KIND =
+                       key("sink.partition-commit.policy.kind")
+                                       .stringType()
+                                       .noDefaultValue()
+                                       .withDescription("Policy to commit a 
partition is to notify the downstream" +
+                                                       " application that the 
partition has finished writing, the partition" +
+                                                       " is ready to be read." 
+
+                                                       " metastore: add 
partition to metastore." +

Review comment:
       If users choose metastore policy, don't they need to specify/provide a 
`TableMetaStoreFactory` implementation?




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


Reply via email to