Code review comment: seems you could use `partitionExpr.collect(SlotRef.class, slots);`

Code under review:
public void processTaskRun(TaskRunContext context) throws Exception {
        Map<String, String> properties = context.getProperties();
        
        long mvId = Long.parseLong(properties.get("mvId"));
        
        Database database = GlobalStateMgr.getCurrentState().getDb(context.ctx.getDatabase());
        MaterializedView materializedView = (MaterializedView) database.getTable(mvId);
        Set<Long> baseTableIds = materializedView.getBaseTableIds();
        PartitionInfo partitionInfo = materializedView.getPartitionInfo();
        if (partitionInfo instanceof SinglePartitionInfo) {
            Map<Long, Map<Long, Long>> baseTableVisibleVersionMap =
                    materializedView.getRefreshScheme().getAsyncRefreshContext().getBaseTableVisibleVersionMap();
            for (Long baseTableId : baseTableIds) {
                OlapTable olapTable = (OlapTable) database.getTable(baseTableId);
                Map<Long, Long> basePartitionVersions =
                        baseTableVisibleVersionMap.computeIfAbsent(baseTableId, k -> Maps.newHashMap());
                Collection<Partition> partitions = olapTable.getPartitions();
                boolean needRefresh = false;
                for (Partition partition : partitions) {
                    long basePartitionId = partition.getId();
                    long basePartitionVersion = partition.getVisibleVersion();
                    Long oldVersion = basePartitionVersions.get(basePartitionId);
                    if (oldVersion == null || basePartitionVersion > oldVersion.longValue()) {
                        needRefresh = true;
                        basePartitionVersions.put(basePartitionId, basePartitionVersion);
                    }
                }
                if (needRefresh) {
                    refreshMv(context, materializedView);
                }
            }
            return;
        }
        Map<String, String> partitionProperties = getPartitionProperties(materializedView);
        DistributionDesc distributionDesc = getDistributionDesc(materializedView);
        ExpressionRangePartitionInfo expressionRangePartitionInfo =
                ((ExpressionRangePartitionInfo) partitionInfo);
        
        Expr partitionExpr = expressionRangePartitionInfo.getPartitionExprs().get(0);
        Column partitionColumn = expressionRangePartitionInfo.getPartitionColumns().get(0);
        
        Map<Long, OlapTable> olapTables = Maps.newHashMap();
        OlapTable partitionTable = null;
        for (Long baseTableId : baseTableIds) {
            OlapTable olapTable = (OlapTable) database.getTable(baseTableId);
            SlotRef slotRef;
            if (partitionExpr instanceof SlotRef) {
                slotRef = ((SlotRef) partitionExpr);
            } else {
                FunctionCallExpr functionCallExpr = (FunctionCallExpr) partitionExpr;
                slotRef = getFirstSlotRefInFunction(functionCallExpr);
            }
            if (slotRef.getTblNameWithoutAnalyzed().getTbl().equals(olapTable.getName())) {
                partitionTable = olapTable;
            }
            olapTables.put(baseTableId, olapTable);
        }
        
        Set<Long> needRefreshPartitionIds = Sets.newHashSet();
        processPartitionWithPartitionTable(database, materializedView, partitionTable,
                partitionExpr, partitionColumn, partitionProperties,
                distributionDesc, needRefreshPartitionIds);
        
        boolean refreshAllPartitions = false;
        for (Long baseTableId : baseTableIds) {
            if (baseTableId == partitionTable.getId()) {
                continue;
            }
            OlapTable olapTable = olapTables.get(baseTableId);
            if (checkNeedRefreshPartitions(materializedView, olapTable)) {
                refreshAllPartitions = true;
            }
        }
        
        if (refreshAllPartitions) {
            refreshMv(context, materializedView);
        } else {
            refreshMv(context, materializedView, partitionTable, needRefreshPartitionIds);
        }
    }

Line commented on: slotRef = ((SlotRef) partitionExpr);

