From 6e1d728e4e27133353b6cc21eae73e846c32c8e5 Mon Sep 17 00:00:00 2001 From: hiliuxg Date: Thu, 15 Aug 2024 15:18:47 +0800 Subject: [PATCH 1/7] 1. fix playground npe bug 2. fix render nothing where run "show tables" sql --- .../gateway/executor/FlinkSqlGatewayExecutor.java | 14 ++++++++++++-- .../web/server/context/logtool/LogReadPool.java | 4 ++-- .../views/playground/components/query/index.tsx | 14 +++++++++++++- 3 files changed, 27 insertions(+), 5 deletions(-) diff --git a/paimon-web-engine/paimon-web-engine-flink/paimon-web-engine-flink-sql-gateway/src/main/java/org/apache/paimon/web/engine/flink/sql/gateway/executor/FlinkSqlGatewayExecutor.java b/paimon-web-engine/paimon-web-engine-flink/paimon-web-engine-flink-sql-gateway/src/main/java/org/apache/paimon/web/engine/flink/sql/gateway/executor/FlinkSqlGatewayExecutor.java index ab58e471c..3de7792a7 100644 --- a/paimon-web-engine/paimon-web-engine-flink/paimon-web-engine-flink-sql-gateway/src/main/java/org/apache/paimon/web/engine/flink/sql/gateway/executor/FlinkSqlGatewayExecutor.java +++ b/paimon-web-engine/paimon-web-engine-flink/paimon-web-engine-flink-sql-gateway/src/main/java/org/apache/paimon/web/engine/flink/sql/gateway/executor/FlinkSqlGatewayExecutor.java @@ -18,11 +18,13 @@ package org.apache.paimon.web.engine.flink.sql.gateway.executor; +import org.apache.flink.api.common.JobID; import org.apache.paimon.web.engine.flink.common.executor.Executor; import org.apache.paimon.web.engine.flink.common.operation.FlinkSqlOperationType; import org.apache.paimon.web.engine.flink.common.parser.CustomSqlParser; import org.apache.paimon.web.engine.flink.common.result.ExecutionResult; import org.apache.paimon.web.engine.flink.common.result.FetchResultParams; +import org.apache.paimon.web.engine.flink.common.status.JobStatus; import org.apache.paimon.web.engine.flink.sql.gateway.client.SqlGatewayClient; import org.apache.paimon.web.engine.flink.sql.gateway.model.SessionEntity; import org.apache.paimon.web.engine.flink.sql.gateway.utils.CollectResultUtil; @@ -102,6 +104,11 @@ public ExecutionResult executeSql(String multiStatement, int maxRows) throws Exc executionResult = executeDmlStatement(combinedStatement); } + if (executionResult == null) { + executionResult = new ExecutionResult.Builder() + .shouldFetchResult(false).status(JobStatus.FINISHED.getValue()).build(); + } + return executionResult; } @@ -113,8 +120,11 @@ private ExecutionResult executeDqlStatement( ExecutionResult.Builder builder = CollectResultUtil.collectSqlGatewayResult(results.getResults()) .submitId(operationId); - if (operationType.getType().equals(FlinkSqlOperationType.SELECT.getType())) { - builder.jobId(getJobIdFromResults(results)).shouldFetchResult(true); + JobID jobId = results.getJobID(); + if (jobId != null && operationType.getType().equals(FlinkSqlOperationType.SELECT.getType())) { + builder.jobId(jobId.toString()).shouldFetchResult(true); + } else if (jobId == null && !results.getResults().getData().isEmpty()) { + builder.shouldFetchResult(false).status(JobStatus.FINISHED.getValue()); } return builder.build(); } diff --git a/paimon-web-server/src/main/java/org/apache/paimon/web/server/context/logtool/LogReadPool.java b/paimon-web-server/src/main/java/org/apache/paimon/web/server/context/logtool/LogReadPool.java index ca855d1d1..ef6261a4d 100644 --- a/paimon-web-server/src/main/java/org/apache/paimon/web/server/context/logtool/LogReadPool.java +++ b/paimon-web-server/src/main/java/org/apache/paimon/web/server/context/logtool/LogReadPool.java @@ -37,11 +37,11 @@ public LRUCache getLRUCache() { public static void write(String str, String userId) { consoleEntityCache - .computeIfAbsent(userId, k -> new StringBuilder("Console:\n")) + .computeIfAbsent(userId, k -> new StringBuilder()) .append(str); } public static void clear(String userId) { - consoleEntityCache.put(userId, new StringBuilder("Console:\n")); + consoleEntityCache.put(userId, new StringBuilder()); } } diff --git a/paimon-web-ui/src/views/playground/components/query/index.tsx b/paimon-web-ui/src/views/playground/components/query/index.tsx index 8d21ba1d1..17ed1da1f 100644 --- a/paimon-web-ui/src/views/playground/components/query/index.tsx +++ b/paimon-web-ui/src/views/playground/components/query/index.tsx @@ -107,7 +107,19 @@ export default defineComponent({ const { connect, subscribe } = useWebSocket(wsUrl, { onMessage: (message) => { const data = JSON.parse(message.body) - if (data && data.jobId && data.fileName) { + if (!data.jobId && !data.shouldFetchResult) { + const jobDetail: JobDetails = { + executionMode: data.executeMode as ExecutionMode, + job: data, + jobResultData: data.resultData.length > 0 ? data.resultData: null, + jobStatus: data.status, + executionTime: 0, + startTime: Date.now(), + displayResult: true, + loading: false, + } + jobStore.addJob(data.fileName, jobDetail) + } else if (data && data.jobId && data.fileName) { const jobDetail: JobDetails = { executionMode: data.executeMode as ExecutionMode, job: data, From 5d3b2526ed19e04d5743a776e90c74206be28e0c Mon Sep 17 00:00:00 2001 From: hiliuxg Date: Thu, 15 Aug 2024 16:10:43 +0800 Subject: [PATCH 2/7] 1. fix playground npe bug 2. fix render nothing where run "show tables" sql --- .../flink/sql/gateway/executor/FlinkSqlGatewayExecutor.java | 2 +- .../src/views/playground/components/query/index.tsx | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/paimon-web-engine/paimon-web-engine-flink/paimon-web-engine-flink-sql-gateway/src/main/java/org/apache/paimon/web/engine/flink/sql/gateway/executor/FlinkSqlGatewayExecutor.java b/paimon-web-engine/paimon-web-engine-flink/paimon-web-engine-flink-sql-gateway/src/main/java/org/apache/paimon/web/engine/flink/sql/gateway/executor/FlinkSqlGatewayExecutor.java index 3de7792a7..3f8e2fbf8 100644 --- a/paimon-web-engine/paimon-web-engine-flink/paimon-web-engine-flink-sql-gateway/src/main/java/org/apache/paimon/web/engine/flink/sql/gateway/executor/FlinkSqlGatewayExecutor.java +++ b/paimon-web-engine/paimon-web-engine-flink/paimon-web-engine-flink-sql-gateway/src/main/java/org/apache/paimon/web/engine/flink/sql/gateway/executor/FlinkSqlGatewayExecutor.java @@ -18,7 +18,6 @@ package org.apache.paimon.web.engine.flink.sql.gateway.executor; -import org.apache.flink.api.common.JobID; import org.apache.paimon.web.engine.flink.common.executor.Executor; import org.apache.paimon.web.engine.flink.common.operation.FlinkSqlOperationType; import org.apache.paimon.web.engine.flink.common.parser.CustomSqlParser; @@ -32,6 +31,7 @@ import org.apache.calcite.sql.SqlNode; import org.apache.calcite.sql.SqlNodeList; +import org.apache.flink.api.common.JobID; import org.apache.flink.table.gateway.api.results.ResultSet; import org.apache.flink.table.gateway.rest.message.statement.FetchResultsResponseBody; diff --git a/paimon-web-ui/src/views/playground/components/query/index.tsx b/paimon-web-ui/src/views/playground/components/query/index.tsx index 17ed1da1f..4e730d193 100644 --- a/paimon-web-ui/src/views/playground/components/query/index.tsx +++ b/paimon-web-ui/src/views/playground/components/query/index.tsx @@ -111,7 +111,7 @@ export default defineComponent({ const jobDetail: JobDetails = { executionMode: data.executeMode as ExecutionMode, job: data, - jobResultData: data.resultData.length > 0 ? data.resultData: null, + jobResultData: data.resultData.length > 0 ? data.resultData : null, jobStatus: data.status, executionTime: 0, startTime: Date.now(), @@ -119,7 +119,8 @@ export default defineComponent({ loading: false, } jobStore.addJob(data.fileName, jobDetail) - } else if (data && data.jobId && data.fileName) { + } + else if (data && data.jobId && data.fileName) { const jobDetail: JobDetails = { executionMode: data.executeMode as ExecutionMode, job: data, From cf057e9a877bd24a38346a39a5afb5587a47f365 Mon Sep 17 00:00:00 2001 From: hiliuxg Date: Thu, 15 Aug 2024 16:23:14 +0800 Subject: [PATCH 3/7] 1. fix playground npe bug 2. fix render nothing where run "show tables" sql --- .../sql/gateway/executor/FlinkSqlGatewayExecutor.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/paimon-web-engine/paimon-web-engine-flink/paimon-web-engine-flink-sql-gateway/src/main/java/org/apache/paimon/web/engine/flink/sql/gateway/executor/FlinkSqlGatewayExecutor.java b/paimon-web-engine/paimon-web-engine-flink/paimon-web-engine-flink-sql-gateway/src/main/java/org/apache/paimon/web/engine/flink/sql/gateway/executor/FlinkSqlGatewayExecutor.java index 3f8e2fbf8..b337cee15 100644 --- a/paimon-web-engine/paimon-web-engine-flink/paimon-web-engine-flink-sql-gateway/src/main/java/org/apache/paimon/web/engine/flink/sql/gateway/executor/FlinkSqlGatewayExecutor.java +++ b/paimon-web-engine/paimon-web-engine-flink/paimon-web-engine-flink-sql-gateway/src/main/java/org/apache/paimon/web/engine/flink/sql/gateway/executor/FlinkSqlGatewayExecutor.java @@ -105,8 +105,11 @@ public ExecutionResult executeSql(String multiStatement, int maxRows) throws Exc } if (executionResult == null) { - executionResult = new ExecutionResult.Builder() - .shouldFetchResult(false).status(JobStatus.FINISHED.getValue()).build(); + executionResult = + new ExecutionResult.Builder() + .shouldFetchResult(false) + .status(JobStatus.FINISHED.getValue()) + .build(); } return executionResult; @@ -121,7 +124,8 @@ private ExecutionResult executeDqlStatement( CollectResultUtil.collectSqlGatewayResult(results.getResults()) .submitId(operationId); JobID jobId = results.getJobID(); - if (jobId != null && operationType.getType().equals(FlinkSqlOperationType.SELECT.getType())) { + if (jobId != null + && operationType.getType().equals(FlinkSqlOperationType.SELECT.getType())) { builder.jobId(jobId.toString()).shouldFetchResult(true); } else if (jobId == null && !results.getResults().getData().isEmpty()) { builder.shouldFetchResult(false).status(JobStatus.FINISHED.getValue()); From 546e4a143c29f5e5d5fd7c208c2d48d8e67aeee6 Mon Sep 17 00:00:00 2001 From: hiliuxg Date: Thu, 15 Aug 2024 16:25:50 +0800 Subject: [PATCH 4/7] 1. fix playground npe bug 2. fix render nothing where run "show tables" sql --- .../apache/paimon/web/server/context/logtool/LogReadPool.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/paimon-web-server/src/main/java/org/apache/paimon/web/server/context/logtool/LogReadPool.java b/paimon-web-server/src/main/java/org/apache/paimon/web/server/context/logtool/LogReadPool.java index ef6261a4d..a6506e01f 100644 --- a/paimon-web-server/src/main/java/org/apache/paimon/web/server/context/logtool/LogReadPool.java +++ b/paimon-web-server/src/main/java/org/apache/paimon/web/server/context/logtool/LogReadPool.java @@ -36,9 +36,7 @@ public LRUCache getLRUCache() { } public static void write(String str, String userId) { - consoleEntityCache - .computeIfAbsent(userId, k -> new StringBuilder()) - .append(str); + consoleEntityCache.computeIfAbsent(userId, k -> new StringBuilder()).append(str); } public static void clear(String userId) { From 068cacf157e8016c9210018a6b102ea8242013ed Mon Sep 17 00:00:00 2001 From: hiliuxg Date: Fri, 16 Aug 2024 09:46:28 +0800 Subject: [PATCH 5/7] 1. fix playground npe bug 2. fix render nothing where run "show tables" sql --- .../flink/sql/gateway/executor/FlinkSqlGatewayExecutor.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/paimon-web-engine/paimon-web-engine-flink/paimon-web-engine-flink-sql-gateway/src/main/java/org/apache/paimon/web/engine/flink/sql/gateway/executor/FlinkSqlGatewayExecutor.java b/paimon-web-engine/paimon-web-engine-flink/paimon-web-engine-flink-sql-gateway/src/main/java/org/apache/paimon/web/engine/flink/sql/gateway/executor/FlinkSqlGatewayExecutor.java index b337cee15..fcffc15d0 100644 --- a/paimon-web-engine/paimon-web-engine-flink/paimon-web-engine-flink-sql-gateway/src/main/java/org/apache/paimon/web/engine/flink/sql/gateway/executor/FlinkSqlGatewayExecutor.java +++ b/paimon-web-engine/paimon-web-engine-flink/paimon-web-engine-flink-sql-gateway/src/main/java/org/apache/paimon/web/engine/flink/sql/gateway/executor/FlinkSqlGatewayExecutor.java @@ -127,7 +127,7 @@ private ExecutionResult executeDqlStatement( if (jobId != null && operationType.getType().equals(FlinkSqlOperationType.SELECT.getType())) { builder.jobId(jobId.toString()).shouldFetchResult(true); - } else if (jobId == null && !results.getResults().getData().isEmpty()) { + } else if (jobId == null) { builder.shouldFetchResult(false).status(JobStatus.FINISHED.getValue()); } return builder.build(); From 572cd4df275c73ab2312f7f7a2ba571039da186c Mon Sep 17 00:00:00 2001 From: hiliuxg Date: Fri, 16 Aug 2024 15:18:31 +0800 Subject: [PATCH 6/7] 1. fix playground npe bug 2. fix render nothing where run "show tables" sql --- .../views/playground/components/query/index.tsx | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/paimon-web-ui/src/views/playground/components/query/index.tsx b/paimon-web-ui/src/views/playground/components/query/index.tsx index 4e730d193..2c709c91d 100644 --- a/paimon-web-ui/src/views/playground/components/query/index.tsx +++ b/paimon-web-ui/src/views/playground/components/query/index.tsx @@ -107,25 +107,12 @@ export default defineComponent({ const { connect, subscribe } = useWebSocket(wsUrl, { onMessage: (message) => { const data = JSON.parse(message.body) - if (!data.jobId && !data.shouldFetchResult) { - const jobDetail: JobDetails = { - executionMode: data.executeMode as ExecutionMode, - job: data, - jobResultData: data.resultData.length > 0 ? data.resultData : null, - jobStatus: data.status, - executionTime: 0, - startTime: Date.now(), - displayResult: true, - loading: false, - } - jobStore.addJob(data.fileName, jobDetail) - } - else if (data && data.jobId && data.fileName) { + if (data && data.fileName) { const jobDetail: JobDetails = { executionMode: data.executeMode as ExecutionMode, job: data, jobResultData: null, - jobStatus: '', + jobStatus: data.status, executionTime: 0, startTime: Date.now(), displayResult: true, From 4b8335a21d09872ce7df1a4df480d19be9ce7260 Mon Sep 17 00:00:00 2001 From: hiliuxg Date: Fri, 16 Aug 2024 17:12:09 +0800 Subject: [PATCH 7/7] 1. fix playground npe bug 2. fix render nothing where run "show tables" sql --- paimon-web-ui/src/views/playground/components/query/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/paimon-web-ui/src/views/playground/components/query/index.tsx b/paimon-web-ui/src/views/playground/components/query/index.tsx index 2c709c91d..4d429df41 100644 --- a/paimon-web-ui/src/views/playground/components/query/index.tsx +++ b/paimon-web-ui/src/views/playground/components/query/index.tsx @@ -112,7 +112,7 @@ export default defineComponent({ executionMode: data.executeMode as ExecutionMode, job: data, jobResultData: null, - jobStatus: data.status, + jobStatus: data.status == null ? '' : data.status, executionTime: 0, startTime: Date.now(), displayResult: true,