[Fix](seq-col) Fix sequence column check fail #31252
When FE generates plans and reaches the sequence column for rule judgment, an insertion statement that should have been correctly processed fails. This failure occurs because the judgment logic for the sequence part is case-sensitive to column names: the column name is in lowercase in the create table statement, but in uppercase in the insertion statement, causing the sequence column not to be correctly identified. However, Doris itself is case-insensitive to column names. This PR fixes the issue through the use of the ignoreCase method.
This commit is contained in:
@ -467,7 +467,7 @@ public class NativeInsertStmt extends InsertStmt {
|
||||
haveInputSeqCol = true; // case1.b
|
||||
}
|
||||
seqColInTable = olapTable.getFullSchema().stream()
|
||||
.filter(col -> col.getName().equals(olapTable.getSequenceMapCol())).findFirst();
|
||||
.filter(col -> col.getName().equalsIgnoreCase(olapTable.getSequenceMapCol())).findFirst();
|
||||
} else {
|
||||
if (targetColumnNames != null) {
|
||||
if (targetColumnNames.stream()
|
||||
@ -480,7 +480,8 @@ public class NativeInsertStmt extends InsertStmt {
|
||||
if (!haveInputSeqCol && !isPartialUpdate && !isFromDeleteOrUpdateStmt
|
||||
&& !analyzer.getContext().getSessionVariable().isEnableUniqueKeyPartialUpdate()) {
|
||||
if (!seqColInTable.isPresent() || seqColInTable.get().getDefaultValue() == null
|
||||
|| !seqColInTable.get().getDefaultValue().equals(DefaultValue.CURRENT_TIMESTAMP)) {
|
||||
|| !seqColInTable.get().getDefaultValue()
|
||||
.equalsIgnoreCase(DefaultValue.CURRENT_TIMESTAMP)) {
|
||||
throw new AnalysisException("Table " + olapTable.getName()
|
||||
+ " has sequence column, need to specify the sequence column");
|
||||
}
|
||||
@ -488,14 +489,14 @@ public class NativeInsertStmt extends InsertStmt {
|
||||
}
|
||||
|
||||
if (isPartialUpdate && olapTable.hasSequenceCol() && olapTable.getSequenceMapCol() != null
|
||||
&& partialUpdateCols.contains(olapTable.getSequenceMapCol())) {
|
||||
&& partialUpdateCols.stream().anyMatch(c -> c.equalsIgnoreCase(olapTable.getSequenceMapCol()))) {
|
||||
partialUpdateCols.add(Column.SEQUENCE_COL);
|
||||
}
|
||||
// need a descriptor
|
||||
DescriptorTable descTable = analyzer.getDescTbl();
|
||||
olapTuple = descTable.createTupleDescriptor();
|
||||
for (Column col : olapTable.getFullSchema()) {
|
||||
if (isPartialUpdate && !partialUpdateCols.contains(col.getName())) {
|
||||
if (isPartialUpdate && partialUpdateCols.stream().noneMatch(c -> c.equalsIgnoreCase(col.getName()))) {
|
||||
continue;
|
||||
}
|
||||
SlotDescriptor slotDesc = descTable.addSlotDescriptor(olapTuple);
|
||||
|
||||
@ -128,17 +128,20 @@ public class BindSink implements AnalysisRuleFactory {
|
||||
Optional<Column> seqColInTable = Optional.empty();
|
||||
if (table.getSequenceMapCol() != null) {
|
||||
if (!sink.getColNames().isEmpty()) {
|
||||
if (sink.getColNames().contains(table.getSequenceMapCol())) {
|
||||
if (sink.getColNames().stream()
|
||||
.anyMatch(c -> c.equalsIgnoreCase(table.getSequenceMapCol()))) {
|
||||
haveInputSeqCol = true; // case1.a
|
||||
}
|
||||
} else {
|
||||
haveInputSeqCol = true; // case1.b
|
||||
}
|
||||
seqColInTable = table.getFullSchema().stream()
|
||||
.filter(col -> col.getName().equals(table.getSequenceMapCol())).findFirst();
|
||||
.filter(col -> col.getName().equalsIgnoreCase(table.getSequenceMapCol()))
|
||||
.findFirst();
|
||||
} else {
|
||||
if (!sink.getColNames().isEmpty()) {
|
||||
if (sink.getColNames().contains(Column.SEQUENCE_COL)) {
|
||||
if (sink.getColNames().stream()
|
||||
.anyMatch(c -> c.equalsIgnoreCase(Column.SEQUENCE_COL))) {
|
||||
haveInputSeqCol = true; // case2.a
|
||||
} // else case2.b
|
||||
}
|
||||
@ -153,7 +156,7 @@ public class BindSink implements AnalysisRuleFactory {
|
||||
&& boundSink.getDmlCommandType() != DMLCommandType.DELETE)) {
|
||||
if (!seqColInTable.isPresent() || seqColInTable.get().getDefaultValue() == null
|
||||
|| !seqColInTable.get().getDefaultValue()
|
||||
.equals(DefaultValue.CURRENT_TIMESTAMP)) {
|
||||
.equalsIgnoreCase(DefaultValue.CURRENT_TIMESTAMP)) {
|
||||
throw new org.apache.doris.common.AnalysisException("Table " + table.getName()
|
||||
+ " has sequence column, need to specify the sequence column");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user