@Test public void testGetTableSchemaWithPtnColsApi() throws IOException { StorageDescriptor sd = new StorageDescriptor( Lists.newArrayList(new FieldSchema("username", serdeConstants.STRING_TYPE_NAME, null)), "location", "org.apache.hadoop.mapred.TextInputFormat", "org.apache.hadoop.mapred.TextOutputFormat", false, -1, new SerDeInfo(), new ArrayList<String>(), new ArrayList<Order>(), new HashMap<String, String>()); org.apache.hadoop.hive.metastore.api.Table apiTable = new org.apache.hadoop.hive.metastore.api.Table("test_tblname", "test_dbname", "test_owner", 0, 0, 0, sd, new ArrayList<FieldSchema>(), new HashMap<String, String>(), "viewOriginalText", "viewExpandedText", TableType.EXTERNAL_TABLE.name()); Table table = new Table(apiTable); List<HCatFieldSchema> expectedHCatSchema = Lists.newArrayList(new HCatFieldSchema("username", HCatFieldSchema.Type.STRING, null)); Assert.assertEquals(new HCatSchema(expectedHCatSchema), HCatUtil.getTableSchemaWithPtnCols(table)); List<FieldSchema> partitionKeys = Lists.newArrayList(new FieldSchema("dt", serdeConstants.STRING_TYPE_NAME, null)); table.getTTable().setPartitionKeys(partitionKeys); expectedHCatSchema.add(new HCatFieldSchema("dt", HCatFieldSchema.Type.STRING, null)); Assert.assertEquals(new HCatSchema(expectedHCatSchema), HCatUtil.getTableSchemaWithPtnCols(table)); }
public static HCatSchema getTableSchemaWithPtnCols(Table table) throws IOException { HCatSchema tableSchema = new HCatSchema(HCatUtil.getHCatFieldSchemaList(table.getCols())); if (table.getPartitionKeys().size() != 0) { for (FieldSchema fs : table.getPartitionKeys()) { tableSchema.append(HCatSchemaUtils.getHCatFieldSchema(fs)); } } return tableSchema; }
HCatUtil { public static HCatSchema getTableSchemaWithPtnCols(Table table) throws IOException { HCatSchema tableSchema = new HCatSchema(HCatUtil.getHCatFieldSchemaList(table.getCols())); if (table.getPartitionKeys().size() != 0) { for (FieldSchema fs : table.getPartitionKeys()) { tableSchema.append(HCatSchemaUtils.getHCatFieldSchema(fs)); } } return tableSchema; } }
HCatUtil { public static HCatSchema getTableSchemaWithPtnCols(Table table) throws IOException { HCatSchema tableSchema = new HCatSchema(HCatUtil.getHCatFieldSchemaList(table.getCols())); if (table.getPartitionKeys().size() != 0) { for (FieldSchema fs : table.getPartitionKeys()) { tableSchema.append(HCatSchemaUtils.getHCatFieldSchema(fs)); } } return tableSchema; }  }
HCatUtil { public static HCatSchema getTableSchemaWithPtnCols(Table table) throws IOException { HCatSchema tableSchema = new HCatSchema(HCatUtil.getHCatFieldSchemaList(table.getCols())); if (table.getPartitionKeys().size() != 0) { for (FieldSchema fs : table.getPartitionKeys()) { tableSchema.append(HCatSchemaUtils.getHCatFieldSchema(fs)); } } return tableSchema; }  static boolean checkJobContextIfRunningFromBackend(JobContext j); static String serialize(Serializable obj); static Object deserialize(String str); static String encodeBytes(byte[] bytes); static byte[] decodeBytes(String str); static List<HCatFieldSchema> getHCatFieldSchemaList(
    FieldSchema... fields); static List<HCatFieldSchema> getHCatFieldSchemaList(
    List<FieldSchema> fields); static HCatSchema extractSchema(Table table); static HCatSchema extractSchema(Partition partition); static List<FieldSchema> getFieldSchemaList(
    List<HCatFieldSchema> hcatFields); static Table getTable(HiveMetaStoreClient client, String dbName, String tableName); static HCatSchema getTableSchemaWithPtnCols(Table table); static HCatSchema getPartitionColumns(Table table); static List<FieldSchema> validatePartitionSchema(Table table,
                              HCatSchema partitionSchema); static boolean validateMorePermissive(FsAction first, FsAction second); static boolean validateExecuteBitPresentIfReadOrWrite(FsAction perms); static Token<org.apache.hadoop.mapreduce.security.token.delegation.DelegationTokenIdentifier> getJobTrackerDelegationToken(
    Configuration conf, String userName); static Token<? extends AbstractDelegationTokenIdentifier> extractThriftToken(
    String tokenStrForm, String tokenSignature); static HCatStorageHandler getStorageHandler(Configuration conf, StorerInfo storerInfo); static HCatStorageHandler getStorageHandler(Configuration conf, PartInfo partitionInfo); static HCatStorageHandler getStorageHandler(Configuration conf,
                             String storageHandler,
                             String serDe,
                             String inputFormat,
                             String outputFormat); static Pair<String, String> getDbAndTableName(String tableName); static Map<String, String> getInputJobProperties(HCatStorageHandler storageHandler,
              InputJobInfo inputJobInfo); @InterfaceAudience.Private @InterfaceStability.Evolving static void configureOutputStorageHandler(HCatStorageHandler storageHandler,
                  Configuration conf,
                  OutputJobInfo outputJobInfo); static void copyConf(Configuration src, Configuration dest); static HiveMetaStoreClient getHiveClient(HiveConf hiveConf); static void closeHiveClientQuietly(HiveMetaStoreClient client); static HiveConf getHiveConf(Configuration conf); static JobConf getJobConfFromContext(JobContext jobContext); static void copyJobPropertiesToJobConf(
    Map<String, String> jobProperties, JobConf jobConf); static boolean isHadoop23(); }
