adonis0147 commented on code in PR #13147:
URL: https://github.com/apache/doris/pull/13147#discussion_r1005145530


##########
fe/fe-core/src/main/java/org/apache/doris/datasource/InternalCatalog.java:
##########
@@ -2091,6 +2100,12 @@ private void createOlapTable(Database db, 
CreateTableStmt stmt) throws UserExcep
 
             throw e;
         }
+
+        // TODO: impl the real logic of create multi-table MaterializedView 
here.
+        if (olapTable instanceof MaterializedView && 
Config.enable_mtmv_scheduler_framework) {
+            
Env.getCurrentEnv().getMtmvJobManager().createJob(MTMVJobFactory.buildJob((MaterializedView)
 olapTable),

Review Comment:
   `getMtmvJobManager` -> `getMTMVJobManager`



##########
fe/fe-core/src/main/java/org/apache/doris/persist/EditLog.java:
##########
@@ -884,6 +890,36 @@ public static void loadJournal(Env env, JournalEntity 
journal) {
                     env.getLoadManager().replayCleanLabel(log);
                     break;
                 }
+                case OperationType.OP_CREATE_MTMV_JOB: {
+                    final MTMVJob job = (MTMVJob) journal.getData();
+                    env.getMtmvJobManager().replayCreateJob(job);

Review Comment:
   `getMtmvJobManager` -> `getMTMVJobManager`



##########
fe/fe-core/src/main/java/org/apache/doris/mtmv/metadata/MTMVTask.java:
##########
@@ -0,0 +1,187 @@
+// 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.doris.mtmv.metadata;
+
+import org.apache.doris.common.io.Text;
+import org.apache.doris.common.io.Writable;
+import org.apache.doris.mtmv.MTMVUtils;
+import org.apache.doris.persist.gson.GsonUtils;
+
+import com.google.gson.annotations.SerializedName;
+
+import java.io.DataInput;
+import java.io.DataOutput;
+import java.io.IOException;
+
+public class MTMVTask implements Writable {
+    // also named query id in ConnectContext
+    @SerializedName("taskId")
+    private String taskId;
+
+    @SerializedName("jobName")
+    private String jobName;
+
+    @SerializedName("createTime")
+    private long createTime;
+
+    @SerializedName("finishTime")
+    private long finishTime;
+
+    @SerializedName("state")
+    private MTMVUtils.TaskState state = MTMVUtils.TaskState.PENDING;
+
+    @SerializedName("dbName")
+    private String dbName;
+
+    @SerializedName("definition")
+    private String definition;
+
+    @SerializedName("user")
+    private String user;
+
+    @SerializedName("errorCode")
+    private int errorCode;
+
+    @SerializedName("errorMessage")
+    private String errorMessage;
+
+    @SerializedName("expireTime")
+    private long expireTime;
+
+    // the larger the value, the higher the priority, the default value is 0
+    @SerializedName("priority")
+    private int priority = 0;
+
+    @SerializedName("retryTimes")
+    private int retryTimes = 0;
+
+    public String getTaskId() {
+        return taskId;
+    }
+
+    public void setTaskId(String taskId) {
+        this.taskId = taskId;
+    }
+
+    public String getJobName() {
+        return jobName;
+    }
+
+    public void setJobName(String jobName) {
+        this.jobName = jobName;
+    }
+
+    public long getCreateTime() {
+        return createTime;
+    }
+
+    public void setCreateTime(long createTime) {
+        this.createTime = createTime;
+    }
+
+    public long getFinishTime() {
+        return finishTime;
+    }
+
+    public void setFinishTime(long finishTime) {
+        this.finishTime = finishTime;
+    }
+
+    public MTMVUtils.TaskState getState() {
+        return state;
+    }
+
+    public void setState(MTMVUtils.TaskState state) {
+        this.state = state;
+    }
+
+    public String getDbName() {
+        return dbName;
+    }
+
+    public void setDbName(String dbName) {
+        this.dbName = dbName;
+    }
+
+    public String getUser() {
+        return user;
+    }
+
+    public void setUser(String user) {
+        this.user = user;
+    }
+
+    public String getDefinition() {

Review Comment:
   `getDefinition` -> `getQuery`



##########
fe/fe-core/src/main/java/org/apache/doris/mtmv/MTMVJobFactory.java:
##########
@@ -0,0 +1,37 @@
+// 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.doris.mtmv;
+
+import org.apache.doris.catalog.MaterializedView;
+import org.apache.doris.mtmv.MTMVUtils.TriggerMode;
+import org.apache.doris.mtmv.metadata.MTMVJob;
+import org.apache.doris.mtmv.metadata.MTMVJob.JobSchedule;
+
+import java.util.concurrent.TimeUnit;
+
+public class MTMVJobFactory {
+    public static MTMVJob buildJob(MaterializedView materializedView) {
+        MTMVJob job = new MTMVJob(materializedView.getName());
+        JobSchedule jobSchedule = new JobSchedule(System.currentTimeMillis() / 
1000, 1, TimeUnit.MINUTES);
+        job.setSchedule(jobSchedule);
+        job.setTriggerMode(TriggerMode.PERIODICAL);
+        job.setDbName("fake");
+        job.setDefinition("select * from fake");

Review Comment:
   `setDefinition` -> `setQuery`



-- 
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: commits-unsubscr...@doris.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to