Home | About | Sematext search-lucene.com search-hadoop.com
NEW: Monitor These Apps!
elasticsearch, apache solr, apache hbase, hadoop, redis, casssandra, amazon cloudwatch, mysql, memcached, apache kafka, apache zookeeper, apache storm, ubuntu, centOS, red hat, debian, puppet labs, java, senseiDB
 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.

Ashish

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

Folks,

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?

thanks,
Michal
NEW: Monitor These Apps!
elasticsearch, apache solr, apache hbase, hadoop, redis, casssandra, amazon cloudwatch, mysql, memcached, apache kafka, apache zookeeper, apache storm, ubuntu, centOS, red hat, debian, puppet labs, java, senseiDB