Skip to content

Commit

Permalink
[Fix](RoutineLoad)Fix when Unique (MoW) RoutineLoad imports unspecifi…
Browse files Browse the repository at this point in the history
…ed Sequence column (#23167)

[Fix](RoutineLoad)Fix when Unique (MoW) routineload imports unspecified Sequence column
  • Loading branch information
CalvinKirs authored Aug 18, 2023
1 parent 26905e3 commit 6847592
Showing 1 changed file with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ private void initColumns(FileLoadScanNode.ParamCreateContext context, Analyzer a
.filter(c -> c.getColumnName().equalsIgnoreCase(finalSequenceCol)).findAny();
// if `columnDescs.descs` is empty, that means it's not a partial update load, and user not specify
// column name.
if (foundCol.isPresent() || columnDescs.descs.isEmpty()) {
if (foundCol.isPresent() || shouldAddSequenceColumn(columnDescs)) {
columnDescs.descs.add(new ImportColumnDesc(Column.SEQUENCE_COL,
new SlotRef(null, sequenceCol)));
} else if (!fileGroupInfo.isPartialUpdate()) {
Expand Down Expand Up @@ -226,6 +226,17 @@ private void initColumns(FileLoadScanNode.ParamCreateContext context, Analyzer a
}
}

/**
* if not set sequence column and column size is null or only have deleted sign ,return true
*/
private boolean shouldAddSequenceColumn(LoadTaskInfo.ImportColumnDescs columnDescs) {
if (columnDescs.descs.isEmpty()) {
return true;
}
return columnDescs.descs.size() == 1 && columnDescs.descs.get(0).getColumnName()
.equalsIgnoreCase(Column.DELETE_SIGN);
}

private TFileFormatType formatType(String fileFormat, String path) throws UserException {
if (fileFormat != null) {
String lowerFileFormat = fileFormat.toLowerCase();
Expand Down

0 comments on commit 6847592

Please sign in to comment.