public static Table createPartitionedTable(Configuration conf,HiveMetastoreClient ms,HiveObjectSpec tableSpec,TableType tableType,Path warehouseRoot) throws IOException, HiveMetastoreException {
  Path tableLocation=getPathForHiveObject(warehouseRoot,tableSpec);
  Table table=new Table();
  table.setDbName(tableSpec.getDbName());
  table.setTableName(tableSpec.getTableName());
  Map<String,String> parameters=new HashMap<>();
  parameters.put(HiveParameterKeys.TLDT,Long.toString(System.currentTimeMillis()));
  table.setParameters(parameters);
  table.setTableType(tableType.toString());
  List<FieldSchema> partitionCols=new ArrayList<>();
  partitionCols.add(new FieldSchema("ds","string","my ds comment"));
  partitionCols.add(new FieldSchema("hr","string","my hr comment"));
  table.setPartitionKeys(partitionCols);
  StorageDescriptor sd=new StorageDescriptor();
  List<FieldSchema> columns=new ArrayList<>();
  columns.add(new FieldSchema("key","string","my comment"));
  sd.setCols(columns);
  if (tableType == TableType.MANAGED_TABLE || tableType == TableType.EXTERNAL_TABLE) {
    sd.setLocation(tableLocation.toString());
  }
  sd.setSerdeInfo(new SerDeInfo("LazySimpleSerde","org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe",new HashMap<>()));
  table.setSd(sd);
  if (!ms.existsDb(table.getDbName())) {
    ms.createDatabase(new Database(table.getDbName(),null,null,null));
  }
  ms.createTable(table);
  return table;
}

public static Table createPartitionedTable ( Configuration conf , HiveMetastoreClient ms , HiveObjectSpec tableSpec , TableType tableType , Path warehouseRoot ) throws IOException , HiveMetastoreException { Path tableLocation = getPathForHiveObject ( warehouseRoot , tableSpec ) ; Table table = new Table ( ) ; table . setDbName ( tableSpec . getDbName ( ) ) ; table . setTableName ( tableSpec . getTableName ( ) ) ; Map < String , String > parameters = new HashMap < > ( ) ; parameters . put ( HiveParameterKeys . TLDT , Long . toString ( System . currentTimeMillis ( ) ) ) ; table . setParameters ( parameters ) ; table . setTableType ( tableType . toString ( ) ) ; List < FieldSchema > partitionCols = new ArrayList < > ( ) ; partitionCols . add ( new FieldSchema ( "ds" , "string" , "my ds comment" ) ) ; partitionCols . add ( new FieldSchema ( "hr" , "string" , "my hr comment" ) ) ; table . setPartitionKeys ( partitionCols ) ; StorageDescriptor sd = new StorageDescriptor ( ) ; List < FieldSchema > columns = new ArrayList < > ( ) ; columns . add ( new FieldSchema ( "key" , "string" , "my comment" ) ) ; sd . setCols ( columns ) ; if ( tableType == TableType . MANAGED_TABLE || tableType == TableType . EXTERNAL_TABLE ) { sd . setLocation ( tableLocation . toString ( ) ) ; } sd . setSerdeInfo ( new SerDeInfo ( "LazySimpleSerde" , "org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe" , new HashMap < > ( ) ) ) ; table . setSd ( sd ) ; if ( ! ms . existsDb ( table . getDbName ( ) ) ) { ms . createDatabase ( new Database ( table . getDbName ( ) , null , null , null ) ) ; } ms . createTable ( table ) ; return table ; }
creates a table that is partitioned on ds and hr .
