This is an automated email from the ASF dual-hosted git repository. yiguolei pushed a commit to branch branch-2.1 in repository https://gitbox.apache.org/repos/asf/doris.git
commit 64056bb96b0464246b0e0a3745270c7b7ccd97ec Author: abmdocrt <[email protected]> AuthorDate: Thu Feb 22 17:43:21 2024 +0800 [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 fix [...] --- .../main/java/org/apache/doris/analysis/NativeInsertStmt.java | 9 +++++---- .../org/apache/doris/nereids/rules/analysis/BindSink.java | 11 +++++++---- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/NativeInsertStmt.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/NativeInsertStmt.java index 1b0d8e59dd2..b9e74557cd2 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/analysis/NativeInsertStmt.java +++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/NativeInsertStmt.java @@ -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); diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/BindSink.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/BindSink.java index c0e8162f08f..5c8a74f00e6 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/BindSink.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/BindSink.java @@ -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"); } --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
