[GitHub] [flink] JackWangCS commented on a change in pull request #17245: [FLINK-23316][Table SQL/Ecosystem] Add tests for custom PartitionCommitPolicy

2021-09-24 Thread GitBox


JackWangCS commented on a change in pull request #17245:
URL: https://github.com/apache/flink/pull/17245#discussion_r715516784



##
File path: 
flink-connectors/flink-connector-hive/src/test/java/org/apache/flink/connectors/hive/HiveTableSinkITCase.java
##
@@ -441,6 +470,93 @@ private void checkSuccessFiles(String path) {
 Assert.assertTrue(new File(new File(basePath, "e=11"), 
"_MY_SUCCESS").exists());
 }
 
+private void testStreamingWriteWithCustomPartitionCommitPolicy(
+String customPartitionCommitPolicyClassName) throws Exception {
+StreamExecutionEnvironment env = 
StreamExecutionEnvironment.getExecutionEnvironment();
+env.setParallelism(1);
+env.enableCheckpointing(100);
+// avoid the job to restart infinitely
+env.setRestartStrategy(RestartStrategies.fixedDelayRestart(3, 1_000));
+
+StreamTableEnvironment tEnv = 
HiveTestUtils.createTableEnvInStreamingMode(env);
+tEnv.registerCatalog(hiveCatalog.getName(), hiveCatalog);
+tEnv.useCatalog(hiveCatalog.getName());
+tEnv.getConfig().setSqlDialect(SqlDialect.HIVE);
+
+try {
+tEnv.executeSql("create database db1");
+tEnv.useDatabase("db1");
+
+// prepare source
+List data =
+Arrays.asList(
+Row.of(1, "a", "b", "2020-05-03", "7"),
+Row.of(2, "p", "q", "2020-05-03", "8"),
+Row.of(3, "x", "y", "2020-05-03", "9"),
+Row.of(4, "x", "y", "2020-05-03", "10"),
+Row.of(5, "x", "y", "2020-05-03", "11"));
+DataStream stream =
+env.addSource(
+new FiniteTestSource<>(data),
+new RowTypeInfo(
+Types.INT,
+Types.STRING,
+Types.STRING,
+Types.STRING,
+Types.STRING));
+tEnv.createTemporaryView("my_table", stream, $("a"), $("b"), 
$("c"), $("d"), $("e"));
+
+// DDL
+tEnv.executeSql(
+"create external table sink_table (a int,b string,c string"
++ ") "
++ "partitioned by (d string,e string) "
++ " stored as textfile"
++ " TBLPROPERTIES ("
++ "'"
++ PARTITION_TIME_EXTRACTOR_TIMESTAMP_PATTERN.key()

Review comment:
   I forgot to remove this properties, I will remove 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.

To unsubscribe, e-mail: issues-unsubscr...@flink.apache.org

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




[GitHub] [flink] JackWangCS commented on a change in pull request #17245: [FLINK-23316][Table SQL/Ecosystem] Add tests for custom PartitionCommitPolicy

2021-09-21 Thread GitBox


JackWangCS commented on a change in pull request #17245:
URL: https://github.com/apache/flink/pull/17245#discussion_r713104035



##
File path: 
flink-connectors/flink-connector-hive/src/test/java/org/apache/flink/connectors/hive/CustomCommitPolicy.java
##
@@ -0,0 +1,41 @@
+/*
+ * 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.connectors.hive;
+
+import org.apache.flink.table.filesystem.PartitionCommitPolicy;
+
+import java.util.HashSet;
+import java.util.Set;
+
+/** A custom PartitionCommitPolicy for test. */
+public class CustomCommitPolicy implements PartitionCommitPolicy {
+
+private static Set committedPartitionPaths = new HashSet<>();

Review comment:
   The `TestCustomCommitPolicy` instance will created by a reflection, 
`committedPartitionPaths` needs to be static so that I can access the commited 
paths.




-- 
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: issues-unsubscr...@flink.apache.org

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