From 9f063ffe153f96436faa24cdbcdf3389146ebc60 Mon Sep 17 00:00:00 2001 From: qidaye Date: Thu, 21 Nov 2024 16:36:21 +0800 Subject: [PATCH] rebuild bf info when replay editlog --- .../doris/alter/SchemaChangeHandler.java | 33 +++++++++++++++---- 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/fe/fe-core/src/main/java/org/apache/doris/alter/SchemaChangeHandler.java b/fe/fe-core/src/main/java/org/apache/doris/alter/SchemaChangeHandler.java index d10bbbf8889e7d..6eaf7d5522c96d 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/alter/SchemaChangeHandler.java +++ b/fe/fe-core/src/main/java/org/apache/doris/alter/SchemaChangeHandler.java @@ -292,8 +292,7 @@ private void processDropColumn(DropColumnClause alterClause, Table externalTable * @throws DdlException */ private boolean processDropColumn(DropColumnClause alterClause, OlapTable olapTable, - Map> indexSchemaMap, List indexes, - Map propertyMap) + Map> indexSchemaMap, List indexes) throws DdlException { String dropColName = alterClause.getColName(); @@ -435,15 +434,16 @@ private boolean processDropColumn(DropColumnClause alterClause, OlapTable olapTa // drop bloom filter column Set bfCols = olapTable.getCopiedBfColumns(); if (bfCols != null) { - Set newBfCols = new HashSet<>(); + Set newBfCols = null; for (String bfCol : bfCols) { if (!bfCol.equalsIgnoreCase(dropColName)) { + if (newBfCols == null) { + newBfCols = Sets.newHashSet(); + } newBfCols.add(bfCol); } } - propertyMap.put(PropertyAnalyzer.PROPERTIES_BF_COLUMNS, Joiner.on(",").join(newBfCols)); - // drop bloom filter column, should write editlog and can not do light schema change - lightSchemaChange = false; + olapTable.setBloomFilterInfo(newBfCols, olapTable.getBfFpp()); } for (int i = 1; i < indexIds.size(); i++) { @@ -2080,7 +2080,7 @@ public int getAsInt() { } else if (alterClause instanceof DropColumnClause) { // drop column and drop indexes on this column boolean clauseCanLigthSchemaChange = processDropColumn((DropColumnClause) alterClause, olapTable, - indexSchemaMap, newIndexes, propertyMap); + indexSchemaMap, newIndexes); if (!clauseCanLigthSchemaChange) { lightSchemaChange = false; } @@ -2956,6 +2956,25 @@ public void modifyTableLightSchemaChange(String rawSql, Database db, OlapTable o LOG.info("finished modify table's add or drop or modify columns. table: {}, job: {}, is replay: {}", olapTable.getName(), jobId, isReplay); } + // for bloom filter, rebuild bloom filter info by table schema in replay + if (isReplay) { + Set bfCols = olapTable.getCopiedBfColumns(); + if (bfCols != null) { + List columns = olapTable.getBaseSchema(); + Set newBfCols = null; + for (String bfCol : bfCols) { + for (Column column : columns) { + if (column.getName().equalsIgnoreCase(bfCol)) { + if (newBfCols == null) { + newBfCols = Sets.newHashSet(); + } + newBfCols.add(column.getName()); + } + } + } + olapTable.setBloomFilterInfo(newBfCols, olapTable.getBfFpp()); + } + } } public void replayModifyTableLightSchemaChange(TableAddOrDropColumnsInfo info)