hive-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From c..@apache.org
Subject svn commit: r1159423 - in /hive/trunk/jdbc/src: java/org/apache/hadoop/hive/jdbc/HiveDatabaseMetaData.java test/org/apache/hadoop/hive/jdbc/TestJdbcDriver.java
Date Thu, 18 Aug 2011 21:39:10 GMT
Author: cws
Date: Thu Aug 18 21:39:10 2011
New Revision: 1159423

URL: http://svn.apache.org/viewvc?rev=1159423&view=rev
Log:
HIVE-2315. DatabaseMetadata.getColumns() does not return partition column names for a table
(Patrick Hunt via cws)

Modified:
    hive/trunk/jdbc/src/java/org/apache/hadoop/hive/jdbc/HiveDatabaseMetaData.java
    hive/trunk/jdbc/src/test/org/apache/hadoop/hive/jdbc/TestJdbcDriver.java

Modified: hive/trunk/jdbc/src/java/org/apache/hadoop/hive/jdbc/HiveDatabaseMetaData.java
URL: http://svn.apache.org/viewvc/hive/trunk/jdbc/src/java/org/apache/hadoop/hive/jdbc/HiveDatabaseMetaData.java?rev=1159423&r1=1159422&r2=1159423&view=diff
==============================================================================
--- hive/trunk/jdbc/src/java/org/apache/hadoop/hive/jdbc/HiveDatabaseMetaData.java (original)
+++ hive/trunk/jdbc/src/java/org/apache/hadoop/hive/jdbc/HiveDatabaseMetaData.java Thu Aug
18 21:39:10 2011
@@ -195,7 +195,7 @@ public class HiveDatabaseMetaData implem
       List<String> tables = client.get_tables(catalog, "*");
       for (String table: tables) {
         if (table.matches(regtableNamePattern)) {
-          List<FieldSchema> fields = client.get_fields(catalog, table);
+          List<FieldSchema> fields = client.get_schema(catalog, table);
           int ordinalPos = 1;
           for (FieldSchema field: fields) {
             if (field.getName().matches(regcolumnNamePattern)) {

Modified: hive/trunk/jdbc/src/test/org/apache/hadoop/hive/jdbc/TestJdbcDriver.java
URL: http://svn.apache.org/viewvc/hive/trunk/jdbc/src/test/org/apache/hadoop/hive/jdbc/TestJdbcDriver.java?rev=1159423&r1=1159422&r2=1159423&view=diff
==============================================================================
--- hive/trunk/jdbc/src/test/org/apache/hadoop/hive/jdbc/TestJdbcDriver.java (original)
+++ hive/trunk/jdbc/src/test/org/apache/hadoop/hive/jdbc/TestJdbcDriver.java Thu Aug 18 21:39:10
2011
@@ -50,6 +50,8 @@ public class TestJdbcDriver extends Test
   private static final String viewName = "testHiveJdbcDriverView";
   private static final String viewComment = "Simple view";
   private static final String partitionedTableName = "testHiveJdbcDriverPartitionedTable";
+  private static final String partitionedColumnName = "partcolabc";
+  private static final String partitionedColumnValue = "20090619";
   private static final String partitionedTableComment = "Partitioned table";
   private static final String dataTypeTableName = "testDataTypeTable";
   private static final String dataTypeTableComment = "Table with many column data types";
@@ -117,13 +119,14 @@ public class TestJdbcDriver extends Test
 
     res = stmt.executeQuery("create table " + partitionedTableName
         + " (under_col int, value string) comment '"+partitionedTableComment
-            +"' partitioned by (dt STRING)");
+            +"' partitioned by (" + partitionedColumnName + " STRING)");
     assertFalse(res.next());
 
     // load data
     res = stmt.executeQuery("load data local inpath '"
         + dataFilePath.toString() + "' into table " + partitionedTableName
-        + " PARTITION (dt='20090619')");
+        + " PARTITION (" + partitionedColumnName + "="
+        + partitionedColumnValue + ")");
     assertFalse(res.next());
 
     // drop table. ignore error.
@@ -383,6 +386,8 @@ public class TestJdbcDriver extends Test
   }
 
   private void doTestSelectAll(String tableName, int maxRows, int fetchSize) throws Exception
{
+    boolean isPartitionTable = tableName.equals(partitionedTableName);
+
     Statement stmt = con.createStatement();
     if (maxRows >= 0) {
       stmt.setMaxRows(maxRows);
@@ -411,10 +416,7 @@ public class TestJdbcDriver extends Test
     int i = 0;
 
     ResultSetMetaData meta = res.getMetaData();
-    int expectedColCount = 2;
-    if (tableName.equals(partitionedTableName)) {
-      ++expectedColCount;
-    }
+    int expectedColCount = isPartitionTable ? 3 : 2;
     assertEquals(
       "Unexpected column count", expectedColCount, meta.getColumnCount());
 
@@ -425,6 +427,10 @@ public class TestJdbcDriver extends Test
         assertEquals(res.getInt(1), res.getInt("under_col"));
         assertEquals(res.getString(1), res.getString("under_col"));
         assertEquals(res.getString(2), res.getString("value"));
+        if (isPartitionTable) {
+          assertEquals(res.getString(3), partitionedColumnValue);
+          assertEquals(res.getString(3), res.getString(partitionedColumnName));
+        }
         assertFalse("Last result value was not null", res.wasNull());
         assertNull("No warnings should be found on ResultSet", res
             .getWarnings());
@@ -630,7 +636,7 @@ public class TestJdbcDriver extends Test
   public void testMetaDataGetColumns() throws SQLException {
     Map<String[], Integer> tests = new HashMap<String[], Integer>();
     tests.put(new String[]{"testhivejdbcdriver\\_table", null}, 2);
-    tests.put(new String[]{"testhivejdbc%", null}, 6);
+    tests.put(new String[]{"testhivejdbc%", null}, 7);
     tests.put(new String[]{"%jdbcdriver\\_table", null}, 2);
     tests.put(new String[]{"%jdbcdriver\\_table%", "under\\_col"}, 1);
     tests.put(new String[]{"%jdbcdriver\\_table%", "under\\_co_"}, 1);



Mime
View raw message