private static Boolean isOutdatedMaterializedView(
    String materializationTxnList, String validTxnsList, HiveTxnManager txnMgr,
    Set<TableName> tablesUsed, Table materializedViewTable) throws LockException {
    List<String> tablesUsedNames = tablesUsed.stream()
        .map(tableName -> TableName.getDbTable(tableName.getDb(), tableName.getTable()))
        .collect(Collectors.toList());
    ValidTxnWriteIdList currentTxnWriteIds = txnMgr.getValidWriteIds(tablesUsedNames,
        validTxnsList);
    if (currentTxnWriteIds == null) {
      LOG.debug("Materialized view " + materializedViewTable.getFullyQualifiedName() +
              " ignored for rewriting as we could not obtain current txn ids");
      return null;
    }

    Set<String> storedTablesUsed = materializedViewTable.getMVMetadata().getSourceTableFullNames();
    if (materializationTxnList == null || materializationTxnList.isEmpty()) {
      LOG.debug("Materialized view " + materializedViewTable.getFullyQualifiedName() +
              " ignored for rewriting as we could not obtain materialization txn ids");
      return null;
    }
    ValidTxnWriteIdList materializationTxnWriteIds = ValidTxnWriteIdList.fromValue(materializationTxnList);
    boolean ignore = false;
    for (String fullyQualifiedTableName : tablesUsedNames) {
      // Note. If the materialized view does not contain a table that is contained in the query,
      // we do not need to check whether that specific table is outdated or not. If a rewriting
      // is produced in those cases, it is because that additional table is joined with the
      // existing tables with an append-columns only join, i.e., PK-FK + not null.
      if (!storedTablesUsed.contains(fullyQualifiedTableName)) {
        continue;
      }
      ValidWriteIdList tableCurrentWriteIds = currentTxnWriteIds.getTableValidWriteIdList(fullyQualifiedTableName);
      if (tableCurrentWriteIds == null) {
        // Uses non-transactional table, cannot be considered
        LOG.debug("Materialized view " + materializedViewTable.getFullyQualifiedName() +
                " ignored for rewriting as it is outdated and cannot be considered for " +
                " rewriting because it uses non-transactional table " + fullyQualifiedTableName);
        ignore = true;
        break;
      }
      ValidWriteIdList tableWriteIds = materializationTxnWriteIds.getTableValidWriteIdList(fullyQualifiedTableName);
      if (tableWriteIds == null) {
        // This should not happen, but we ignore for safety
        LOG.warn("Materialized view " + materializedViewTable.getFullyQualifiedName() +
                " ignored for rewriting as details about txn ids for table " + fullyQualifiedTableName +
                " could not be found in " + materializationTxnWriteIds);
        ignore = true;
        break;
      }
      if (!TxnIdUtils.checkEquivalentWriteIds(tableCurrentWriteIds, tableWriteIds)) {
        LOG.debug("Materialized view " + materializedViewTable.getFullyQualifiedName() +
                " contents are outdated");
        return true;
      }
    }
    if (ignore) {
      return null;
    }

    return false;
  }
Utility method that returns whether a materialized view is outdated (true), not outdated
(false), or it cannot be determined (null). The latest case may happen e.g. when the
materialized view definition uses external tables.
ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/views/HiveMaterializedViewUtils.java