Review Board 1.7.22


HIVE-4549: JDBC compliance change TABLE_SCHEMA to TABLE_SCHEM

Review Request #11706 - Created June 7, 2013 and updated

Prasad Mujumdar
trunk
HIVE-4549
Reviewers
hive
hive-git
JDBC compliance change TABLE_SCHEMA to TABLE_SCHEM for getTables() and getSchemas().

The GetTablesOperation at this point generates a resultset that alings with ODBC SQLTables() and missing columns TYPE_CAT, TYPE_SCHEM, TYPE_NAME, SELF_REFERENCING_COL_NAME and REF_GENERATION per JDBC spec. On the other hand GetColumnsOperation matches JDBC but adds some extra columns for ODBC. I will log a separate ticket to handle the metadata request differences between JDBC and ODBC. 

Updated testcases in TestJdbcDriver2
jdbc/src/test/org/apache/hive/jdbc/TestJdbcDriver2.java
Revision 35c8e8f New Change
[20] 634 lines
[+20] [+] public void testMetaDataGetTables() throws SQLException {
635
            , "testhivejdbcdriverview"});
635
            , "testhivejdbcdriverview"});
636
    tests.put("", new Object[]{});
636
    tests.put("", new Object[]{});
637

    
   
637

   
638
    for (String checkPattern: tests.keySet()) {
638
    for (String checkPattern: tests.keySet()) {
639
      ResultSet rs = (ResultSet)con.getMetaData().getTables("default", null, checkPattern, null);
639
      ResultSet rs = (ResultSet)con.getMetaData().getTables("default", null, checkPattern, null);

    
   
640
      ResultSetMetaData resMeta = rs.getMetaData();

    
   
641
      assertEquals(5, resMeta.getColumnCount());

    
   
642
      assertEquals("TABLE_CAT", resMeta.getColumnName(1));

    
   
643
      assertEquals("TABLE_SCHEM", resMeta.getColumnName(2));

    
   
644
      assertEquals("TABLE_NAME", resMeta.getColumnName(3));

    
   
645
      assertEquals("TABLE_TYPE", resMeta.getColumnName(4));

    
   
646
      assertEquals("REMARKS", resMeta.getColumnName(5));

    
   
647

   
640
      int cnt = 0;
648
      int cnt = 0;
641
      while (rs.next()) {
649
      while (rs.next()) {
642
        String resultTableName = rs.getString("TABLE_NAME");
650
        String resultTableName = rs.getString("TABLE_NAME");
643
        assertEquals("Get by index different from get by name.", rs.getString(3), resultTableName);
651
        assertEquals("Get by index different from get by name.", rs.getString(3), resultTableName);
644
        assertEquals("Excpected a different table.", tests.get(checkPattern)[cnt], resultTableName);
652
        assertEquals("Excpected a different table.", tests.get(checkPattern)[cnt], resultTableName);
[+20] [20] 31 lines
[+20] [+] public void testMetaDataGetCatalogs() throws SQLException {
676

    
   
684

   
677
  public void testMetaDataGetSchemas() throws SQLException {
685
  public void testMetaDataGetSchemas() throws SQLException {
678
    ResultSet rs = (ResultSet)con.getMetaData().getSchemas();
686
    ResultSet rs = (ResultSet)con.getMetaData().getSchemas();
679
    ResultSetMetaData resMeta = rs.getMetaData();
687
    ResultSetMetaData resMeta = rs.getMetaData();
680
    assertEquals(2, resMeta.getColumnCount());
688
    assertEquals(2, resMeta.getColumnCount());
681
    assertEquals("TABLE_SCHEMA", resMeta.getColumnName(1));
689
    assertEquals("TABLE_SCHEM", resMeta.getColumnName(1));
682
    assertEquals("TABLE_CATALOG", resMeta.getColumnName(2));
690
    assertEquals("TABLE_CATALOG", resMeta.getColumnName(2));
683

    
   
691

   
684
    assertTrue(rs.next());
692
    assertTrue(rs.next());
685
    assertEquals("default", rs.getString(1));
693
    assertEquals("default", rs.getString(1));
686
//    assertNull(rs.getString(2));
694
//    assertNull(rs.getString(2));
[+20] [20] 592 lines
service/src/java/org/apache/hive/service/cli/operation/GetSchemasOperation.java
Revision 6970f35 New Change
 
service/src/java/org/apache/hive/service/cli/operation/GetTablesOperation.java
Revision df8b5b3 New Change
 
  1. jdbc/src/test/org/apache/hive/jdbc/TestJdbcDriver2.java: Loading...
  2. service/src/java/org/apache/hive/service/cli/operation/GetSchemasOperation.java: Loading...
  3. service/src/java/org/apache/hive/service/cli/operation/GetTablesOperation.java: Loading...