imay commented on a change in pull request #1597: Support checking error data 
row when doing INSERT
URL: https://github.com/apache/incubator-doris/pull/1597#discussion_r314669650
 
 

 ##########
 File path: fe/src/main/java/org/apache/doris/qe/StmtExecutor.java
 ##########
 @@ -612,35 +616,36 @@ private void handleInsertStmt() throws Exception {
             if (!coord.getExecStatus().ok()) {
                 String errMsg = coord.getExecStatus().getErrorMsg();
                 LOG.warn("insert failed: {}", errMsg);
-
-                // hide host info
-                int hostIndex = errMsg.indexOf("host");
-                if (hostIndex != -1) {
-                    errMsg = errMsg.substring(0, hostIndex);
-                }
                 ErrorReport.reportDdlException(errMsg, 
ErrorCode.ERR_FAILED_WHEN_INSERT);
             }
 
-            LOG.info("delta files is {}", coord.getDeltaUrls());
+            LOG.debug("delta files is {}", coord.getDeltaUrls());
+
+            if (coord.getLoadCounters().get(LoadEtlTask.DPP_NORMAL_ALL) != 
null) {
+                loadedRows = 
Long.valueOf(coord.getLoadCounters().get(LoadEtlTask.DPP_NORMAL_ALL));
+            }
+            if (coord.getLoadCounters().get(LoadEtlTask.DPP_ABNORMAL_ALL) != 
null) {
+                filteredRows = 
Integer.valueOf(coord.getLoadCounters().get(LoadEtlTask.DPP_ABNORMAL_ALL));
+            }
 
+            // if in strict mode, insert will fail if there are filtered rows
             if (context.getSessionVariable().getEnableInsertStrict()) {
-                Map<String, String> counters = coord.getLoadCounters();
-                String strValue = counters.get(LoadEtlTask.DPP_ABNORMAL_ALL);
-                if (strValue != null && Long.valueOf(strValue) > 0) {
-                    throw new UserException("Insert has filtered data in 
strict mode, tracking_url="
+                if (filteredRows > 0) {
+                    context.getState().setError("Insert has filtered data in 
strict mode, tracking_url="
                             + coord.getTrackingUrl());
+                    return;
                 }
             }
 
             if (insertStmt.getTargetTable().getType() != TableType.OLAP) {
                 // no need to add load job.
                 // MySQL table is already being inserted.
-                context.getState().setOk();
+                context.getState().setOk(loadedRows, filteredRows, null);
                 return;
             }
 
-            if (insertStmt.getQueryStmt() != null && (coord.getCommitInfos() 
== null || coord.getCommitInfos().isEmpty())) {
-                
Catalog.getCurrentGlobalTransactionMgr().abortTransaction(insertStmt.getTransactionId(),
 "select stmt return empty set when insert");
+            if (loadedRows == 0 && filteredRows == 0) {
+                // if no data, just return ok
 
 Review comment:
   abort transaction.

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to