private void validateCreateView()
      throws SemanticException {
    try {
      // Do not allow view to be defined on temp table or other materialized view
      validateTablesUsed(this);
      if (createVwDesc.isRewriteEnabled()) {
        int nativeAcidCount = 0;
        int supportsSnapshotCount = 0;
        for (TableScanOperator ts : topOps.values()) {
          Table table = ts.getConf().getTableMetadata();
          if (SemanticAnalyzer.DUMMY_TABLE.equals(table.getTableName())) {
            continue;
          }
          if (AcidUtils.isTransactionalTable(table)) {
            ++nativeAcidCount;
          } else if (table.isNonNative() && table.getStorageHandler().areSnapshotsSupported()) {
            ++supportsSnapshotCount;
          } else {
            throw new SemanticException("Automatic rewriting for materialized view cannot "
                    + "be enabled if the materialized view uses non-transactional tables");
          }
          if (isNotBlank(ts.getConf().getAsOfTimestamp()) || isNotBlank(ts.getConf().getAsOfVersion())) {
            throw new SemanticException("Automatic rewriting for materialized view cannot "
                    + "be enabled if the materialized view uses time travel query.");
          }
        }
        if (nativeAcidCount > 0 && supportsSnapshotCount > 0) {
          throw new SemanticException("All materialized view source tables either must be native ACID tables or " +
                  "must support table snapshots.");
        }
      }

      if (!qb.hasTableDefined()) {
        throw new SemanticException("Materialized view must have a table defined.");
      }

      if (createVwDesc.isRewriteEnabled()) {
        if (!ctx.isCboSucceeded()) {
          String msg = "Cannot enable automatic rewriting for materialized view.";
          if (ctx.getCboInfo() != null) {
            msg += " " + ctx.getCboInfo();
          } else {
            msg += " Check CBO is turned on: set " + ConfVars.HIVE_CBO_ENABLED.varname;
          }
          throw new SemanticException(msg);
        }
        if (materializationValidationResult.getSupportedRewriteAlgorithms().isEmpty()) {
          createVwDesc.setRewriteEnabled(false);
        }
        String errorMessage = materializationValidationResult.getErrorMessage();
        if (isNotBlank(errorMessage)) {
          console.printError(errorMessage);
        }
      }
    } catch (HiveException e) {
      throw new SemanticException(e.getMessage(), e);
    }
  }
Adds entities for create table/create view.
ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java