Code review comment: snapShotPaimonTable

Code before review:
private boolean checkBaseTablePartitionChange() {
for (Pair<BaseTableInfo, Table> tablePair : snapshotBaseTables.values()) {
BaseTableInfo baseTableInfo = tablePair.first;
Table snapshotTable = tablePair.second;
Database db = baseTableInfo.getDb();
if (db == null) {
return true;
}
db.readLock();
try {
Table table = baseTableInfo.getTable();
if (table == null) {
return true;
}
if (snapshotTable.isOlapOrCloudNativeTable()) {
OlapTable snapShotOlapTable = (OlapTable) snapshotTable;
PartitionInfo snapshotPartitionInfo = snapShotOlapTable.getPartitionInfo();
if (snapshotPartitionInfo instanceof SinglePartitionInfo) {
Set<String> partitionNames = ((OlapTable) table).getVisiblePartitionNames();
if (!snapShotOlapTable.getVisiblePartitionNames().equals(partitionNames)) {
return true;
}
} else if (snapshotPartitionInfo instanceof ListPartitionInfo) {
Map<String, List<List<String>>> snapshotPartitionMap =
snapShotOlapTable.getListPartitionMap();
Map<String, List<List<String>>> currentPartitionMap =
((OlapTable) table).getListPartitionMap();
return SyncPartitionUtils.hasListPartitionChanged(snapshotPartitionMap, currentPartitionMap);
} else {
Map<String, Range<PartitionKey>> snapshotPartitionMap =
snapShotOlapTable.getRangePartitionMap();
Map<String, Range<PartitionKey>> currentPartitionMap =
((OlapTable) table).getRangePartitionMap();
return SyncPartitionUtils.hasRangePartitionChanged(snapshotPartitionMap, currentPartitionMap);
}
} else if (snapshotTable.isHiveTable() || snapshotTable.isHudiTable()) {
HiveMetaStoreTable snapShotHMSTable = (HiveMetaStoreTable) snapshotTable;
if (snapShotHMSTable.isUnPartitioned()) {
if (!((HiveMetaStoreTable) table).isUnPartitioned()) {
return true;
}
} else {
PartitionInfo mvPartitionInfo = materializedView.getPartitionInfo();
if  (!(mvPartitionInfo instanceof ExpressionRangePartitionInfo)) {
return false;
}
Pair<Table, Column> partitionTableAndColumn = getRefBaseTableAndPartitionColumn(snapshotBaseTables);
Column partitionColumn = partitionTableAndColumn.second;
if (!snapshotTable.equals(partitionTableAndColumn.first)
|| !snapshotTable.containColumn(partitionColumn.getName())) {
continue;
}
Map<String, Range<PartitionKey>> snapshotPartitionMap = PartitionUtil.
getPartitionKeyRange(snapshotTable, partitionColumn);
Map<String, Range<PartitionKey>> currentPartitionMap = PartitionUtil.
getPartitionKeyRange(table, partitionColumn);
return SyncPartitionUtils.hasRangePartitionChanged(snapshotPartitionMap, currentPartitionMap);
}
} else if (snapshotTable.isIcebergTable()) {
IcebergTable snapShotIcebergTable = (IcebergTable) snapshotTable;
if (snapShotIcebergTable.isUnPartitioned()) {
if (!table.isUnPartitioned()) {
return true;
}
} else {
PartitionInfo mvPartitionInfo = materializedView.getPartitionInfo();
if  (!(mvPartitionInfo instanceof ExpressionRangePartitionInfo)) {
return false;
}
Pair<Table, Column> partitionTableAndColumn = getRefBaseTableAndPartitionColumn(snapshotBaseTables);
Column partitionColumn = partitionTableAndColumn.second;
if (!snapshotTable.equals(partitionTableAndColumn.first)
|| !snapShotIcebergTable.containColumn(partitionColumn.getName())) {
continue;
}
Map<String, Range<PartitionKey>> snapshotPartitionMap = PartitionUtil.
getPartitionKeyRange(snapshotTable, partitionColumn);
Map<String, Range<PartitionKey>> currentPartitionMap = PartitionUtil.
getPartitionKeyRange(table, partitionColumn);
return SyncPartitionUtils.hasRangePartitionChanged(snapshotPartitionMap, currentPartitionMap);
}
} else if (snapshotTable.isPaimonTable()) {
PaimonTable snapShotIcebergTable = (PaimonTable) snapshotTable;
if (snapShotIcebergTable.isUnPartitioned()) {
if (!table.isUnPartitioned()) {
return true;
}
} else {
PartitionInfo mvPartitionInfo = materializedView.getPartitionInfo();
if (!(mvPartitionInfo instanceof ExpressionRangePartitionInfo)) {
return false;
}
Pair<Table, Column> partitionTableAndColumn =
getRefBaseTableAndPartitionColumn(snapshotBaseTables);
Column partitionColumn = partitionTableAndColumn.second;
if (!snapshotTable.equals(partitionTableAndColumn.first)
|| !snapShotIcebergTable.containColumn(partitionColumn.getName())) {
continue;
}
Map<String, Range<PartitionKey>> snapshotPartitionMap = PartitionUtil.
getPartitionKeyRange(snapshotTable, partitionColumn);
Map<String, Range<PartitionKey>> currentPartitionMap = PartitionUtil.
getPartitionKeyRange(table, partitionColumn);
return SyncPartitionUtils.hasRangePartitionChanged(snapshotPartitionMap, currentPartitionMap);
}
}
} catch (UserException e) {
LOG.warn("Materialized view compute partition change failed", e);
return true;
} finally {
db.readUnlock();
}
}
return false;
}

