You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flink.apache.org by yu...@apache.org on 2023/06/25 09:35:19 UTC
[flink] 01/02: [FLINK-31956][table-planner] Fix COMPILE PLAN statement fails to write to file when parent directories do not exist
This is an automated email from the ASF dual-hosted git repository.
yuxia pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/flink.git
commit c83eb5cd5a632e1e25ee5cda897b6acf68b72e53
Author: Jane Chan <qi...@gmail.com>
AuthorDate: Sat Jun 17 19:01:03 2023 +0800
[FLINK-31956][table-planner] Fix COMPILE PLAN statement fails to write to file when parent directories do not exist
---
.../flink/table/planner/plan/ExecNodeGraphInternalPlan.java | 1 +
.../java/org/apache/flink/table/api/CompiledPlanITCase.java | 11 -----------
2 files changed, 1 insertion(+), 11 deletions(-)
diff --git a/flink-table/flink-table-planner/src/main/java/org/apache/flink/table/planner/plan/ExecNodeGraphInternalPlan.java b/flink-table/flink-table-planner/src/main/java/org/apache/flink/table/planner/plan/ExecNodeGraphInternalPlan.java
index 71c9b13b04e..7f138c6517a 100644
--- a/flink-table/flink-table-planner/src/main/java/org/apache/flink/table/planner/plan/ExecNodeGraphInternalPlan.java
+++ b/flink-table/flink-table-planner/src/main/java/org/apache/flink/table/planner/plan/ExecNodeGraphInternalPlan.java
@@ -75,6 +75,7 @@ public class ExecNodeGraphInternalPlan implements InternalPlan {
}
}
try {
+ Files.createDirectories(file.toPath().getParent());
Files.write(
file.toPath(),
serializedPlan.getBytes(StandardCharsets.UTF_8),
diff --git a/flink-table/flink-table-planner/src/test/java/org/apache/flink/table/api/CompiledPlanITCase.java b/flink-table/flink-table-planner/src/test/java/org/apache/flink/table/api/CompiledPlanITCase.java
index b5485097aa6..91cd2d9fdf5 100644
--- a/flink-table/flink-table-planner/src/test/java/org/apache/flink/table/api/CompiledPlanITCase.java
+++ b/flink-table/flink-table-planner/src/test/java/org/apache/flink/table/api/CompiledPlanITCase.java
@@ -26,7 +26,6 @@ import org.apache.flink.table.planner.utils.JsonPlanTestBase;
import org.apache.flink.table.planner.utils.JsonTestUtils;
import org.apache.flink.table.planner.utils.TableTestUtil;
-import org.apache.commons.io.FileUtils;
import org.junit.Before;
import org.junit.Test;
@@ -136,7 +135,6 @@ public class CompiledPlanITCase extends JsonPlanTestBase {
@Test
public void testCompileWriteToFileAndThenExecuteSql() throws Exception {
Path planPath = Paths.get(URI.create(getTempDirPath("plan")).getPath(), "plan.json");
- FileUtils.createParentDirectories(planPath.toFile());
File sinkPath = createSourceSinkTables();
@@ -153,7 +151,6 @@ public class CompiledPlanITCase extends JsonPlanTestBase {
Path planPath =
Paths.get(URI.create(getTempDirPath("plan")).getPath(), "plan.json")
.toAbsolutePath();
- FileUtils.createParentDirectories(planPath.toFile());
File sinkPath = createSourceSinkTables();
@@ -184,7 +181,6 @@ public class CompiledPlanITCase extends JsonPlanTestBase {
Path planPath =
Paths.get(URI.create(getTempDirPath("plan")).getPath(), "plan.json")
.toAbsolutePath();
- FileUtils.createParentDirectories(planPath.toFile());
createTestCsvSourceTable("src", DATA, COLUMNS_DEFINITION);
File sinkAPath = createTestCsvSinkTable("sinkA", COLUMNS_DEFINITION);
@@ -216,7 +212,6 @@ public class CompiledPlanITCase extends JsonPlanTestBase {
Path planPath =
Paths.get(URI.create(getTempDirPath("plan")).getPath(), "plan.json")
.toAbsolutePath();
- FileUtils.createParentDirectories(planPath.toFile());
File sinkPath = createSourceSinkTables();
@@ -249,7 +244,6 @@ public class CompiledPlanITCase extends JsonPlanTestBase {
Path planPath =
Paths.get(URI.create(getTempDirPath("plan")).getPath(), "plan.json")
.toAbsolutePath();
- FileUtils.createParentDirectories(planPath.toFile());
List<String> expectedData =
Arrays.asList(
@@ -289,7 +283,6 @@ public class CompiledPlanITCase extends JsonPlanTestBase {
Path planPath =
Paths.get(URI.create(getTempDirPath("plan")).getPath(), "plan.json")
.toAbsolutePath();
- FileUtils.createParentDirectories(planPath.toFile());
File sinkPath = createSourceSinkTables();
@@ -309,7 +302,6 @@ public class CompiledPlanITCase extends JsonPlanTestBase {
Path planPath =
Paths.get(URI.create(getTempDirPath("plan")).getPath(), "plan.json")
.toAbsolutePath();
- FileUtils.createParentDirectories(planPath.toFile());
createTestCsvSourceTable("src", DATA, COLUMNS_DEFINITION);
File sinkAPath = createTestCsvSinkTable("sinkA", COLUMNS_DEFINITION);
@@ -351,9 +343,6 @@ public class CompiledPlanITCase extends JsonPlanTestBase {
@Test
public void testPersistedConfigOption() throws Exception {
- Path planPath = Paths.get(URI.create(getTempDirPath("plan")).getPath(), "plan.json");
- FileUtils.createParentDirectories(planPath.toFile());
-
List<String> data =
Stream.concat(
DATA.stream(),