[fix](inverted index) fix BE coredump because of not ignore case ensitivity for column name when create index (#17276)

This commit is contained in:
YueW
2023-03-01 19:32:39 +08:00
committed by GitHub
parent 3871e989ac
commit b839353c2d
5 changed files with 243 additions and 6 deletions

View File

@ -2128,7 +2128,8 @@ public class SchemaChangeHandler extends AlterHandler {
*/
private boolean processAddIndex(CreateIndexClause alterClause, OlapTable olapTable, List<Index> newIndexes)
throws UserException {
if (alterClause.getIndex() == null) {
Index alterIndex = alterClause.getIndex();
if (alterIndex == null) {
return false;
}
@ -2166,7 +2167,12 @@ public class SchemaChangeHandler extends AlterHandler {
}
}
newIndexes.add(alterClause.getIndex());
// the column name in CreateIndexClause is not check case sensitivity,
// when send index description to BE, there maybe cannot find column by name,
// so here update column name in CreateIndexClause after checkColumn for indexDef,
// there will use the column name in olapTable insead of the column name in CreateIndexClause.
alterIndex.setColumns(indexDef.getColumns());
newIndexes.add(alterIndex);
return false;
}

View File

@ -24,6 +24,7 @@ import org.apache.doris.catalog.PrimitiveType;
import org.apache.doris.common.AnalysisException;
import com.google.common.base.Strings;
import com.google.common.collect.Lists;
import java.util.HashMap;
import java.util.List;
@ -34,6 +35,9 @@ public class IndexDef {
private String indexName;
private boolean ifNotExists;
private List<String> columns;
// add the column name of olapTable column into caseSensitivityColumns
// instead of the column name which from sql_parser analyze
private List<String> caseSensitivityColumns = Lists.newArrayList();
private IndexType indexType;
private String comment;
private Map<String, String> properties;
@ -142,6 +146,9 @@ public class IndexDef {
}
public List<String> getColumns() {
if (caseSensitivityColumns.size() > 0) {
return caseSensitivityColumns;
}
return columns;
}
@ -176,6 +183,7 @@ public class IndexDef {
if (indexType == IndexType.BITMAP || indexType == IndexType.INVERTED || indexType == IndexType.BLOOMFILTER
|| indexType == IndexType.NGRAM_BF) {
String indexColName = column.getName();
caseSensitivityColumns.add(indexColName);
PrimitiveType colType = column.getDataType();
if (indexType == IndexType.INVERTED && colType.isArrayType()) {
colType = ((ArrayType) column.getType()).getItemType().getPrimitiveType();