示例#1
0
 @Test
 public void testQueryForInt() throws Exception {
   String tableName = "testHiveDriverTable";
   hiveTemplate.query("create table if not exists " + tableName + " (key int, value string)");
   System.out.println(hiveTemplate.query("show tables"));
   assertEquals(
       Integer.valueOf(0), hiveTemplate.queryForInt("select count(1) as cnt from " + tableName));
 }
示例#2
0
 @Test
 public void testQueryForLong() throws Exception {
   String tableName = "testHiveDriverTable";
   assertEquals(
       Long.valueOf(0),
       hiveTemplate.queryForLong("select count(1) as cnt from " + tableName + ";"));
 }
示例#3
0
 @Test
 public void testHiveTemplate() throws Exception {
   System.out.println(
       hiveTemplate.execute(
           new HiveClientCallback<Object>() {
             @Override
             public Object doInHive(HiveClient hiveClient) throws Exception {
               return hiveClient.get_all_databases();
             }
           }));
 }