[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:
Kang
2023-06-19 09:11:36 +08:00
committed by GitHub
parent 1efd345963
commit 0bed52d86b
2 changed files with 9 additions and 2 deletions

View File

@ -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();

View File

@ -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);
}