Line under review: PaimonTable snapShotIcebergTable = (PaimonTable) snapshotTable;

Code after addressing the review:
private boolean checkBaseTablePartitionChange() {
for (Pair<BaseTableInfo, Table> tablePair : snapshotBaseTables.values()) {
BaseTableInfo baseTableInfo = tablePair.first;
Table snapshotTable = tablePair.second;
Database db = baseTableInfo.getDb();
if (db == null) {
return true;
}
db.readLock();
try {
Table table = baseTableInfo.getTable();
if (table == null) {
return true;
}
if (snapshotTable.isOlapOrCloudNativeTable()) {
OlapTable snapShotOlapTable = (OlapTable) snapshotTable;
PartitionInfo snapshotPartitionInfo = snapShotOlapTable.getPartitionInfo();
if (snapshotPartitionInfo instanceof SinglePartitionInfo) {
Set<String> partitionNames = ((OlapTable) table).getVisiblePartitionNames();
if (!snapShotOlapTable.getVisiblePartitionNames().equals(partitionNames)) {
return true;
}
} else if (snapshotPartitionInfo instanceof ListPartitionInfo) {
Map<String, List<List<String>>> snapshotPartitionMap =
snapShotOlapTable.getListPartitionMap();
Map<String, List<List<String>>> currentPartitionMap =
((OlapTable) table).getListPartitionMap();
return SyncPartitionUtils.hasListPartitionChanged(snapshotPartitionMap, currentPartitionMap);
} else {
Map<String, Range<PartitionKey>> snapshotPartitionMap =
snapShotOlapTable.getRangePartitionMap();
Map<String, Range<PartitionKey>> currentPartitionMap =
((OlapTable) table).getRangePartitionMap();
return SyncPartitionUtils.hasRangePartitionChanged(snapshotPartitionMap, currentPartitionMap);
}
} else if (snapshotTable.isHiveTable() || snapshotTable.isHudiTable()) {
HiveMetaStoreTable snapShotHMSTable = (HiveMetaStoreTable) snapshotTable;
if (snapShotHMSTable.isUnPartitioned()) {
if (!((HiveMetaStoreTable) table).isUnPartitioned()) {
return true;
}
} else {
PartitionInfo mvPartitionInfo = materializedView.getPartitionInfo();
if  (!(mvPartitionInfo instanceof ExpressionRangePartitionInfo)) {
return false;
}
Pair<Table, Column> partitionTableAndColumn = getRefBaseTableAndPartitionColumn(snapshotBaseTables);
Column partitionColumn = partitionTableAndColumn.second;
if (!snapshotTable.equals(partitionTableAndColumn.first)
|| !snapshotTable.containColumn(partitionColumn.getName())) {
continue;
}
Map<String, Range<PartitionKey>> snapshotPartitionMap = PartitionUtil.
getPartitionKeyRange(snapshotTable, partitionColumn);
Map<String, Range<PartitionKey>> currentPartitionMap = PartitionUtil.
getPartitionKeyRange(table, partitionColumn);
return SyncPartitionUtils.hasRangePartitionChanged(snapshotPartitionMap, currentPartitionMap);
}
} else if (snapshotTable.isIcebergTable()) {
IcebergTable snapShotIcebergTable = (IcebergTable) snapshotTable;
if (snapShotIcebergTable.isUnPartitioned()) {
if (!table.isUnPartitioned()) {
return true;
}
} else {
PartitionInfo mvPartitionInfo = materializedView.getPartitionInfo();
if  (!(mvPartitionInfo instanceof ExpressionRangePartitionInfo)) {
return false;
}
Pair<Table, Column> partitionTableAndColumn = getRefBaseTableAndPartitionColumn(snapshotBaseTables);
Column partitionColumn = partitionTableAndColumn.second;
if (!snapshotTable.equals(partitionTableAndColumn.first)
|| !snapShotIcebergTable.containColumn(partitionColumn.getName())) {
continue;
}
Map<String, Range<PartitionKey>> snapshotPartitionMap = PartitionUtil.
getPartitionKeyRange(snapshotTable, partitionColumn);
Map<String, Range<PartitionKey>> currentPartitionMap = PartitionUtil.
getPartitionKeyRange(table, partitionColumn);
return SyncPartitionUtils.hasRangePartitionChanged(snapshotPartitionMap, currentPartitionMap);
}
} else if (snapshotTable.isJDBCTable()) {
JDBCTable snapShotJDBCTable = (JDBCTable) snapshotTable;
if (snapShotJDBCTable.isUnPartitioned()) {
if (!table.isUnPartitioned()) {
return true;
}
} else {
PartitionInfo mvPartitionInfo = materializedView.getPartitionInfo();
if  (!(mvPartitionInfo instanceof ExpressionRangePartitionInfo)) {
return false;
}
Pair<Table, Column> partitionTableAndColumn = getRefBaseTableAndPartitionColumn(snapshotBaseTables);
Column partitionColumn = partitionTableAndColumn.second;
if (!snapshotTable.equals(partitionTableAndColumn.first)
|| !snapShotJDBCTable.containColumn(partitionColumn.getName())) {
continue;
}
Map<String, Range<PartitionKey>> snapshotPartitionMap = PartitionUtil.
getPartitionKeyRange(snapshotTable, partitionColumn);
Map<String, Range<PartitionKey>> currentPartitionMap = PartitionUtil.
getPartitionKeyRange(table, partitionColumn);
return SyncPartitionUtils.hasRangePartitionChanged(snapshotPartitionMap, currentPartitionMap);
}
} else if (snapshotTable.isPaimonTable()) {
PaimonTable snapShotPaimonTable = (PaimonTable) snapshotTable;
if (snapShotPaimonTable.isUnPartitioned()) {
if (!table.isUnPartitioned()) {
return true;
}
} else {
PartitionInfo mvPartitionInfo = materializedView.getPartitionInfo();
if (!(mvPartitionInfo instanceof ExpressionRangePartitionInfo)) {
return false;
}
Pair<Table, Column> partitionTableAndColumn =
getRefBaseTableAndPartitionColumn(snapshotBaseTables);
Column partitionColumn = partitionTableAndColumn.second;
if (!snapshotTable.equals(partitionTableAndColumn.first)
|| !snapShotPaimonTable.containColumn(partitionColumn.getName())) {
continue;
}
Map<String, Range<PartitionKey>> snapshotPartitionMap = PartitionUtil.
getPartitionKeyRange(snapshotTable, partitionColumn);
Map<String, Range<PartitionKey>> currentPartitionMap = PartitionUtil.
getPartitionKeyRange(table, partitionColumn);
return SyncPartitionUtils.hasRangePartitionChanged(snapshotPartitionMap, currentPartitionMap);
}
}
} catch (UserException e) {
LOG.warn("Materialized view compute partition change failed", e);
return true;
} finally {
db.readUnlock();
}
}
return false;
}