@Override
  public int execute() throws HiveException {
    // get the create table statement for the table and populate the output
    try (DataOutputStream outStream = ShowUtils.getOutputStream(new Path(desc.getResFile()), context)) {
      Table table = context.getDb().getTable(desc.getDatabaseName(), desc.getTableName());
      DDLPlanUtils ddlObj = new DDLPlanUtils();
      String command;
      if (table.isView()) {
        command = ddlObj.getCreateViewCommand(table, desc.isRelative());
      } else {
        List<String> commands = new ArrayList<>();
        commands.add(ddlObj.getCreateTableCommand(table, desc.isRelative()));
        String primaryKeyStmt = ddlObj.getAlterTableStmtPrimaryKeyConstraint(table.getPrimaryKeyInfo());
        if (primaryKeyStmt != null) {
          commands.add(primaryKeyStmt);
        }
        commands.addAll(ddlObj.populateConstraints(table));
        command = String.join("\n", commands);
      }
      outStream.write(command.getBytes(StandardCharsets.UTF_8));
      return 0;
    } catch (IOException e) {
      LOG.info("Show create table failed", e);
      return 1;
    } catch (Exception e) {
      throw new HiveException(e);
    }
  }
Operation process showing the creation of a table.
ql/src/java/org/apache/hadoop/hive/ql/ddl/table/create/show/ShowCreateTableOperation.java