@Override
  public void analyzeInternal(ASTNode root) throws SemanticException {
    if (root.getChildCount() > 3) {
      throw new SemanticException(ErrorMsg.GENERIC_ERROR.getMsg());
    }

    ctx.setResFile(ctx.getLocalTmpPath());

    String dbName = SessionState.get().getCurrentDatabase();
    String viewNames = null;
    switch (root.getChildCount()) {
    case 1: // Uses a pattern
      viewNames = unescapeSQLString(root.getChild(0).getText());
      break;
    case 2: // Specifies a DB
      assert (root.getChild(0).getType() == HiveParser.TOK_FROM);
      dbName = unescapeIdentifier(root.getChild(1).getText());
      db.validateDatabaseExists(dbName);
      break;
    case 3: // Uses a pattern and specifies a DB
      assert (root.getChild(0).getType() == HiveParser.TOK_FROM);
      dbName = unescapeIdentifier(root.getChild(1).getText());
      viewNames = unescapeSQLString(root.getChild(2).getText());
      db.validateDatabaseExists(dbName);
      break;
    default: // No pattern or DB
      break;
    }

    ShowMaterializedViewsDesc desc = new ShowMaterializedViewsDesc(ctx.getResFile(), dbName, viewNames);
    Task<DDLWork> task = TaskFactory.get(new DDLWork(getInputs(), getOutputs(), desc));
    rootTasks.add(task);

    task.setFetchSource(true);
    setFetchTask(createFetchTask(ShowMaterializedViewsDesc.SCHEMA));
  }
Analyzer for show materialized views commands.
ql/src/java/org/apache/hadoop/hive/ql/ddl/view/materialized/show/ShowMaterializedViewsAnalyzer.java