You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by br...@apache.org on 2013/10/04 23:30:46 UTC

svn commit: r1529308 [3/10] - in /hive/branches/maven: ./ ant/src/org/apache/hadoop/hive/ant/ beeline/src/java/org/apache/hive/beeline/ beeline/src/test/org/apache/hive/beeline/src/test/ bin/ common/ common/src/java/org/apache/hadoop/hive/conf/ common/...

Modified: hive/branches/maven/jdbc/src/test/org/apache/hive/jdbc/TestJdbcDriver2.java
URL: http://svn.apache.org/viewvc/hive/branches/maven/jdbc/src/test/org/apache/hive/jdbc/TestJdbcDriver2.java?rev=1529308&r1=1529307&r2=1529308&view=diff
==============================================================================
--- hive/branches/maven/jdbc/src/test/org/apache/hive/jdbc/TestJdbcDriver2.java (original)
+++ hive/branches/maven/jdbc/src/test/org/apache/hive/jdbc/TestJdbcDriver2.java Fri Oct  4 21:30:38 2013
@@ -20,6 +20,12 @@ package org.apache.hive.jdbc;
 
 import static org.apache.hadoop.hive.ql.exec.ExplainTask.EXPL_COLUMN_NAME;
 import static org.apache.hadoop.hive.ql.processors.SetProcessor.SET_COLUMN_NAME;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
 
 import java.sql.Connection;
 import java.sql.DatabaseMetaData;
@@ -39,8 +45,6 @@ import java.util.Properties;
 import java.util.Set;
 import java.util.regex.Pattern;
 
-import junit.framework.TestCase;
-
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.hive.conf.HiveConf;
 import org.apache.hadoop.hive.metastore.TableType;
@@ -50,13 +54,17 @@ import org.apache.hive.service.cli.opera
 import org.apache.hive.service.cli.operation.ClassicTableTypeMapping.ClassicTableTypes;
 import org.apache.hive.service.cli.operation.HiveTableTypeMapping;
 import org.apache.hive.service.cli.operation.TableTypeMappingFactory.TableTypeMappings;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
 
 
 /**
  * TestJdbcDriver2
  *
  */
-public class TestJdbcDriver2 extends TestCase {
+public class TestJdbcDriver2 {
   private static final String driverName = "org.apache.hive.jdbc.HiveDriver";
   private static final String tableName = "testHiveJdbcDriver_Table";
   private static final String tableComment = "Simple table";
@@ -72,10 +80,10 @@ public class TestJdbcDriver2 extends Tes
   private final Path dataFilePath;
   private final Path dataTypeDataFilePath;
   private Connection con;
-  private boolean standAloneServer = false;
+  private static boolean standAloneServer = false;
+  private static final float floatCompareDelta = 0.0001f;
 
-  public TestJdbcDriver2(String name) {
-    super(name);
+  public TestJdbcDriver2() {
     conf = new HiveConf(TestJdbcDriver2.class);
     String dataFileDir = conf.get("test.data.files").replace('\\', '/')
         .replace("c:", "");
@@ -85,19 +93,36 @@ public class TestJdbcDriver2 extends Tes
         .getProperty("test.service.standalone.server"));
   }
 
-  @Override
-  protected void setUp() throws Exception {
-    super.setUp();
+  @BeforeClass
+  public static void setUpBeforeClass() throws SQLException, ClassNotFoundException{
     Class.forName(driverName);
-    if (standAloneServer) {
-      // get connection
-      con = DriverManager.getConnection("jdbc:hive2://localhost:10000/default",
-          "", "");
-    } else {
-      con = DriverManager.getConnection("jdbc:hive2://", "", "");
+    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");
+      }
     }
-    assertNotNull("Connection is null", con);
-    assertFalse("Connection should not be closed", con.isClosed());
+    stmt1.close();
+    con1.close();
+  }
+
+  @Before
+  public void setUp() throws Exception {
+    con = getConnection();
+
     Statement stmt = con.createStatement();
     assertNotNull("Statement is null", stmt);
 
@@ -110,7 +135,6 @@ public class TestJdbcDriver2 extends Tes
       fail(ex.toString());
     }
 
-    ResultSet res;
     // create table
     stmt.execute("create table " + tableName
         + " (under_col int comment 'the under column', value string) comment '"
@@ -179,10 +203,23 @@ public class TestJdbcDriver2 extends Tes
         +"' as select * from "+ tableName);
   }
 
-  @Override
-  protected void tearDown() throws Exception {
-    super.tearDown();
+  private static Connection getConnection() throws SQLException {
+    Connection con1;
+    if (standAloneServer) {
+      // get connection
+      con1 = DriverManager.getConnection("jdbc:hive2://localhost:10000/default",
+          "", "");
+    } else {
+      con1 = DriverManager.getConnection("jdbc:hive2://", "", "");
+    }
+    assertNotNull("Connection is null", con1);
+    assertFalse("Connection should not be closed", con1.isClosed());
 
+    return con1;
+  }
+
+  @After
+  public void tearDown() throws Exception {
     // drop table
     Statement stmt = con.createStatement();
     assertNotNull("Statement is null", stmt);
@@ -205,6 +242,7 @@ public class TestJdbcDriver2 extends Tes
         expectedException);
   }
 
+  @Test
   public void testBadURL() throws Exception {
     checkBadUrl("jdbc:hive2://localhost:10000;principal=test");
     checkBadUrl("jdbc:hive2://localhost:10000;" +
@@ -223,6 +261,7 @@ public class TestJdbcDriver2 extends Tes
     }
   }
 
+  @Test
   public void testDataTypes2() throws Exception {
     Statement stmt = con.createStatement();
 
@@ -238,6 +277,8 @@ public class TestJdbcDriver2 extends Tes
     }
 
   }
