[Bug](delete) ignore case on delete from command and add check on deletejob dispatch (#31593)
ignore case on delete from command and add check on deletejob dispatch
This commit is contained in:
@ -18,6 +18,7 @@
|
||||
package org.apache.doris.load;
|
||||
|
||||
import org.apache.doris.analysis.BinaryPredicate;
|
||||
import org.apache.doris.analysis.CreateMaterializedViewStmt;
|
||||
import org.apache.doris.analysis.InPredicate;
|
||||
import org.apache.doris.analysis.IsNullPredicate;
|
||||
import org.apache.doris.analysis.LiteralExpr;
|
||||
@ -78,6 +79,7 @@ import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class DeleteJob extends AbstractTxnStateChangeCallback implements DeleteJobLifeCycle {
|
||||
@ -304,6 +306,23 @@ public class DeleteJob extends AbstractTxnStateChangeCallback implements DeleteJ
|
||||
columnsDesc.add(column.toThrift());
|
||||
}
|
||||
|
||||
Map<String, TColumn> colNameToColDesc = columnsDesc.stream()
|
||||
.collect(Collectors.toMap(c -> c.getColumnName(), Function.identity(), (v1, v2) -> v1,
|
||||
() -> Maps.newTreeMap(String.CASE_INSENSITIVE_ORDER)));
|
||||
for (Predicate condition : deleteConditions) {
|
||||
SlotRef slotRef = (SlotRef) condition.getChild(0);
|
||||
String columnName = new String(slotRef.getColumnName());
|
||||
TColumn column = colNameToColDesc.get(slotRef.getColumnName());
|
||||
if (column == null) {
|
||||
columnName = CreateMaterializedViewStmt.mvColumnBuilder(columnName);
|
||||
column = colNameToColDesc.get(columnName);
|
||||
}
|
||||
if (column == null) {
|
||||
throw new AnalysisException(
|
||||
"condition's column not founded in index, column=" + columnName + " , index=" + index);
|
||||
}
|
||||
}
|
||||
|
||||
for (Tablet tablet : index.getTablets()) {
|
||||
long tabletId = tablet.getId();
|
||||
|
||||
|
||||
@ -67,6 +67,7 @@ import org.apache.commons.lang3.StringUtils;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
@ -244,9 +245,10 @@ public class DeleteFromCommand extends Command implements ForwardWithSync {
|
||||
|
||||
for (String indexName : table.getIndexNameToId().keySet()) {
|
||||
MaterializedIndexMeta meta = table.getIndexMetaByIndexId(table.getIndexIdByName(indexName));
|
||||
Set<String> columns = meta.getSchema().stream()
|
||||
Set<String> columns = new TreeSet<>(String.CASE_INSENSITIVE_ORDER);
|
||||
meta.getSchema().stream()
|
||||
.map(col -> org.apache.doris.analysis.CreateMaterializedViewStmt.mvColumnBreaker(col.getName()))
|
||||
.collect(Collectors.toSet());
|
||||
.forEach(name -> columns.add(name));
|
||||
if (!columns.contains(column.getName())) {
|
||||
throw new AnalysisException("Column[" + column.getName() + "] not exist in index " + indexName
|
||||
+ ". maybe you need drop the corresponding materialized-view.");
|
||||
|
||||
Reference in New Issue
Block a user