Home | About | Sematext search-lucene.com search-hadoop.com
 Search Hadoop and all its subprojects:

Switch to Threaded View
Hive >> mail # user >> Correct way to use Hive Java API

Copy link to this message
Correct way to use Hive Java API
Hello list,

     I am trying to access data stored in my Hive table through the Java
API but looks like I am not using it in the correct manner. Would really
appreciate some help. Here is the small piece of code I am trying to use :

public static void main(String[] args) throws HiveMetaException {
// TODO Auto-generated method stub

Table table = new Table("default", "pokes");
 System.out.println("DBNAME : " + table.getDbName());
List<FieldSchema> cols = new ArrayList<FieldSchema>();
 cols = table.getCols();
System.out.println("SIZE : " + cols.size());
 for(FieldSchema fs : cols) {
System.out.println(fs.getFieldValue(_Fields.findByName("foo VALUE : " +

The problem here is that *table.getCols() *is not returning anything. I
tried to print the size of the list, but it's zero. Looks like i'm missing
out something obvious or the approach itself is wrong. Need some help.
Pardon my ignorance.

Thank you so much for your valuable time.

Warm Regards,