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

Switch to Plain 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 : " +
"foo")));
 }
}

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,
Tariq
cloudfront.blogspot.com
+
Haidar Hadi 2013-06-07, 14:59
+
Prasad Mujumdar 2013-06-07, 16:46
+
Mohammad Tariq 2013-06-07, 18:27