[bugfix](inverted index) fix not writing inverted index file if upgrade from old version #20945
The metadata indexes in MaterializedIndexMeta is introduced in 2.0-beta version and it's relied by writing inverted index. When upgrade doris from old version to 2.0-beta, the metadata indexes in MaterializedIndexMeta is empty and no inverted index file will be written. This PR add compatibility logic to use metadata indexes in table if indexes in MaterializedIndexMeta is empty and indexes in MaterializedIndexMeta indexId is equal to table baseIndexId. This PR also fix metadata indexes missing for schema change.
This commit is contained in:
@ -365,7 +365,8 @@ public class SchemaChangeJobV2 extends AlterJobV2 {
|
||||
indexSchemaVersionAndHashMap.get(shadowIdxId).schemaVersion,
|
||||
indexSchemaVersionAndHashMap.get(shadowIdxId).schemaHash,
|
||||
indexShortKeyMap.get(shadowIdxId), TStorageType.COLUMN,
|
||||
tbl.getKeysTypeByIndexId(indexIdMap.get(shadowIdxId)), null);
|
||||
tbl.getKeysTypeByIndexId(indexIdMap.get(shadowIdxId)),
|
||||
indexChange ? indexes : tbl.getIndexMetaByIndexId(indexIdMap.get(shadowIdxId)).getIndexes());
|
||||
}
|
||||
|
||||
tbl.rebuildFullSchema();
|
||||
|
||||
@ -228,7 +228,13 @@ public class OlapTableSink extends DataSink {
|
||||
column.setIndexFlag(tColumn, table);
|
||||
columnsDesc.add(tColumn);
|
||||
}
|
||||
for (Index index : indexMeta.getIndexes()) {
|
||||
List<Index> indexes = indexMeta.getIndexes();
|
||||
if (indexes.size() == 0 && pair.getKey() == table.getBaseIndexId()) {
|
||||
// for compatible with old version befor 2.0-beta
|
||||
// if indexMeta.getIndexes() is empty, use table.getIndexes()
|
||||
indexes = table.getIndexes();
|
||||
}
|
||||
for (Index index : indexes) {
|
||||
TOlapTableIndex tIndex = index.toThrift();
|
||||
indexDesc.add(tIndex);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user