diff --git a/common/src/java/org/apache/hadoop/hive/conf/HiveConf.java b/common/src/java/org/apache/hadoop/hive/conf/HiveConf.java index c5a8ff3..1af68a6 100644 --- a/common/src/java/org/apache/hadoop/hive/conf/HiveConf.java +++ b/common/src/java/org/apache/hadoop/hive/conf/HiveConf.java @@ -758,7 +758,7 @@ HIVE_SERVER2_PLAIN_LDAP_DOMAIN("hive.server2.authentication.ldap.Domain", null), HIVE_SERVER2_CUSTOM_AUTHENTICATION_CLASS("hive.server2.custom.authentication.class", null), HIVE_SERVER2_ENABLE_DOAS("hive.server2.enable.doAs", true), - HIVE_SERVER2_TABLE_TYPE_MAPPING("hive.server2.table.type.mapping", "HIVE"), + HIVE_SERVER2_TABLE_TYPE_MAPPING("hive.server2.table.type.mapping", "CLASSIC"), HIVE_SERVER2_SESSION_HOOK("hive.server2.session.hook", ""), HIVE_CONF_RESTRICTED_LIST("hive.conf.restricted.list", null), diff --git a/conf/hive-default.xml.template b/conf/hive-default.xml.template index 181011b..545026d 100644 --- a/conf/hive-default.xml.template +++ b/conf/hive-default.xml.template @@ -1955,7 +1955,7 @@ hive.server2.table.type.mapping - HIVE + CLASSIC This setting reflects how HiveServer will report the table types for JDBC and other client implementations that retrieves the available tables and supported table types diff --git a/jdbc/src/test/org/apache/hive/jdbc/TestJdbcDriver2.java b/jdbc/src/test/org/apache/hive/jdbc/TestJdbcDriver2.java index c658dbd..bb36337 100644 --- a/jdbc/src/test/org/apache/hive/jdbc/TestJdbcDriver2.java +++ b/jdbc/src/test/org/apache/hive/jdbc/TestJdbcDriver2.java @@ -789,7 +789,7 @@ public void testShowTables() throws SQLException { } public void testMetaDataGetTables() throws SQLException { - getTablesTest(TableType.MANAGED_TABLE.toString(), TableType.VIRTUAL_VIEW.toString()); + getTablesTest(ClassicTableTypes.TABLE.toString(), ClassicTableTypes.VIEW.toString()); } public void testMetaDataGetTablesHive() throws SQLException { @@ -807,6 +807,13 @@ public void testMetaDataGetTablesClassic() throws SQLException { getTablesTest(ClassicTableTypes.TABLE.toString(), ClassicTableTypes.VIEW.toString()); } + /** + * Test the type returned for pre-created table type table and view type + * table + * @param tableTypeName expected table type + * @param viewTypeName expected view type + * @throws SQLException + */ private void getTablesTest(String tableTypeName, String viewTypeName) throws SQLException { Map tests = new HashMap(); tests.put("test%jdbc%", new Object[]{"testhivejdbcdriver_table" @@ -887,10 +894,14 @@ public void testMetaDataGetSchemas() throws SQLException { rs.close(); } + //test default table types returned in + // Connection.getMetaData().getTableTypes() public void testMetaDataGetTableTypes() throws SQLException { - metaDataGetTableTypeTest(new HiveTableTypeMapping().getTableTypeNames()); + metaDataGetTableTypeTest(new ClassicTableTypeMapping().getTableTypeNames()); } + //test default table types returned in + // Connection.getMetaData().getTableTypes() when type config is set to "HIVE" public void testMetaDataGetHiveTableTypes() throws SQLException { Statement stmt = con.createStatement(); stmt.execute("set " + HiveConf.ConfVars.HIVE_SERVER2_TABLE_TYPE_MAPPING.varname + @@ -899,6 +910,8 @@ public void testMetaDataGetHiveTableTypes() throws SQLException { metaDataGetTableTypeTest(new HiveTableTypeMapping().getTableTypeNames()); } + //test default table types returned in + // Connection.getMetaData().getTableTypes() when type config is set to "CLASSIC" public void testMetaDataGetClassicTableTypes() throws SQLException { Statement stmt = con.createStatement(); stmt.execute("set " + HiveConf.ConfVars.HIVE_SERVER2_TABLE_TYPE_MAPPING.varname + @@ -907,6 +920,12 @@ public void testMetaDataGetClassicTableTypes() throws SQLException { metaDataGetTableTypeTest(new ClassicTableTypeMapping().getTableTypeNames()); } + /** + * Test if Connection.getMetaData().getTableTypes() returns expected + * tabletypes + * @param tabletypes expected table types + * @throws SQLException + */ private void metaDataGetTableTypeTest(Set tabletypes) throws SQLException { ResultSet rs = (ResultSet)con.getMetaData().getTableTypes();