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

Switch to Threaded View
Hive >> mail # user >> Complex Type and JDBC

Copy link to this message
RE: Complex Type and JDBC
JDBC itself does not support complex types. If I remember correctly (Raghu can confirm), the complex type should get serialzed as a json string when you run the query. You can then do a res.getString(2) to get that column and then use some json libraries in java to deserialize this and get back a java map.


From: michal shmueli [mailto:[EMAIL PROTECTED]]
Sent: Thursday, August 20, 2009 3:01 AM
Subject: Complex Type and JDBC


I have a table with this schema: (int key, values MAP<String, String>). I want to fetch the data from the table into local Map in my java code.
Following the hive JDBC example, I did :
String selectSql = "select * from " + tableName;
ResultSet res = stmt.executeQuery(selectSql);

To get the first attribute (the key ) i did: String user = res.getString(1);
Now I wish to get the data of values (the Map) into the local map, but I don't know how to access the ResultSet such that it will keep the Map so i don't have to parse the content. Is there such an option at all? if not, does it mean that I can only keep the complex type within Hive and can't utilize it to other parts?