Revised code:
public void processTaskRun(TaskRunContext context) throws Exception {
        Map<String, String> properties = context.getProperties();
        
        long mvId = Long.parseLong(properties.get(MV_ID));
        
        Database database = GlobalStateMgr.getCurrentState().getDb(context.ctx.getDatabase());
        MaterializedView materializedView = (MaterializedView) database.getTable(mvId);
        Set<Long> baseTableIds = materializedView.getBaseTableIds();
        PartitionInfo partitionInfo = materializedView.getPartitionInfo();
        if (partitionInfo instanceof SinglePartitionInfo) {
            
            Preconditions.checkState(materializedView.getPartitions().size() != 0);
            Map<Long, Map<Long, Long>> baseTableVisibleVersionMap =
                    materializedView.getRefreshScheme().getAsyncRefreshContext().getBaseTableVisibleVersionMap();
            for (Long baseTableId : baseTableIds) {
                OlapTable olapTable = (OlapTable) database.getTable(baseTableId);
                Map<Long, Long> basePartitionVersions =
                        baseTableVisibleVersionMap.computeIfAbsent(baseTableId, k -> Maps.newHashMap());
                Collection<Partition> partitions = olapTable.getPartitions();
                boolean needRefresh = false;
                for (Partition partition : partitions) {
                    long basePartitionId = partition.getId();
                    long basePartitionVersion = partition.getVisibleVersion();
                    Long oldVersion = basePartitionVersions.get(basePartitionId);
                    if (oldVersion == null || basePartitionVersion > oldVersion.longValue()) {
                        needRefresh = true;
                        basePartitionVersions.put(basePartitionId, basePartitionVersion);
                    }
                }
                if (needRefresh) {
                    refreshMv(context, materializedView);
                }
            }
            return;
        }
        Map<String, String> partitionProperties = getPartitionProperties(materializedView);
        DistributionDesc distributionDesc = getDistributionDesc(materializedView);
        ExpressionRangePartitionInfo expressionRangePartitionInfo =
                ((ExpressionRangePartitionInfo) partitionInfo);
        
        Preconditions.checkState(expressionRangePartitionInfo.getPartitionExprs().size() == 1);
        Expr partitionExpr = expressionRangePartitionInfo.getPartitionExprs().get(0);
        Column partitionColumn = expressionRangePartitionInfo.getPartitionColumns().get(0);
        
        Map<Long, OlapTable> olapTables = Maps.newHashMap();
        OlapTable partitionTable = null;
        for (Long baseTableId : baseTableIds) {
            OlapTable olapTable = (OlapTable) database.getTable(baseTableId);
            List<SlotRef> slotRefs = Lists.newArrayList();
            partitionExpr.collect(SlotRef.class, slotRefs);
            
            Preconditions.checkState(slotRefs.size() == 1);
            SlotRef slotRef = slotRefs.get(0);
            if (slotRef.getTblNameWithoutAnalyzed().getTbl().equals(olapTable.getName())) {
                partitionTable = olapTable;
            }
            olapTables.put(baseTableId, olapTable);
        }
        
        Set<Long> needRefreshPartitionIds = Sets.newHashSet();
        processPartitionWithPartitionTable(database, materializedView, partitionTable,
                partitionExpr, partitionColumn, partitionProperties,
                distributionDesc, needRefreshPartitionIds);
        
        boolean refreshAllPartitions = false;
        for (Long baseTableId : baseTableIds) {
            if (baseTableId == partitionTable.getId()) {
                continue;
            }
            OlapTable olapTable = olapTables.get(baseTableId);
            if (checkNeedRefreshPartitions(materializedView, olapTable)) {
                refreshAllPartitions = true;
            }
        }
        
        if (refreshAllPartitions) {
            refreshMv(context, materializedView);
        } else {
            refreshMv(context, materializedView, partitionTable, needRefreshPartitionIds);
        }
    }