+
+  @Test
   public void testErrorDiag() throws SQLException {
     Statement stmt = con.createStatement();
 
@@ -268,6 +309,7 @@ public class TestJdbcDriver2 extends Tes
    * verify 'explain ...' resultset
    * @throws SQLException
    */
+  @Test
   public void testExplainStmt() throws SQLException {
     Statement stmt = con.createStatement();
 
@@ -276,12 +318,15 @@ public class TestJdbcDriver2 extends Tes
             "c1*2, sentences(null, null, null) as b from " + dataTypeTableName + " limit 1");
 
     ResultSetMetaData md = res.getMetaData();
-    assertEquals(md.getColumnCount(), 1); // only one result column
-    assertEquals(md.getColumnLabel(1), EXPL_COLUMN_NAME); // verify the column name
+    // only one result column
+    assertEquals(md.getColumnCount(), 1);
+    // verify the column name
+    assertEquals(md.getColumnLabel(1), EXPL_COLUMN_NAME);
     //verify that there is data in the resultset
     assertTrue("Nothing returned explain", res.next());
   }
 
+  @Test
   public void testPrepareStatement() {
 
     String sql = "from (select count(1) from "
@@ -398,6 +443,7 @@ public class TestJdbcDriver2 extends Tes
    * of PreparedStatement interface
    * @throws Exception
    */
+  @Test
   public void testExecutePreparedStatement() throws Exception {
     String key = "testKey";
     String val1 = "val1";
@@ -433,11 +479,13 @@ public class TestJdbcDriver2 extends Tes
     assertEquals("Conf value should be set by execute()", expectedVal, result);
   }
 
+  @Test
   public final void testSelectAll() throws Exception {
     doTestSelectAll(tableName, -1, -1); // tests not setting maxRows (return all)
     doTestSelectAll(tableName, 0, -1); // tests setting maxRows to 0 (return all)
   }
 
+  @Test
   public final void testSelectAllPartioned() throws Exception {
     doTestSelectAll(partitionedTableName, -1, -1); // tests not setting maxRows
     // (return all)
@@ -445,14 +493,17 @@ public class TestJdbcDriver2 extends Tes
     // (return all)
   }
 
+  @Test
   public final void testSelectAllMaxRows() throws Exception {
     doTestSelectAll(tableName, 100, -1);
   }
 
+  @Test
   public final void testSelectAllFetchSize() throws Exception {
     doTestSelectAll(tableName, 100, 20);
   }
 
+  @Test
   public void testNullType() throws Exception {
     Statement stmt = con.createStatement();
     try {
@@ -466,6 +517,7 @@ public class TestJdbcDriver2 extends Tes
 
   // executeQuery should always throw a SQLException,
   // when it executes a non-ResultSet query (like create)
+  @Test
   public void testExecuteQueryException() throws Exception {
     Statement stmt = con.createStatement();
     try {
@@ -506,6 +558,7 @@ public class TestJdbcDriver2 extends Tes
     fail(e.toString());
   }
 
+  @Test
   public void testNullResultSet() throws Exception {
     List<String> setupQueries = new ArrayList<String>();
     String testQuery;
@@ -541,6 +594,7 @@ public class TestJdbcDriver2 extends Tes
     stmt.close();
   }
 
+  @Test
   public void testCloseResultSet() throws Exception {
     Statement stmt = con.createStatement();
 
@@ -574,6 +628,7 @@ public class TestJdbcDriver2 extends Tes
     assertTrue(stmt.isClosed());
   }
 
+  @Test
   public void testDataTypes() throws Exception {
     Statement stmt = con.createStatement();
 
@@ -590,7 +645,7 @@ public class TestJdbcDriver2 extends Tes
     // getXXX returns 0 for numeric types, false for boolean and null for other
     assertEquals(0, res.getInt(1));
     assertEquals(false, res.getBoolean(2));
-    assertEquals(0d, res.getDouble(3));
+    assertEquals(0d, res.getDouble(3), floatCompareDelta);
     assertEquals(null, res.getString(4));
     assertEquals(null, res.getString(5));
     assertEquals(null, res.getString(6));
@@ -598,7 +653,7 @@ public class TestJdbcDriver2 extends Tes
     assertEquals(null, res.getString(8));
     assertEquals(0, res.getByte(9));
     assertEquals(0, res.getShort(10));
-    assertEquals(0f, res.getFloat(11));
+    assertEquals(0f, res.getFloat(11), floatCompareDelta);
     assertEquals(0L, res.getLong(12));
     assertEquals(null, res.getString(13));
     assertEquals(null, res.getString(14));
@@ -615,7 +670,7 @@ public class TestJdbcDriver2 extends Tes
     assertTrue(res.next());
     assertEquals(-1, res.getInt(1));
     assertEquals(false, res.getBoolean(2));
-    assertEquals(-1.1d, res.getDouble(3));
+    assertEquals(-1.1d, res.getDouble(3), floatCompareDelta);
     assertEquals("", res.getString(4));
     assertEquals("[]", res.getString(5));
     assertEquals("{}", res.getString(6));
@@ -623,7 +678,7 @@ public class TestJdbcDriver2 extends Tes
     assertEquals("{\"r\":null,\"s\":null,\"t\":null}", res.getString(8));
     assertEquals(-1, res.getByte(9));
     assertEquals(-1, res.getShort(10));
-    assertEquals(-1.0f, res.getFloat(11));
+    assertEquals(-1.0f, res.getFloat(11), floatCompareDelta);
     assertEquals(-1, res.getLong(12));
     assertEquals("[]", res.getString(13));
     assertEquals("{}", res.getString(14));
@@ -641,7 +696,7 @@ public class TestJdbcDriver2 extends Tes
     assertTrue(res.next());
     assertEquals(1, res.getInt(1));
     assertEquals(true, res.getBoolean(2));
-    assertEquals(1.1d, res.getDouble(3));
+    assertEquals(1.1d, res.getDouble(3), floatCompareDelta);
     assertEquals("1", res.getString(4));
     assertEquals("[1,2]", res.getString(5));
     assertEquals("{1:\"x\",2:\"y\"}", res.getString(6));
@@ -649,7 +704,7 @@ public class TestJdbcDriver2 extends Tes
     assertEquals("{\"r\":\"a\",\"s\":9,\"t\":2.2}", res.getString(8));
     assertEquals(1, res.getByte(9));
     assertEquals(1, res.getShort(10));
-    assertEquals(1.0f, res.getFloat(11));
+    assertEquals(1.0f, res.getFloat(11), floatCompareDelta);
     assertEquals(1, res.getLong(12));
     assertEquals("[[\"a\",\"b\"],[\"c\",\"d\"]]", res.getString(13));
     assertEquals("{1:{11:12,13:14},2:{21:22}}", res.getString(14));
@@ -759,6 +814,7 @@ public class TestJdbcDriver2 extends Tes
     assertTrue("Statement should be closed", stmt.isClosed());
   }
 
+  @Test
   public void testErrorMessages() throws SQLException {
     String invalidSyntaxSQLState = "42000";
 
@@ -807,6 +863,7 @@ public class TestJdbcDriver2 extends Tes
         exceptionFound);
   }
 
+  @Test
   public void testShowTables() throws SQLException {
     Statement stmt = con.createStatement();
     assertNotNull("Statement is null", stmt);
@@ -825,10 +882,12 @@ public class TestJdbcDriver2 extends Tes
         + " not found in SHOW TABLES result set", testTableExists);
   }
 
+  @Test
   public void testMetaDataGetTables() throws SQLException {
     getTablesTest(ClassicTableTypes.TABLE.toString(), ClassicTableTypes.VIEW.toString());
   }
 
+  @Test
   public  void testMetaDataGetTablesHive() throws SQLException {
     Statement stmt = con.createStatement();
     stmt.execute("set " + HiveConf.ConfVars.HIVE_SERVER2_TABLE_TYPE_MAPPING.varname +
@@ -836,6 +895,7 @@ public class TestJdbcDriver2 extends Tes
     getTablesTest(TableType.MANAGED_TABLE.toString(), TableType.VIRTUAL_VIEW.toString());
   }
 
+  @Test
   public  void testMetaDataGetTablesClassic() throws SQLException {
     Statement stmt = con.createStatement();
     stmt.execute("set " + HiveConf.ConfVars.HIVE_SERVER2_TABLE_TYPE_MAPPING.varname +
@@ -907,6 +967,7 @@ public class TestJdbcDriver2 extends Tes
     assertEquals("Incorrect number of views found.", 1, cnt);
   }
 
+  @Test
   public void testMetaDataGetCatalogs() throws SQLException {
     ResultSet rs = (ResultSet)con.getMetaData().getCatalogs();
     ResultSetMetaData resMeta = rs.getMetaData();
@@ -916,6 +977,7 @@ public class TestJdbcDriver2 extends Tes
     assertFalse(rs.next());
   }
 
+  @Test
   public void testMetaDataGetSchemas() throws SQLException {
     ResultSet rs = (ResultSet)con.getMetaData().getSchemas();
     ResultSetMetaData resMeta = rs.getMetaData();
@@ -925,20 +987,21 @@ public class TestJdbcDriver2 extends Tes
 
     assertTrue(rs.next());
     assertEquals("default", rs.getString(1));
-    //    assertNull(rs.getString(2));
 
     assertFalse(rs.next());
     rs.close();
   }
 
-  //test default table types returned in
+  // test default table types returned in
   // Connection.getMetaData().getTableTypes()
+  @Test
   public void testMetaDataGetTableTypes() throws SQLException {
     metaDataGetTableTypeTest(new ClassicTableTypeMapping().getTableTypeNames());
   }
 
-  //test default table types returned in
+  // test default table types returned in
   // Connection.getMetaData().getTableTypes() when type config is set to "HIVE"
+  @Test
   public void testMetaDataGetHiveTableTypes() throws SQLException {
     Statement stmt = con.createStatement();
     stmt.execute("set " + HiveConf.ConfVars.HIVE_SERVER2_TABLE_TYPE_MAPPING.varname +
@@ -947,8 +1010,9 @@ public class TestJdbcDriver2 extends Tes
     metaDataGetTableTypeTest(new HiveTableTypeMapping().getTableTypeNames());
   }
 
-  //test default table types returned in
+  // test default table types returned in
   // Connection.getMetaData().getTableTypes() when type config is set to "CLASSIC"
+  @Test
   public void testMetaDataGetClassicTableTypes() throws SQLException {
     Statement stmt = con.createStatement();
     stmt.execute("set " + HiveConf.ConfVars.HIVE_SERVER2_TABLE_TYPE_MAPPING.varname +
@@ -979,6 +1043,7 @@ public class TestJdbcDriver2 extends Tes
     assertTrue("Found less tabletypes then we test for.", cnt >= tabletypes.size());
   }
 
+  @Test
   public void testMetaDataGetColumns() throws SQLException {
     Map<String[], Integer> tests = new HashMap<String[], Integer>();
     tests.put(new String[]{"testhivejdbcdriver\\_table", null}, 2);
@@ -1027,6 +1092,7 @@ public class TestJdbcDriver2 extends Tes
   /**
    * Validate the Metadata for the result set of a metadata getColumns call.
    */
+  @Test
   public void testMetaDataGetColumnsMetaData() throws SQLException {
     ResultSet rs = (ResultSet)con.getMetaData().getColumns(null, null
         , "testhivejdbcdriver\\_table", null);
@@ -1084,6 +1150,7 @@ public class TestJdbcDriver2 extends Tes
   }
    */
 
+  @Test
   public void testDescribeTable() throws SQLException {
     Statement stmt = con.createStatement();
     assertNotNull("Statement is null", stmt);
@@ -1102,6 +1169,7 @@ public class TestJdbcDriver2 extends Tes
     assertFalse("More results found than expected", res.next());
   }
 
+  @Test
   public void testDatabaseMetaData() throws SQLException {
     DatabaseMetaData meta = con.getMetaData();
 
@@ -1120,12 +1188,13 @@ public class TestJdbcDriver2 extends Tes
     assertTrue(meta.supportsAlterTableWithAddColumn());
   }
 
+  @Test
   public void testResultSetMetaData() throws SQLException {
     Statement stmt = con.createStatement();
 
     ResultSet res = stmt.executeQuery(
         "select c1, c2, c3, c4, c5 as a, c6, c7, c8, c9, c10, c11, c12, " +
-        "c1*2, sentences(null, null, null) as b, c17, c18, c20, c21 from " + dataTypeTableName +
+            "c1*2, sentences(null, null, null) as b, c17, c18, c20, c21 from " + dataTypeTableName +
         " limit 1");
     ResultSetMetaData meta = res.getMetaData();
 
@@ -1370,6 +1439,7 @@ public class TestJdbcDriver2 extends Tes
         "server", "10002", "db"},
   };
 
+  @Test
   public void testDriverProperties() throws SQLException {
     HiveDriver driver = new HiveDriver();
     for (String[] testValues : URL_PROPERTIES) {
@@ -1386,12 +1456,13 @@ public class TestJdbcDriver2 extends Tes
         "user=foo;password=bar?" +
         "hive.server2.transport.mode=http;" +
         "hive.server2.thrift.http.path=hs2", "server", "10002", "db", "http", "hs2"},
-    {"jdbc:hive2://server:10000/testdb;" +
-        "user=foo;password=bar?" +
-        "hive.server2.transport.mode=binary;" +
-        "hive.server2.thrift.http.path=", "server", "10000", "testdb", "binary", ""},
+        {"jdbc:hive2://server:10000/testdb;" +
+            "user=foo;password=bar?" +
+            "hive.server2.transport.mode=binary;" +
+            "hive.server2.thrift.http.path=", "server", "10000", "testdb", "binary", ""},
   };
 
+  @Test
   public void testParseUrlHttpMode() throws SQLException {
     HiveDriver driver = new HiveDriver();
     for (String[] testValues : HTTP_URL_PROPERTIES) {
@@ -1416,6 +1487,7 @@ public class TestJdbcDriver2 extends Tes
    * validate schema generated by "set" command
    * @throws SQLException
    */
+  @Test
   public void testSetCommand() throws SQLException {
     // execute set command
     String sql = "set -v";
@@ -1438,6 +1510,7 @@ public class TestJdbcDriver2 extends Tes
    * Validate error on closed resultset
    * @throws SQLException
    */
+  @Test
   public void testPostClose() throws SQLException {
     Statement stmt = con.createStatement();
     ResultSet res = stmt.executeQuery("select * from " + tableName);
@@ -1455,6 +1528,7 @@ public class TestJdbcDriver2 extends Tes
    * The JDBC spec says when you have duplicate column names,
    * the first one should be returned.
    */
+  @Test
   public void testDuplicateColumnNameOrder() throws SQLException {
     Statement stmt = con.createStatement();
     ResultSet rs = stmt.executeQuery("SELECT 1 AS a, 2 AS a from " + tableName);
@@ -1467,6 +1541,7 @@ public class TestJdbcDriver2 extends Tes
    * Test bad args to getXXX()
    * @throws SQLException
    */
+  @Test
   public void testOutOfBoundCols() throws SQLException {
     Statement stmt = con.createStatement();
 
@@ -1492,6 +1567,7 @@ public class TestJdbcDriver2 extends Tes
    * Verify selecting using builtin UDFs
    * @throws SQLException
    */
+  @Test
   public void testBuiltInUDFCol() throws SQLException {
     Statement stmt = con.createStatement();
     ResultSet res = stmt.executeQuery("select c12, bin(c12) from " + dataTypeTableName
@@ -1509,6 +1585,7 @@ public class TestJdbcDriver2 extends Tes
    * Verify selecting named expression columns
    * @throws SQLException
    */
+  @Test
   public void testExprCol() throws SQLException {
     Statement stmt = con.createStatement();
     ResultSet res = stmt.executeQuery("select c1+1 as col1, length(c4) as len from " + dataTypeTableName
@@ -1527,6 +1604,7 @@ public class TestJdbcDriver2 extends Tes
    * test getProcedureColumns()
    * @throws SQLException
    */
+  @Test
   public void testProcCols() throws SQLException {
     DatabaseMetaData dbmd = con.getMetaData();
     assertNotNull(dbmd);
@@ -1541,6 +1619,7 @@ public class TestJdbcDriver2 extends Tes
    * test testProccedures()
    * @throws SQLException
    */
+  @Test
   public void testProccedures() throws SQLException {
     DatabaseMetaData dbmd = con.getMetaData();
     assertNotNull(dbmd);
@@ -1555,6 +1634,7 @@ public class TestJdbcDriver2 extends Tes
    * test getPrimaryKeys()
    * @throws SQLException
    */
+  @Test
   public void testPrimaryKeys() throws SQLException {
     DatabaseMetaData dbmd = con.getMetaData();
     assertNotNull(dbmd);
@@ -1569,6 +1649,7 @@ public class TestJdbcDriver2 extends Tes
    * test getImportedKeys()
    * @throws SQLException
    */
+  @Test
   public void testImportedKeys() throws SQLException {
     DatabaseMetaData dbmd = con.getMetaData();
     assertNotNull(dbmd);
@@ -1583,12 +1664,10 @@ public class TestJdbcDriver2 extends Tes
    * If the Driver implementation understands the URL, it will return a Connection object;
    * otherwise it returns null
    */
+  @Test
   public void testInvalidURL() throws Exception {
     HiveDriver driver = new HiveDriver();
     Connection conn = driver.connect("jdbc:derby://localhost:10000/default", new Properties());
     assertNull(conn);
   }
-
-
-
 }

Modified: hive/branches/maven/metastore/scripts/upgrade/derby/hive-schema-0.13.0.derby.sql
URL: http://svn.apache.org/viewvc/hive/branches/maven/metastore/scripts/upgrade/derby/hive-schema-0.13.0.derby.sql?rev=1529308&r1=1529307&r2=1529308&view=diff
==============================================================================
--- hive/branches/maven/metastore/scripts/upgrade/derby/hive-schema-0.13.0.derby.sql (original)
+++ hive/branches/maven/metastore/scripts/upgrade/derby/hive-schema-0.13.0.derby.sql Fri Oct  4 21:30:38 2013
@@ -296,4 +296,4 @@ ALTER TABLE "APP"."IDXS" ADD CONSTRAINT 
 
 ALTER TABLE "APP"."SDS" ADD CONSTRAINT "SQL110318025505550" CHECK (IS_COMPRESSED IN ('Y','N'));
 
-INSERT INTO "APP"."VERSION" (VER_ID, SCHEMA_VERSION, COMMENT) VALUES (1, '0.13.0', 'Hive release version 0.13.0');
+INSERT INTO "APP"."VERSION" (VER_ID, SCHEMA_VERSION, VERSION_COMMENT) VALUES (1, '0.13.0', 'Hive release version 0.13.0');

Modified: hive/branches/maven/metastore/scripts/upgrade/oracle/014-HIVE-3764.oracle.sql
URL: http://svn.apache.org/viewvc/hive/branches/maven/metastore/scripts/upgrade/oracle/014-HIVE-3764.oracle.sql?rev=1529308&r1=1529307&r2=1529308&view=diff
==============================================================================
--- hive/branches/maven/metastore/scripts/upgrade/oracle/014-HIVE-3764.oracle.sql (original)
+++ hive/branches/maven/metastore/scripts/upgrade/oracle/014-HIVE-3764.oracle.sql Fri Oct  4 21:30:38 2013
@@ -1,10 +1,10 @@
 -- HIVE-3764 Support metastore version consistency check
 
-CREATE TABLE IF NOT EXISTS VERSION (
+CREATE TABLE VERSION (
   VER_ID NUMBER NOT NULL,
   SCHEMA_VERSION VARCHAR(127) NOT NULL,
   VERSION_COMMENT VARCHAR(255)
-)
+);
 ALTER TABLE VERSION ADD CONSTRAINT VERSION_PK PRIMARY KEY (VER_ID);
 
-INSERT INTO VERSION (VER_ID, SCHEMA_VERSION, VERSION_COMMENT) VALUES (1, '', 'Initial value');
+INSERT INTO VERSION (VER_ID, SCHEMA_VERSION, VERSION_COMMENT) VALUES (1, ' ', 'Initial value');

Modified: hive/branches/maven/metastore/scripts/upgrade/oracle/hive-schema-0.12.0.oracle.sql
URL: http://svn.apache.org/viewvc/hive/branches/maven/metastore/scripts/upgrade/oracle/hive-schema-0.12.0.oracle.sql?rev=1529308&r1=1529307&r2=1529308&view=diff
==============================================================================
--- hive/branches/maven/metastore/scripts/upgrade/oracle/hive-schema-0.12.0.oracle.sql (original)
+++ hive/branches/maven/metastore/scripts/upgrade/oracle/hive-schema-0.12.0.oracle.sql Fri Oct  4 21:30:38 2013
@@ -483,11 +483,11 @@ CREATE TABLE TAB_COL_STATS (
  LAST_ANALYZED NUMBER NOT NULL
 );
 
-CREATE TABLE IF NOT EXISTS VERSION (
+CREATE TABLE VERSION (
   VER_ID NUMBER NOT NULL,
   SCHEMA_VERSION VARCHAR(127) NOT NULL,
   VERSION_COMMENT VARCHAR(255)
-)
+);
 ALTER TABLE VERSION ADD CONSTRAINT VERSION_PK PRIMARY KEY (VER_ID);
 
 ALTER TABLE TAB_COL_STATS ADD CONSTRAINT TAB_COL_STATS_PKEY PRIMARY KEY (CS_ID);

Modified: hive/branches/maven/metastore/scripts/upgrade/oracle/hive-schema-0.13.0.oracle.sql
URL: http://svn.apache.org/viewvc/hive/branches/maven/metastore/scripts/upgrade/oracle/hive-schema-0.13.0.oracle.sql?rev=1529308&r1=1529307&r2=1529308&view=diff
==============================================================================
--- hive/branches/maven/metastore/scripts/upgrade/oracle/hive-schema-0.13.0.oracle.sql (original)
+++ hive/branches/maven/metastore/scripts/upgrade/oracle/hive-schema-0.13.0.oracle.sql Fri Oct  4 21:30:38 2013
@@ -483,11 +483,11 @@ CREATE TABLE TAB_COL_STATS (
  LAST_ANALYZED NUMBER NOT NULL
 );
 
-CREATE TABLE IF NOT EXISTS VERSION (
+CREATE TABLE VERSION (
   VER_ID NUMBER NOT NULL,
   SCHEMA_VERSION VARCHAR(127) NOT NULL,
-  COMMENT VARCHAR(255)
-)
+  VERSION_COMMENT VARCHAR(255)
+);
 ALTER TABLE VERSION ADD CONSTRAINT VERSION_PK PRIMARY KEY (VER_ID);
 
 ALTER TABLE TAB_COL_STATS ADD CONSTRAINT TAB_COL_STATS_PKEY PRIMARY KEY (CS_ID);

Modified: hive/branches/maven/metastore/scripts/upgrade/oracle/upgrade-0.11.0-to-0.12.0.oracle.sql
URL: http://svn.apache.org/viewvc/hive/branches/maven/metastore/scripts/upgrade/oracle/upgrade-0.11.0-to-0.12.0.oracle.sql?rev=1529308&r1=1529307&r2=1529308&view=diff
==============================================================================
--- hive/branches/maven/metastore/scripts/upgrade/oracle/upgrade-0.11.0-to-0.12.0.oracle.sql (original)
+++ hive/branches/maven/metastore/scripts/upgrade/oracle/upgrade-0.11.0-to-0.12.0.oracle.sql Fri Oct  4 21:30:38 2013
@@ -1,4 +1,4 @@
-SELECT 'Upgrading MetaStore schema from 0.11.0 to 0.12.0' AS ' ';
+SELECT 'Upgrading MetaStore schema from 0.11.0 to 0.12.0' AS Status from dual;
 @013-HIVE-3255.oracle.sql;
 @014-HIVE-3764.oracle.sql;
 UPDATE VERSION SET SCHEMA_VERSION='0.12.0', VERSION_COMMENT='Hive release version 0.12.0' where VER_ID=1;

Modified: hive/branches/maven/metastore/scripts/upgrade/oracle/upgrade-0.12.0-to-0.13.0.oracle.sql
URL: http://svn.apache.org/viewvc/hive/branches/maven/metastore/scripts/upgrade/oracle/upgrade-0.12.0-to-0.13.0.oracle.sql?rev=1529308&r1=1529307&r2=1529308&view=diff
==============================================================================
--- hive/branches/maven/metastore/scripts/upgrade/oracle/upgrade-0.12.0-to-0.13.0.oracle.sql (original)
+++ hive/branches/maven/metastore/scripts/upgrade/oracle/upgrade-0.12.0-to-0.13.0.oracle.sql Fri Oct  4 21:30:38 2013
@@ -1,3 +1,3 @@
-SELECT 'Upgrading MetaStore schema from 0.11.0 to 0.12.0' AS ' ';
+SELECT 'Upgrading MetaStore schema from 0.11.0 to 0.12.0' AS Status from dual;
 UPDATE VERSION SET SCHEMA_VERSION='0.13.0', VERSION_COMMENT='Hive release version 0.13.0' where VER_ID=1;
 SELECT 'Finished upgrading MetaStore schema from 0.11.0 to 0.12.0' AS Status from dual;

Modified: hive/branches/maven/metastore/scripts/upgrade/postgres/014-HIVE-3764.postgres.sql
URL: http://svn.apache.org/viewvc/hive/branches/maven/metastore/scripts/upgrade/postgres/014-HIVE-3764.postgres.sql?rev=1529308&r1=1529307&r2=1529308&view=diff
==============================================================================
--- hive/branches/maven/metastore/scripts/upgrade/postgres/014-HIVE-3764.postgres.sql (original)
+++ hive/branches/maven/metastore/scripts/upgrade/postgres/014-HIVE-3764.postgres.sql Fri Oct  4 21:30:38 2013
@@ -4,9 +4,8 @@
 CREATE TABLE "VERSION" (
   "VER_ID" bigint,
   "SCHEMA_VERSION" character varying(127) NOT NULL,
-  "VERSION_COMMENT" character varying(255) NOT NULL,
-  PRIMARY KEY ("VER_ID")
+  "VERSION_COMMENT" character varying(255) NOT NULL
 );
 ALTER TABLE ONLY "VERSION" ADD CONSTRAINT "VERSION_pkey" PRIMARY KEY ("VER_ID");
 
-INSERT INTO VERSION (VER_ID, SCHEMA_VERSION, VERSION_COMMENT) VALUES (1, '', 'Initial value');
+INSERT INTO "VERSION" ("VER_ID", "SCHEMA_VERSION", "VERSION_COMMENT") VALUES (1, '', 'Initial value');

Modified: hive/branches/maven/metastore/scripts/upgrade/postgres/hive-schema-0.12.0.postgres.sql
URL: http://svn.apache.org/viewvc/hive/branches/maven/metastore/scripts/upgrade/postgres/hive-schema-0.12.0.postgres.sql?rev=1529308&r1=1529307&r2=1529308&view=diff
==============================================================================
--- hive/branches/maven/metastore/scripts/upgrade/postgres/hive-schema-0.12.0.postgres.sql (original)
+++ hive/branches/maven/metastore/scripts/upgrade/postgres/hive-schema-0.12.0.postgres.sql Fri Oct  4 21:30:38 2013
@@ -521,8 +521,7 @@ CREATE TABLE "TAB_COL_STATS" (
 CREATE TABLE "VERSION" (
   "VER_ID" bigint,
   "SCHEMA_VERSION" character varying(127) NOT NULL,
-  "VERSION_COMMENT" character varying(255) NOT NULL,
-  PRIMARY KEY ("VER_ID")
+  "VERSION_COMMENT" character varying(255) NOT NULL
 );
 
 --
@@ -1400,7 +1399,7 @@ REVOKE ALL ON SCHEMA public FROM PUBLIC;
 GRANT ALL ON SCHEMA public TO PUBLIC;
 
 
-INSERT INTO VERSION (VER_ID, SCHEMA_VERSION, VERSION_COMMENT) VALUES (1, '0.12.0', 'Hive release version 0.12.0');
+INSERT INTO "VERSION" ("VER_ID", "SCHEMA_VERSION", "VERSION_COMMENT") VALUES (1, '0.12.0', 'Hive release version 0.12.0');
 --
 -- PostgreSQL database dump complete
 --

Modified: hive/branches/maven/metastore/scripts/upgrade/postgres/hive-schema-0.13.0.postgres.sql
URL: http://svn.apache.org/viewvc/hive/branches/maven/metastore/scripts/upgrade/postgres/hive-schema-0.13.0.postgres.sql?rev=1529308&r1=1529307&r2=1529308&view=diff
==============================================================================
--- hive/branches/maven/metastore/scripts/upgrade/postgres/hive-schema-0.13.0.postgres.sql (original)
+++ hive/branches/maven/metastore/scripts/upgrade/postgres/hive-schema-0.13.0.postgres.sql Fri Oct  4 21:30:38 2013
@@ -521,8 +521,7 @@ CREATE TABLE "TAB_COL_STATS" (
 CREATE TABLE "VERSION" (
   "VER_ID" bigint,
   "SCHEMA_VERSION" character varying(127) NOT NULL,
-  "COMMENT" character varying(255) NOT NULL,
-  PRIMARY KEY ("VER_ID")
+  "VERSION_COMMENT" character varying(255) NOT NULL
 );
 
 --
@@ -1400,7 +1399,7 @@ REVOKE ALL ON SCHEMA public FROM PUBLIC;
 GRANT ALL ON SCHEMA public TO PUBLIC;
 
 
-INSERT INTO VERSION (VER_ID, SCHEMA_VERSION, VERSION_COMMENT) VALUES (1, '0.13.0', 'Hive release version 0.13.0');
+INSERT INTO "VERSION" ("VER_ID", "SCHEMA_VERSION", "VERSION_COMMENT") VALUES (1, '0.13.0', 'Hive release version 0.13.0');
 --
 -- PostgreSQL database dump complete
 --

Modified: hive/branches/maven/metastore/scripts/upgrade/postgres/upgrade-0.11.0-to-0.12.0.postgres.sql
URL: http://svn.apache.org/viewvc/hive/branches/maven/metastore/scripts/upgrade/postgres/upgrade-0.11.0-to-0.12.0.postgres.sql?rev=1529308&r1=1529307&r2=1529308&view=diff
==============================================================================
--- hive/branches/maven/metastore/scripts/upgrade/postgres/upgrade-0.11.0-to-0.12.0.postgres.sql (original)
+++ hive/branches/maven/metastore/scripts/upgrade/postgres/upgrade-0.11.0-to-0.12.0.postgres.sql Fri Oct  4 21:30:38 2013
@@ -1,5 +1,5 @@
 SELECT 'Upgrading MetaStore schema from 0.11.0 to 0.12.0';
 \i 013-HIVE-3255.postgres.sql;
 \i 014-HIVE-3764.postgres.sql;
-UPDATE VERSION SET SCHEMA_VERSION='0.12.0', VERSION_COMMENT='Hive release version 0.12.0' where VER_ID=1;
+UPDATE "VERSION" SET "SCHEMA_VERSION"='0.12.0', "VERSION_COMMENT"='Hive release version 0.12.0' where "VER_ID"=1;
 SELECT 'Finished upgrading MetaStore schema from 0.11.0 to 0.12.0';

Modified: hive/branches/maven/metastore/scripts/upgrade/postgres/upgrade-0.12.0-to-0.13.0.postgres.sql
URL: http://svn.apache.org/viewvc/hive/branches/maven/metastore/scripts/upgrade/postgres/upgrade-0.12.0-to-0.13.0.postgres.sql?rev=1529308&r1=1529307&r2=1529308&view=diff
==============================================================================
--- hive/branches/maven/metastore/scripts/upgrade/postgres/upgrade-0.12.0-to-0.13.0.postgres.sql (original)
+++ hive/branches/maven/metastore/scripts/upgrade/postgres/upgrade-0.12.0-to-0.13.0.postgres.sql Fri Oct  4 21:30:38 2013
@@ -1,3 +1,3 @@
 SELECT 'Upgrading MetaStore schema from 0.11.0 to 0.12.0';
-UPDATE VERSION SET SCHEMA_VERSION='0.13.0', VERSION_COMMENT='Hive release version 0.13.0' where VER_ID=1;
+UPDATE "VERSION" SET "SCHEMA_VERSION"='0.13.0', "VERSION_COMMENT"='Hive release version 0.13.0' where "VER_ID"=1;
 SELECT 'Finished upgrading MetaStore schema from 0.11.0 to 0.12.0';

Modified: hive/branches/maven/metastore/src/test/org/apache/hadoop/hive/metastore/TestMetastoreVersion.java
URL: http://svn.apache.org/viewvc/hive/branches/maven/metastore/src/test/org/apache/hadoop/hive/metastore/TestMetastoreVersion.java?rev=1529308&r1=1529307&r2=1529308&view=diff
==============================================================================
--- hive/branches/maven/metastore/src/test/org/apache/hadoop/hive/metastore/TestMetastoreVersion.java (original)
+++ hive/branches/maven/metastore/src/test/org/apache/hadoop/hive/metastore/TestMetastoreVersion.java Fri Oct  4 21:30:38 2013
@@ -17,8 +17,13 @@
  */
 package org.apache.hadoop.hive.metastore;
 
+import java.io.File;
+import java.lang.reflect.Field;
+import java.util.Random;
+
 import junit.framework.TestCase;
 
+import org.apache.commons.io.FileUtils;
 import org.apache.hadoop.hive.cli.CliSessionState;
 import org.apache.hadoop.hive.conf.HiveConf;
 import org.apache.hadoop.hive.metastore.api.MetaException;
@@ -31,18 +36,35 @@ public class TestMetastoreVersion extend
   protected HiveConf hiveConf;
   private Driver driver;
   private String hiveHome;
+  private String testMetastoreDB;
+  Random randomNum = new Random();
 
   @Override
   protected void setUp() throws Exception {
     super.setUp();
+    Field defDb = HiveMetaStore.HMSHandler.class.getDeclaredField("createDefaultDB");
+    defDb.setAccessible(true);
+    defDb.setBoolean(null, false);
     hiveConf = new HiveConf(this.getClass());
     System.setProperty("hive.metastore.event.listeners",
         DummyListener.class.getName());
     System.setProperty("hive.metastore.pre.event.listeners",
         DummyPreListener.class.getName());
+    testMetastoreDB = System.getProperty("java.io.tmpdir") +
+    File.separator + "test_metastore-" + randomNum.nextInt();
+    System.setProperty(HiveConf.ConfVars.METASTORECONNECTURLKEY.varname,
+        "jdbc:derby:" + testMetastoreDB + ";create=true");
     hiveHome = System.getProperty("hive.home");
   }
 
+  @Override
+  protected void tearDown() throws Exception {
+    File metaStoreDir = new File(testMetastoreDB);
+    if (metaStoreDir.exists()) {
+      FileUtils.deleteDirectory(metaStoreDir);
+    }
+  }
+
   /***
    * Test config defaults
    */

Modified: hive/branches/maven/ql/build.xml
URL: http://svn.apache.org/viewvc/hive/branches/maven/ql/build.xml?rev=1529308&r1=1529307&r2=1529308&view=diff
==============================================================================
--- hive/branches/maven/ql/build.xml (original)
+++ hive/branches/maven/ql/build.xml Fri Oct  4 21:30:38 2013
@@ -190,7 +190,7 @@
     <echo message="Project: ${ant.project.name}"/>
     <javac
      encoding="${build.encoding}"
-     srcdir="${src.dir}:${basedir}/src/gen/thrift/gen-javabean:${build.dir}/gen/antlr/gen-java:${protobuf.build.dir}"
+     srcdir="${src.dir}:${basedir}/src/gen/thrift/gen-javabean:${build.dir}/gen/antlr/gen-java:${protobuf.build.dir}:${build.dir}/gen/vector"
      includes="**/*.java"
      destdir="${build.classes}"
      debug="${javac.debug}"