Skip to content

Commit

Permalink
1
Browse files Browse the repository at this point in the history
  • Loading branch information
Yukang-Lian committed Nov 10, 2023
1 parent 328e5b1 commit d256b83
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,10 @@ public String getTbl() {
return tblName.getTbl();
}

public List<String> getTargetColumnNames() {
return targetColumnNames;
}

public void getTables(Analyzer analyzer, Map<Long, TableIf> tableMap, Set<String> parentViewNameSet)
throws AnalysisException {
if (tableId != -1) {
Expand Down
17 changes: 16 additions & 1 deletion fe/fe-core/src/main/java/org/apache/doris/qe/StmtExecutor.java
Original file line number Diff line number Diff line change
Expand Up @@ -1706,7 +1706,10 @@ private int executeForTxn(InsertStmt insertStmt)
int effectRows = 0;
if (selectStmt.getValueList() != null) {
Table tbl = txnEntry.getTable();
int schemaSize = tbl.getBaseSchema(false).size();
int schemaSize =
(parsedStmt instanceof NativeInsertStmt && ((NativeInsertStmt) parsedStmt).getTargetColumnNames()
.contains(Column.SEQUENCE_COL)) ? tbl.getBaseSchema(false).size() + 1
: tbl.getBaseSchema(false).size();
for (List<Expr> row : selectStmt.getValueList().getRows()) {
// the value columns are columns which are visible to user, so here we use
// getBaseSchema(), not getFullSchema()
Expand Down Expand Up @@ -1780,6 +1783,18 @@ private void beginTxn(String dbName, String tblName) throws UserException, TExce
.setMergeType(TMergeType.APPEND).setThriftRpcTimeoutMs(5000).setLoadId(context.queryId())
.setExecMemLimit(maxExecMemByte).setTimeout((int) timeoutSecond)
.setTimezone(timeZone).setSendBatchParallelism(sendBatchParallelism);
if (parsedStmt instanceof NativeInsertStmt && ((NativeInsertStmt) parsedStmt).getTargetColumnNames()
.contains(Column.SEQUENCE_COL)) {
request.setSequenceCol(Column.SEQUENCE_COL);
StringBuilder allCols = new StringBuilder();
for (String col : ((NativeInsertStmt) parsedStmt).getTargetColumnNames()) {
allCols.append(col);
allCols.append(",");
}
allCols.deleteCharAt(allCols.length() - 1);
request.setColumns(String.valueOf(allCols));
request.setColumnSeparator(",");
}

// execute begin txn
InsertStreamTxnExecutor executor = new InsertStreamTxnExecutor(txnEntry);
Expand Down

0 comments on commit d256b83

Please sign in to comment.