javaapihadoophivemetastore

Get Table Properties out of Hive using Java API


I'm trying to get table properties like table db, name, owner, and hdfs location out of the hive metastore using the metastore client in java. I think I can get the table databases and names okay, but I can't figure out how to grab things like owner and hdfs location. Is it possible? I've been searching the doc and internet for a couple hours now and no dice.


Solution

  • Could be something like that:

    org.apache.hadoop.hive.metastore.api.Table table=..........;
    org.apache.hadoop.hive.metastore.api.StorageDescriptor sd=table.getSd();
    String loc=sd.getLocation();
    String own=sd.getOwner();
    

    https://hive.apache.org/javadocs/r1.2.2/api/org/apache/hadoop/hive/metastore/api/Table.html https://hive.apache.org/javadocs/r1.2.2/api/org/apache/hadoop/hive/metastore/api/StorageDescriptor.html