This is an automated email from the ASF dual-hosted git repository.

nicholasjiang pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-paimon-webui.git


The following commit(s) were added to refs/heads/main by this push:
     new 50605db  [Feature] Introduce paimon-web-engine module (#142)
50605db is described below

commit 50605db795a012356c8e97d35358d7581de28c8a
Author: s7monk <[email protected]>
AuthorDate: Fri Jan 19 19:38:46 2024 +0800

    [Feature] Introduce paimon-web-engine module (#142)
---
 .../paimon-web-engine-flink-common/pom.xml         |  34 ++++++
 .../web/engine/flink/common/executor/Executor.java |  57 +++++++++
 .../common/operation/FlinkSqlOperationType.java    | 101 ++++++++++++++++
 .../engine/flink/common/operation/SqlCategory.java |  27 +++++
 .../flink/common/parser/StatementParser.java       |  45 ++++++++
 .../flink/common/result/ExecutionResult.java       | 117 +++++++++++++++++++
 .../flink/common/result/FetchResultParams.java     |  75 ++++++++++++
 .../web/engine/flink/common/status/JobStatus.java  |  47 ++++++++
 .../flink/common/parser/StatementParserTest.java   |  78 +++++++++++++
 paimon-web-engine/paimon-web-engine-flink/pom.xml  | 128 +++++++++++++++++++++
 paimon-web-engine/pom.xml                          |  39 +++++++
 pom.xml                                            |   1 +
 12 files changed, 749 insertions(+)

diff --git 
a/paimon-web-engine/paimon-web-engine-flink/paimon-web-engine-flink-common/pom.xml
 
b/paimon-web-engine/paimon-web-engine-flink/paimon-web-engine-flink-common/pom.xml
new file mode 100644
index 0000000..87fd5f8
--- /dev/null
+++ 
b/paimon-web-engine/paimon-web-engine-flink/paimon-web-engine-flink-common/pom.xml
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0";
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/xsd/maven-4.0.0.xsd";>
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.apache.paimon</groupId>
+        <artifactId>paimon-web-engine-flink</artifactId>
+        <version>0.1-SNAPSHOT</version>
+    </parent>
+
+    <artifactId>paimon-web-engine-flink-common</artifactId>
+    <name>Paimon : Web : Engine : Flink : Common</name>
+
+</project>
\ No newline at end of file
diff --git 
a/paimon-web-engine/paimon-web-engine-flink/paimon-web-engine-flink-common/src/main/java/org/apache/paimon/web/engine/flink/common/executor/Executor.java
 
b/paimon-web-engine/paimon-web-engine-flink/paimon-web-engine-flink-common/src/main/java/org/apache/paimon/web/engine/flink/common/executor/Executor.java
new file mode 100644
index 0000000..64218a1
--- /dev/null
+++ 
b/paimon-web-engine/paimon-web-engine-flink/paimon-web-engine-flink-common/src/main/java/org/apache/paimon/web/engine/flink/common/executor/Executor.java
@@ -0,0 +1,57 @@
+/*
+ * 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.paimon.web.engine.flink.common.executor;
+
+import org.apache.paimon.web.engine.flink.common.result.ExecutionResult;
+import org.apache.paimon.web.engine.flink.common.result.FetchResultParams;
+
+/**
+ * The Executor interface provides methods to submit SQL statements for 
execution, fetch results,
+ * and stop jobs.
+ */
+public interface Executor {
+
+    /**
+     * Executes an SQL statement.
+     *
+     * @param statement The SQL statement to be executed.
+     * @return SubmitResult containing information about the execution result.
+     * @throws Exception if there is an error executing the SQL statement.
+     */
+    ExecutionResult executeSql(String statement) throws Exception;
+
+    /**
+     * Fetches the results of a previously submitted SQL statement execution.
+     *
+     * @param params The parameters defining how results should be fetched.
+     * @return SubmitResult containing the execution results.
+     * @throws Exception if there is an error fetching the results.
+     */
+    ExecutionResult fetchResults(FetchResultParams params) throws Exception;
+
+    /**
+     * Attempts to stop a running job identified by its jobId.
+     *
+     * @param jobId The unique identifier of the job to stop.
+     * @param withSavepoint If true, the job will create a savepoint before 
stopping.
+     * @return true if the job was successfully stopped, false otherwise.
+     * @throws Exception if the job cannot be stopped or savepoint cannot be 
created.
+     */
+    boolean stop(String jobId, boolean withSavepoint) throws Exception;
+}
diff --git 
a/paimon-web-engine/paimon-web-engine-flink/paimon-web-engine-flink-common/src/main/java/org/apache/paimon/web/engine/flink/common/operation/FlinkSqlOperationType.java
 
b/paimon-web-engine/paimon-web-engine-flink/paimon-web-engine-flink-common/src/main/java/org/apache/paimon/web/engine/flink/common/operation/FlinkSqlOperationType.java
new file mode 100644
index 0000000..7b1324a
--- /dev/null
+++ 
b/paimon-web-engine/paimon-web-engine-flink/paimon-web-engine-flink-common/src/main/java/org/apache/paimon/web/engine/flink/common/operation/FlinkSqlOperationType.java
@@ -0,0 +1,101 @@
+/*
+ * 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.paimon.web.engine.flink.common.operation;
+
+/**
+ * This enum represents the types of operations that can be performed in Flink 
SQL. It includes
+ * operations like SELECT, CREATE, DROP, ALTER, INSERT, etc. Each operation 
type is associated with
+ * a string value, and there are methods to compare the operation type with a 
string, check if the
+ * operation type is INSERT, and get the operation type from a SQL statement.
+ *
+ * <p>Typically, you would use this enum to categorize a SQL statement and 
perform different actions
+ * based on the operation type.
+ */
+public enum FlinkSqlOperationType {
+    SELECT("SELECT"),
+    CREATE("CREATE"),
+    DROP("DROP"),
+    ALTER("ALTER"),
+    TRUNCATE("TRUNCATE"),
+    INSERT("INSERT"),
+    UPDATE("UPDATE"),
+    DELETE("DELETE"),
+    DESC("DESC"),
+    DESCRIBE("DESCRIBE"),
+    EXPLAIN("EXPLAIN"),
+    USE("USE"),
+    SHOW("SHOW"),
+    LOAD("LOAD"),
+    UNLOAD("UNLOAD"),
+    SET("SET"),
+    RESET("RESET"),
+    CALL("CALL");
+
+    private String type;
+
+    FlinkSqlOperationType(String type) {
+        this.type = type;
+    }
+
+    public void setType(String type) {
+        this.type = type;
+    }
+
+    public String getType() {
+        return type;
+    }
+
+    /**
+     * Gets the operation type from a SQL statement.
+     *
+     * @param sql the SQL statement
+     * @return the operation type
+     */
+    public static FlinkSqlOperationType getOperationType(String sql) {
+        String sqlTrim = sql.replaceAll("[\\s\\t\\n\\r]", 
"").trim().toUpperCase();
+        for (FlinkSqlOperationType sqlType : FlinkSqlOperationType.values()) {
+            if (sqlTrim.startsWith(sqlType.getType())) {
+                return sqlType;
+            }
+        }
+        return null;
+    }
+
+    public SqlCategory getCategory() {
+        switch (this) {
+            case CREATE:
+            case DROP:
+            case ALTER:
+            case TRUNCATE:
+                return SqlCategory.DDL;
+            case INSERT:
+            case UPDATE:
+            case DELETE:
+                return SqlCategory.DML;
+            case SELECT:
+            case DESC:
+            case DESCRIBE:
+            case EXPLAIN:
+            case SHOW:
+                return SqlCategory.DQL;
+            default:
+                return SqlCategory.OTHER;
+        }
+    }
+}
diff --git 
a/paimon-web-engine/paimon-web-engine-flink/paimon-web-engine-flink-common/src/main/java/org/apache/paimon/web/engine/flink/common/operation/SqlCategory.java
 
b/paimon-web-engine/paimon-web-engine-flink/paimon-web-engine-flink-common/src/main/java/org/apache/paimon/web/engine/flink/common/operation/SqlCategory.java
new file mode 100644
index 0000000..9a2da53
--- /dev/null
+++ 
b/paimon-web-engine/paimon-web-engine-flink/paimon-web-engine-flink-common/src/main/java/org/apache/paimon/web/engine/flink/common/operation/SqlCategory.java
@@ -0,0 +1,27 @@
+/*
+ * 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.paimon.web.engine.flink.common.operation;
+
+/** Enum representing the category of SQL statements. */
+public enum SqlCategory {
+    DDL,
+    DML,
+    DQL,
+    OTHER
+}
diff --git 
a/paimon-web-engine/paimon-web-engine-flink/paimon-web-engine-flink-common/src/main/java/org/apache/paimon/web/engine/flink/common/parser/StatementParser.java
 
b/paimon-web-engine/paimon-web-engine-flink/paimon-web-engine-flink-common/src/main/java/org/apache/paimon/web/engine/flink/common/parser/StatementParser.java
new file mode 100644
index 0000000..a5d6fac
--- /dev/null
+++ 
b/paimon-web-engine/paimon-web-engine-flink/paimon-web-engine-flink-common/src/main/java/org/apache/paimon/web/engine/flink/common/parser/StatementParser.java
@@ -0,0 +1,45 @@
+/*
+ * 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.paimon.web.engine.flink.common.parser;
+
+import java.util.Arrays;
+
+/** The parser of the SQL statement. */
+public class StatementParser {
+
+    private static final String STATEMENT_SPLIT = ";\n";
+
+    public static String[] parse(String statement) {
+        if (statement == null || statement.trim().isEmpty()) {
+            return new String[0];
+        }
+
+        String[] splits = statement.replace(";\r\n", 
";\n").split(STATEMENT_SPLIT);
+        String lastStmt = splits[splits.length - 1].trim();
+        if (lastStmt.endsWith(";")) {
+            splits[splits.length - 1] = lastStmt.substring(0, 
lastStmt.length() - 1).trim();
+        }
+
+        for (int i = 0; i < splits.length; i++) {
+            splits[i] = splits[i].replaceAll("(?m)^[ \t]*--.*$(\r\n|\n)?", 
"").trim();
+        }
+
+        return Arrays.stream(splits).filter(s -> 
!s.isEmpty()).toArray(String[]::new);
+    }
+}
diff --git 
a/paimon-web-engine/paimon-web-engine-flink/paimon-web-engine-flink-common/src/main/java/org/apache/paimon/web/engine/flink/common/result/ExecutionResult.java
 
b/paimon-web-engine/paimon-web-engine-flink/paimon-web-engine-flink-common/src/main/java/org/apache/paimon/web/engine/flink/common/result/ExecutionResult.java
new file mode 100644
index 0000000..ead0d57
--- /dev/null
+++ 
b/paimon-web-engine/paimon-web-engine-flink/paimon-web-engine-flink-common/src/main/java/org/apache/paimon/web/engine/flink/common/result/ExecutionResult.java
@@ -0,0 +1,117 @@
+/*
+ * 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.paimon.web.engine.flink.common.result;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+/** Represents the outcome of a job execution process. */
+public class ExecutionResult implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    private final String submitId;
+    private final String jobId;
+    private final String status;
+    private final List<Map<String, Object>> data;
+    private final boolean shouldFetchResult;
+
+    private ExecutionResult(
+            String submitId,
+            String jobId,
+            String status,
+            List<Map<String, Object>> data,
+            boolean shouldFetchResult) {
+        this.submitId = submitId;
+        this.jobId = jobId;
+        this.status = status;
+        this.data = data;
+        this.shouldFetchResult = shouldFetchResult;
+    }
+
+    public String getSubmitId() {
+        return submitId;
+    }
+
+    public String getJobId() {
+        return jobId;
+    }
+
+    public String getStatus() {
+        return status;
+    }
+
+    public List<Map<String, Object>> getData() {
+        return data;
+    }
+
+    public boolean shouldFetchResult() {
+        return shouldFetchResult;
+    }
+
+    public static Builder builder() {
+        return new Builder();
+    }
+
+    /** The builder for SubmitResult. */
+    public static class Builder {
+
+        private String submitId;
+        private String jobId;
+        private String status;
+        private List<Map<String, Object>> data = new ArrayList<>();
+        private boolean shouldFetchResult;
+
+        public Builder submitId(String submitId) {
+            this.submitId = submitId;
+            return this;
+        }
+
+        public Builder jobId(String jobId) {
+            this.jobId = jobId;
+            return this;
+        }
+
+        public Builder status(String status) {
+            this.status = status;
+            return this;
+        }
+
+        public Builder data(List<Map<String, Object>> data) {
+            this.data = data;
+            return this;
+        }
+
+        public Builder addData(Map<String, Object> dataItem) {
+            this.data.add(dataItem);
+            return this;
+        }
+
+        public Builder shouldFetchResult(boolean shouldFetchResult) {
+            this.shouldFetchResult = shouldFetchResult;
+            return this;
+        }
+
+        public ExecutionResult build() {
+            return new ExecutionResult(submitId, jobId, status, data, 
shouldFetchResult);
+        }
+    }
+}
diff --git 
a/paimon-web-engine/paimon-web-engine-flink/paimon-web-engine-flink-common/src/main/java/org/apache/paimon/web/engine/flink/common/result/FetchResultParams.java
 
b/paimon-web-engine/paimon-web-engine-flink/paimon-web-engine-flink-common/src/main/java/org/apache/paimon/web/engine/flink/common/result/FetchResultParams.java
new file mode 100644
index 0000000..3c5bc80
--- /dev/null
+++ 
b/paimon-web-engine/paimon-web-engine-flink/paimon-web-engine-flink-common/src/main/java/org/apache/paimon/web/engine/flink/common/result/FetchResultParams.java
@@ -0,0 +1,75 @@
+/*
+ * 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.paimon.web.engine.flink.common.result;
+
+/** Represents the parameters required to fetch the results of a certain 
operation. */
+public class FetchResultParams {
+
+    private final String sessionId;
+    private final String submitId;
+    private final Long token;
+
+    private FetchResultParams(String sessionId, String submitId, Long token) {
+        this.sessionId = sessionId;
+        this.submitId = submitId;
+        this.token = token;
+    }
+
+    public String getSessionId() {
+        return sessionId;
+    }
+
+    public String getSubmitId() {
+        return submitId;
+    }
+
+    public Long getToken() {
+        return token;
+    }
+
+    public static Builder builder() {
+        return new Builder();
+    }
+
+    /** The builder for FetchResultParams. */
+    public static class Builder {
+        private String sessionId;
+        private String submitId;
+        private Long token;
+
+        public Builder sessionId(String sessionId) {
+            this.sessionId = sessionId;
+            return this;
+        }
+
+        public Builder submitId(String submitId) {
+            this.submitId = submitId;
+            return this;
+        }
+
+        public Builder token(Long token) {
+            this.token = token;
+            return this;
+        }
+
+        public FetchResultParams build() {
+            return new FetchResultParams(sessionId, submitId, token);
+        }
+    }
+}
diff --git 
a/paimon-web-engine/paimon-web-engine-flink/paimon-web-engine-flink-common/src/main/java/org/apache/paimon/web/engine/flink/common/status/JobStatus.java
 
b/paimon-web-engine/paimon-web-engine-flink/paimon-web-engine-flink-common/src/main/java/org/apache/paimon/web/engine/flink/common/status/JobStatus.java
new file mode 100644
index 0000000..aabaab1
--- /dev/null
+++ 
b/paimon-web-engine/paimon-web-engine-flink/paimon-web-engine-flink-common/src/main/java/org/apache/paimon/web/engine/flink/common/status/JobStatus.java
@@ -0,0 +1,47 @@
+/*
+ * 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.paimon.web.engine.flink.common.status;
+
+/** Represents the various states that a job. */
+public enum JobStatus {
+    CREATED("CREATED"),
+    RUNNING("RUNNING"),
+    FINISHED("FINISHED"),
+    FAILED("FAILED"),
+    CANCELED("CANCELED");
+
+    private final String value;
+
+    public static JobStatus fromValue(String value) {
+        for (JobStatus type : values()) {
+            if (type.getValue().equals(value)) {
+                return type;
+            }
+        }
+        throw new IllegalArgumentException("Unknown job status: " + value);
+    }
+
+    JobStatus(String value) {
+        this.value = value;
+    }
+
+    public String getValue() {
+        return this.value;
+    }
+}
diff --git 
a/paimon-web-engine/paimon-web-engine-flink/paimon-web-engine-flink-common/src/test/java/org/apache/paimon/web/engine/flink/common/parser/StatementParserTest.java
 
b/paimon-web-engine/paimon-web-engine-flink/paimon-web-engine-flink-common/src/test/java/org/apache/paimon/web/engine/flink/common/parser/StatementParserTest.java
new file mode 100644
index 0000000..10b8e06
--- /dev/null
+++ 
b/paimon-web-engine/paimon-web-engine-flink/paimon-web-engine-flink-common/src/test/java/org/apache/paimon/web/engine/flink/common/parser/StatementParserTest.java
@@ -0,0 +1,78 @@
+/*
+ * 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.paimon.web.engine.flink.common.parser;
+
+import org.junit.jupiter.api.Test;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+/** Tests of {@link StatementParser}. */
+public class StatementParserTest {
+
+    private String statement =
+            "DROP TABLE IF EXISTS t_order;\n"
+                    + "CREATE TABLE IF NOT EXISTS t_order(\n"
+                    + "    --order id\n"
+                    + "    `order_id` BIGINT,\n"
+                    + "    --product\n"
+                    + "    `product` BIGINT,\n"
+                    + "    --amount\n"
+                    + "    `amount` BIGINT,\n"
+                    + "    --payment time\n"
+                    + "    `order_time` as CAST(CURRENT_TIMESTAMP AS 
TIMESTAMP(3)),\n"
+                    + "    --WATERMARK\n"
+                    + "    WATERMARK FOR order_time AS order_time-INTERVAL '2' 
SECOND\n"
+                    + ") WITH(\n"
+                    + "    'connector' = 'datagen',\n"
+                    + "    'rows-per-second' = '1',\n"
+                    + "    'fields.order_id.min' = '1',\n"
+                    + "    'fields.order_id.max' = '2',\n"
+                    + "    'fields.amount.min' = '1',\n"
+                    + "    'fields.amount.max' = '10',\n"
+                    + "    'fields.product.min' = '1',\n"
+                    + "    'fields.product.max' = '2'\n"
+                    + ");\n"
+                    + "-- SELECT * FROM t_order LIMIT 10;\n"
+                    + "DROP TABLE IF EXISTS sink_table;\n"
+                    + "CREATE TABLE IF NOT EXISTS sink_table(\n"
+                    + "    --product\n"
+                    + "    `product` BIGINT,\n"
+                    + "    --amount\n"
+                    + "    `amount` BIGINT,\n"
+                    + "    --payment time\n"
+                    + "    `order_time` TIMESTAMP(3),\n"
+                    + "    `one_minute_sum` BIGINT\n"
+                    + ") WITH('connector' = 'print');\n"
+                    + "\n"
+                    + "INSERT INTO\n"
+                    + "    sink_table\n"
+                    + "SELECT\n"
+                    + "    product,\n"
+                    + "    amount,\n"
+                    + "    order_time,\n"
+                    + "    0 as one_minute_sum\n"
+                    + "FROM\n"
+                    + "    t_order;";
+
+    @Test
+    public void testParse() {
+        String[] statements = StatementParser.parse(statement);
+        assertThat(statements.length).isEqualTo(5);
+    }
+}
diff --git a/paimon-web-engine/paimon-web-engine-flink/pom.xml 
b/paimon-web-engine/paimon-web-engine-flink/pom.xml
new file mode 100644
index 0000000..fa44e1c
--- /dev/null
+++ b/paimon-web-engine/paimon-web-engine-flink/pom.xml
@@ -0,0 +1,128 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0";
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/xsd/maven-4.0.0.xsd";>
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.apache.paimon</groupId>
+        <artifactId>paimon-web-engine</artifactId>
+        <version>0.1-SNAPSHOT</version>
+    </parent>
+
+    <artifactId>paimon-web-engine-flink</artifactId>
+    <name>Paimon : Web : Engine : Flink</name>
+
+    <packaging>pom</packaging>
+
+    <modules>
+        <module>paimon-web-engine-flink-common</module>
+    </modules>
+
+    <properties>
+        <flink.version>1.18.0</flink.version>
+        <scala.version>2.12</scala.version>
+    </properties>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.flink</groupId>
+            <artifactId>flink-annotations</artifactId>
+            <version>${flink.version}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.flink</groupId>
+            <artifactId>flink-java</artifactId>
+            <version>${flink.version}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.flink</groupId>
+            <artifactId>flink-streaming-java</artifactId>
+            <version>${flink.version}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.flink</groupId>
+            <artifactId>flink-clients</artifactId>
+            <version>${flink.version}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.flink</groupId>
+            <artifactId>flink-yarn</artifactId>
+            <version>${flink.version}</version>
+            <exclusions>
+                <exclusion>
+                    <groupId>javax.servlet</groupId>
+                    <artifactId>servlet-api</artifactId>
+                </exclusion>
+            </exclusions>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.flink</groupId>
+            <artifactId>flink-table-planner_${scala.version}</artifactId>
+            <version>${flink.version}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.flink</groupId>
+            <artifactId>flink-table-api-java-bridge</artifactId>
+            <version>${flink.version}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.flink</groupId>
+            <artifactId>flink-sql-gateway-api</artifactId>
+            <version>${flink.version}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.flink</groupId>
+            <artifactId>flink-sql-gateway</artifactId>
+            <version>${flink.version}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.flink</groupId>
+            <artifactId>flink-test-utils</artifactId>
+            <version>${flink.version}</version>
+            <scope>test</scope>
+            <exclusions>
+                <exclusion>
+                    <artifactId>log4j-slf4j-impl</artifactId>
+                    <groupId>org.apache.logging.log4j</groupId>
+                </exclusion>
+                <exclusion>
+                    <artifactId>log4j-core</artifactId>
+                    <groupId>org.apache.logging.log4j</groupId>
+                </exclusion>
+                <exclusion>
+                    <artifactId>log4j-api</artifactId>
+                    <groupId>org.apache.logging.log4j</groupId>
+                </exclusion>
+            </exclusions>
+        </dependency>
+    </dependencies>
+
+</project>
\ No newline at end of file
diff --git a/paimon-web-engine/pom.xml b/paimon-web-engine/pom.xml
new file mode 100644
index 0000000..81a45f5
--- /dev/null
+++ b/paimon-web-engine/pom.xml
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0";
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/xsd/maven-4.0.0.xsd";>
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.apache.paimon</groupId>
+        <artifactId>paimon-webui</artifactId>
+        <version>0.1-SNAPSHOT</version>
+    </parent>
+
+    <artifactId>paimon-web-engine</artifactId>
+    <name>Paimon : Web : Engine</name>
+
+    <packaging>pom</packaging>
+
+    <modules>
+        <module>paimon-web-engine-flink</module>
+    </modules>
+</project>
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index 4e3147a..423e450 100644
--- a/pom.xml
+++ b/pom.xml
@@ -28,6 +28,7 @@ under the License.
         <module>paimon-web-common</module>
         <module>paimon-web-gateway</module>
         <module>paimon-web-api</module>
+        <module>paimon-web-engine</module>
     </modules>
 
     <parent>

Reply via email to