You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2022/09/21 10:05:29 UTC
[GitHub] [flink] wuchong commented on a diff in pull request #20869: [FLINK-29219][table] Fix CREATE TABLE AS statement blocks SQL client's execution
wuchong commented on code in PR #20869:
URL: https://github.com/apache/flink/pull/20869#discussion_r976315122
##########
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/api/CompiledPlanITCase.java:
##########
@@ -99,6 +99,26 @@ public void testExecutePlanSql() throws Exception {
assertResult(DATA, sinkPath);
}
+ @Test
+ public void testExecuteCtasPlanSql() throws Exception {
+ createTestCsvSourceTable("src", DATA, COLUMNS_DEFINITION);
+
+ File sinkPath = TEMPORARY_FOLDER.newFolder();
+ tableEnv.compilePlanSql(
+ String.format(
+ "CREATE TABLE sink\n"
+ + "WITH (\n"
+ + " 'connector' = 'filesystem',\n"
+ + " 'format' = 'testcsv',\n"
+ + " 'path' = '%s'\n"
+ + ") AS SELECT * FROM src",
+ sinkPath.getAbsolutePath()))
Review Comment:
Check the "sink" is not created in metastore?
##########
flink-table/flink-table-api-java/src/main/java/org/apache/flink/table/api/internal/TableEnvironmentImpl.java:
##########
@@ -783,10 +783,16 @@ public CompiledPlan compilePlanSql(String stmt) {
throw new TableException(UNSUPPORTED_QUERY_IN_COMPILE_PLAN_SQL_MSG);
}
+ ModifyOperation modifyOperation = (ModifyOperation) operations.get(0);
+ // execute CREATE TABLE first for CTAS statements
+ if (modifyOperation instanceof CreateTableASOperation) {
+ CreateTableASOperation ctasOperation = (CreateTableASOperation) modifyOperation;
+ executeInternal(ctasOperation.getCreateTableOperation());
Review Comment:
Compile plan shouldn't have side effects. CREATE TABLE should be executed when `executePlan`. We can simply throw an unsupported exception for compile plan CTAS if it's not easy to support.
##########
flink-table/flink-table-api-java/src/main/java/org/apache/flink/table/api/internal/TableEnvironmentImpl.java:
##########
@@ -839,8 +845,20 @@ public CompiledPlan compilePlan(List<ModifyOperation> operations) {
@Override
public TableResultInternal executeInternal(List<ModifyOperation> operations) {
- List<Transformation<?>> transformations = translate(operations);
- List<String> sinkIdentifierNames = extractSinkIdentifierNames(operations);
+ List<ModifyOperation> mapOperations = new ArrayList<>();
Review Comment:
??
--
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-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org