morningman commented on a change in pull request #2718: [Insert] Return more 
info of insert operation
URL: https://github.com/apache/incubator-doris/pull/2718#discussion_r366345755
 
 

 ##########
 File path: fe/src/main/java/org/apache/doris/qe/StmtExecutor.java
 ##########
 @@ -692,37 +697,36 @@ private void handleInsertStmt() throws Exception {
             throwable = t;
         }
 
-        // record insert info for show load stmt if
-        // 1. NOT a streaming insert(deprecated)
-        // 2. using_old_load_usage_pattern is set to true, means a label will 
be returned for user to show load.
-        // 3. has filtered rows. so a label should be returned for user to show
-        // 4. user specify a label for insert stmt
-        if (!insertStmt.isStreaming() || Config.using_old_load_usage_pattern 
|| filteredRows > 0 || insertStmt.isUserSpecifiedLabel()) {
-            try {
-                context.getCatalog().getLoadManager().recordFinishedLoadJob(
-                        label,
-                        insertStmt.getDb(),
-                        insertStmt.getTargetTable().getId(),
-                        EtlJobType.INSERT,
-                        createTime,
-                        throwable == null ? "" : throwable.getMessage(),
-                        coord.getTrackingUrl()
-                );
-            } catch (MetaNotFoundException e) {
-                LOG.warn("Record info of insert load with error {}", 
e.getMessage(), e);
-                context.getState().setError("Failed to record info of insert 
load job, but insert job is "
-                        + (throwable == null ? "success" : "failed"));
-                return;
-            }
+        // Go here, which means:
+        // 1. transaction is finished successfully (COMMITTED or VISIBLE), or
+        // 2. transaction failed but Config.using_old_load_usage_pattern is 
true.
+        // we will record the load job info for these 2 cases
 
-            // set to OK, which means the insert load job is successfully 
submitted.
-            // and user can check the job's status by label.
-            context.getState().setOk(loadedRows, filteredRows, "{'label':'" + 
label + "'}");
-        } else {
-            // just return OK without label, which means this job is 
successfully done without any error.
-            Preconditions.checkState(loadedRows > 0 && filteredRows == 0);
-            context.getState().setOk(loadedRows, filteredRows, null);
-        }
+        String errMsg = "";
+        try {
+            context.getCatalog().getLoadManager().recordFinishedLoadJob(
+                    label,
+                    insertStmt.getDb(),
+                    insertStmt.getTargetTable().getId(),
+                    EtlJobType.INSERT,
+                    createTime,
+                    throwable == null ? "" : throwable.getMessage(),
+                    coord.getTrackingUrl());
+        } catch (MetaNotFoundException e) {
+            LOG.warn("Record info of insert load with error {}", 
e.getMessage(), e);
+            errMsg = "Record info of insert load with error " + e.getMessage();
+        }
+
+        // {'label':'my_label1', 'status':'visible', 'txnId':'123'}
+        // {'label':'my_label1', 'status':'visible', 'txnId':'123' 
'err':'error messages'}
+        String info = "{'label':'" + label + "', 'status':'" + 
txnStatus.name() + "', 'txnId':'"
 
 Review comment:
   ok

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

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

Reply via email to