HCatUtil { public static HCatSchema getTableSchemaWithPtnCols(Table table) throws IOException { HCatSchema tableSchema = new HCatSchema(HCatUtil.getHCatFieldSchemaList(table.getCols())); if (table.getPartitionKeys().size() != 0) { for (FieldSchema fs : table.getPartitionKeys()) { tableSchema.append(HCatSchemaUtils.getHCatFieldSchema(fs)); } } return tableSchema; }  static boolean checkJobContextIfRunningFromBackend(JobContext j); static String serialize(Serializable obj); static Object deserialize(String str); static String encodeBytes(byte[] bytes); static byte[] decodeBytes(String str); static List<HCatFieldSchema> getHCatFieldSchemaList(
    FieldSchema... fields); static List<HCatFieldSchema> getHCatFieldSchemaList(
    List<FieldSchema> fields); static HCatSchema extractSchema(Table table); static HCatSchema extractSchema(Partition partition); static List<FieldSchema> getFieldSchemaList(
    List<HCatFieldSchema> hcatFields); static Table getTable(HiveMetaStoreClient client, String dbName, String tableName); static HCatSchema getTableSchemaWithPtnCols(Table table); static HCatSchema getPartitionColumns(Table table); static List<FieldSchema> validatePartitionSchema(Table table,
                              HCatSchema partitionSchema); static boolean validateMorePermissive(FsAction first, FsAction second); static boolean validateExecuteBitPresentIfReadOrWrite(FsAction perms); static Token<org.apache.hadoop.mapreduce.security.token.delegation.DelegationTokenIdentifier> getJobTrackerDelegationToken(
    Configuration conf, String userName); static Token<? extends AbstractDelegationTokenIdentifier> extractThriftToken(
    String tokenStrForm, String tokenSignature); static HCatStorageHandler getStorageHandler(Configuration conf, StorerInfo storerInfo); static HCatStorageHandler getStorageHandler(Configuration conf, PartInfo partitionInfo); static HCatStorageHandler getStorageHandler(Configuration conf,
                             String storageHandler,
                             String serDe,
                             String inputFormat,
                             String outputFormat); static Pair<String, String> getDbAndTableName(String tableName); static Map<String, String> getInputJobProperties(HCatStorageHandler storageHandler,
              InputJobInfo inputJobInfo); @InterfaceAudience.Private @InterfaceStability.Evolving static void configureOutputStorageHandler(HCatStorageHandler storageHandler,
                  Configuration conf,
                  OutputJobInfo outputJobInfo); static void copyConf(Configuration src, Configuration dest); static HiveMetaStoreClient getHiveClient(HiveConf hiveConf); static void closeHiveClientQuietly(HiveMetaStoreClient client); static HiveConf getHiveConf(Configuration conf); static JobConf getJobConfFromContext(JobContext jobContext); static void copyJobPropertiesToJobConf(
    Map<String, String> jobProperties, JobConf jobConf); static boolean isHadoop23();  }