diff --git a/itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestJdbcDriver2.java b/itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestJdbcDriver2.java index 4090e72..4ce170b 100644 --- a/itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestJdbcDriver2.java +++ b/itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestJdbcDriver2.java @@ -69,7 +69,7 @@ */ public class TestJdbcDriver2 { private static final String driverName = "org.apache.hive.jdbc.HiveDriver"; - private static final String tableName = "testHiveJdbcDriver_Table"; + private static final String tableName = "testHiveJdbcDriverTable"; private static final String tableComment = "Simple table"; private static final String viewName = "testHiveJdbcDriverView"; private static final String viewComment = "Simple view"; @@ -97,29 +97,8 @@ public TestJdbcDriver2() { } @BeforeClass - public static void setUpBeforeClass() throws SQLException, ClassNotFoundException{ + public static void setUpBeforeClass() throws SQLException, ClassNotFoundException { Class.forName(driverName); - Connection con1 = getConnection(); - - Statement stmt1 = con1.createStatement(); - assertNotNull("Statement is null", stmt1); - - stmt1.execute("set hive.support.concurrency = false"); - - DatabaseMetaData metadata = con1.getMetaData(); - - // Drop databases created by other test cases - ResultSet databaseRes = metadata.getSchemas(); - - while(databaseRes.next()){ - String db = databaseRes.getString(1); - if(!db.equals("default")){ - System.err.println("Dropping database " + db); - stmt1.execute("DROP DATABASE " + db + " CASCADE"); - } - } - stmt1.close(); - con1.close(); } @Before @@ -131,14 +110,14 @@ public void setUp() throws Exception { stmt.execute("set hive.support.concurrency = false"); - // drop table. ignore error. + // drop simple table, ignore error. try { stmt.execute("drop table " + tableName); } catch (Exception ex) { fail(ex.toString()); } - // create table + // create a simple table stmt.execute("create table " + tableName + " (under_col int comment 'the under column', value string) comment '" + tableComment + "'"); @@ -148,31 +127,29 @@ public void setUp() throws Exception { + dataFilePath.toString() + "' into table " + tableName); // also initialize a paritioned table to test against. - - // drop table. ignore error. + // drop paritioned table. ignore error. try { stmt.execute("drop table " + partitionedTableName); } catch (Exception ex) { fail(ex.toString()); } - + // create paritioned table stmt.execute("create table " + partitionedTableName + " (under_col int, value string) comment '"+partitionedTableComment +"' partitioned by (" + partitionedColumnName + " STRING)"); - // load data stmt.execute("load data local inpath '" + dataFilePath.toString() + "' into table " + partitionedTableName + " PARTITION (" + partitionedColumnName + "=" + partitionedColumnValue + ")"); - // drop table. ignore error. + // drop data type table. ignore error. try { stmt.execute("drop table " + dataTypeTableName); } catch (Exception ex) { fail(ex.toString()); } - + // create data type table stmt.execute("create table " + dataTypeTableName + " (c1 int, c2 boolean, c3 double, c4 string," + " c5 array, c6 map, c7 map," @@ -190,7 +167,7 @@ public void setUp() throws Exception { + " c22 char(15)" + ") comment'" + dataTypeTableComment +"' partitioned by (dt STRING)"); - + // load data stmt.execute("load data local inpath '" + dataTypeDataFilePath.toString() + "' into table " + dataTypeTableName + " PARTITION (dt='20090619')"); @@ -201,7 +178,6 @@ public void setUp() throws Exception { } catch (Exception ex) { fail(ex.toString()); } - // create view stmt.execute("create view " + viewName + " comment '"+viewComment +"' as select * from "+ tableName); @@ -224,7 +200,7 @@ private static Connection getConnection() throws SQLException { @After public void tearDown() throws Exception { - // drop table + // drop all test tables Statement stmt = con.createStatement(); assertNotNull("Statement is null", stmt); stmt.execute("drop table " + tableName);