public static TableDesc getTableDesc(
      Class<? extends Deserializer> serdeClass, String separatorCode,
      String columns, String columnTypes, List<FieldSchema> partCols, boolean lastColumnTakesRestOfTheLine,
      String fileFormat) {

    Properties properties = Utilities.makeProperties(
        serdeConstants.SERIALIZATION_FORMAT, separatorCode, serdeConstants.LIST_COLUMNS,
        columns);

    if (!separatorCode.equals(Integer.toString(Utilities.ctrlaCode))) {
      properties.setProperty(
          serdeConstants.FIELD_DELIM, separatorCode);
    }
    if (columnTypes != null) {
      properties.setProperty(
          serdeConstants.LIST_COLUMN_TYPES, columnTypes);
    }
    if (CollectionUtils.isNotEmpty(partCols)) {
      properties.setProperty(
          serdeConstants.LIST_PARTITION_COLUMNS,
          MetaStoreUtils.getColumnNamesFromFieldSchema(partCols));
      properties.setProperty(
          serdeConstants.LIST_PARTITION_COLUMN_TYPES,
          MetaStoreUtils.getColumnTypesFromFieldSchema(partCols, ":"));
      properties.setProperty(
          serdeConstants.LIST_PARTITION_COLUMN_COMMENTS,
          MetaStoreUtils.getColumnCommentsFromFieldSchema(partCols));
    }
    if (lastColumnTakesRestOfTheLine) {
      properties.setProperty(
          serdeConstants.SERIALIZATION_LAST_COLUMN_TAKES_REST, "true");
    }

    Class inputFormat, outputFormat;
    // get the input & output file formats
    if ("HiveSequenceFile".equalsIgnoreCase(fileFormat)) {
      inputFormat = HiveSequenceFileInputFormat.class;
      outputFormat = SequenceFileOutputFormat.class;
    } else if ("SequenceFile".equalsIgnoreCase(fileFormat)) {
      inputFormat = SequenceFileInputFormat.class;
      outputFormat = SequenceFileOutputFormat.class;
    } else if ("RCFile".equalsIgnoreCase(fileFormat)) {
      inputFormat = RCFileInputFormat.class;
      outputFormat = RCFileOutputFormat.class;
      assert serdeClass == ColumnarSerDe.class;
    } else if (LLAP_OUTPUT_FORMAT_KEY.equalsIgnoreCase(fileFormat)) {
      inputFormat = TextInputFormat.class;
      outputFormat = LlapOutputFormat.class;
      properties.setProperty(
          hive_metastoreConstants.META_TABLE_STORAGE, LLAP_OF_SH_CLASS);
    } else { // use TextFile by default
      inputFormat = TextInputFormat.class;
      outputFormat = IgnoreKeyTextOutputFormat.class;
    }
    properties.setProperty(serdeConstants.SERIALIZATION_LIB, serdeClass.getName());
    properties.setProperty(hive_metastoreConstants.TABLE_BUCKETING_VERSION, "-1");
    return new TableDesc(inputFormat, outputFormat, properties);
  }
Generate the table descriptor of MetadataTypedColumnsetSerDe with the
separatorCode and column names (comma separated string), and whether the
last column should take the rest of the line.
ql/src/java/org/apache/hadoop/hive/ql/plan/PlanUtils.java