@Override
  public int execute() throws HiveException {
    List<Table> tables = new ArrayList<Table>();
    Map<String, String> partitionSpec = desc.getPartSpec();
    Partition partition = null;
    if (partitionSpec != null) {
      Table table = context.getDb().getTable(desc.getDbName(), desc.getPattern());
      partition = context.getDb().getPartition(table, partitionSpec, false);
      if (partition == null) {
        throw new HiveException("Partition " + partitionSpec + " for table " + desc.getPattern() + " does not exist.");
      }
      tables.add(table);
    } else {
      LOG.debug("pattern: {}", desc.getPattern());
      List<String> tableNames = context.getDb().getTablesForDb(desc.getDbName(), null);
      if (desc.getPattern() != null) {
        Pattern pattern = Pattern.compile(UDFLike.likePatternToRegExp(desc.getPattern()), Pattern.CASE_INSENSITIVE);
        tableNames = tableNames.stream()
            .filter(name -> pattern.matcher(name).matches())
            .collect(Collectors.toList());
      }
      Collections.sort(tableNames);
      for (String tableName : tableNames) {
        Table table = context.getDb().getTable(desc.getDbName(), tableName);
        tables.add(table);
      }
      LOG.info("Found {} table(s) matching the SHOW TABLE EXTENDED statement.", tableNames.size());
    }

    DataOutputStream outStream = ShowUtils.getOutputStream(new Path(desc.getResFile()), context);
    try {
      ShowTableStatusFormatter formatter = ShowTableStatusFormatter.getFormatter(context.getConf());
      formatter.showTableStatus(outStream, context.getDb(), context.getConf(), tables, partition);
    } catch (Exception e) {
      throw new HiveException(e, ErrorMsg.GENERIC_ERROR, "show table status");
    } finally {
      IOUtils.closeStream(outStream);
    }
    return 0;
  }
Operation process showing the table status.
ql/src/java/org/apache/hadoop/hive/ql/ddl/table/info/show/status/ShowTableStatusOperation.java