From 758e8ed2e049d313d7228cfc333a6cc5ee5d5694 Mon Sep 17 00:00:00 2001 From: mbautin Date: Sun, 2 Dec 2012 18:22:10 -0800 Subject: [PATCH] HIVE-3384 Hive JDBC module won't compile under JDK1.7 as new methods added in JDBC specification HIVE-3384 addendum: specify jvm.args in build-plugin.xml if not set --- build-common.xml | 1 + build.properties | 7 +- .../apache/hadoop/hive/jdbc/HiveBaseResultSet.java | 10 +++ .../hadoop/hive/jdbc/HiveCallableStatement.java | 21 +++++ .../apache/hadoop/hive/jdbc/HiveConnection.java | 36 +++++++-- .../apache/hadoop/hive/jdbc/HiveDataSource.java | 9 +++ .../hadoop/hive/jdbc/HiveDatabaseMetaData.java | 85 ++++++++++++++++++++ .../org/apache/hadoop/hive/jdbc/HiveDriver.java | 9 +++ .../hadoop/hive/jdbc/HivePreparedStatement.java | 11 +++ .../hadoop/hive/jdbc/HiveQueryResultSet.java | 12 +++ .../org/apache/hadoop/hive/jdbc/HiveStatement.java | 10 +++ metastore/build.xml | 2 +- pdk/scripts/build-plugin.xml | 13 ++- 13 files changed, 214 insertions(+), 12 deletions(-) diff --git build-common.xml build-common.xml index ad9a3cc..92f3694 100644 --- build-common.xml +++ build-common.xml @@ -437,6 +437,7 @@ + diff --git build.properties build.properties index 55b8ea0..4d9eed8 100644 --- build.properties +++ build.properties @@ -110,7 +110,6 @@ mvn.pom.dir=${build.dir.hive}/maven/poms mvn.license.dir=${build.dir.hive}/maven/licenses mvn.deploy.id=apache.snapshots.https mvn.deploy.url=https://repository.apache.org/content/repositories/snapshots - # # unit test Properties # @@ -121,9 +120,13 @@ failonerror=false # datanucleus.repo=http://www.datanucleus.org/downloads/maven2 +# JVM arguments +jvm.args=-XX:-UseSplitVerifier + # # Eclipse Properties # # JVM arguments for Eclipse launch configurations -eclipse.launch.jvm.args=-Xms256m -Xmx1024m +eclipse.launch.jvm.args=-Xms256m -Xmx1024m ${jvm.args} + diff --git jdbc/src/java/org/apache/hadoop/hive/jdbc/HiveBaseResultSet.java jdbc/src/java/org/apache/hadoop/hive/jdbc/HiveBaseResultSet.java index 5b5d4de..3bfff92 100644 --- jdbc/src/java/org/apache/hadoop/hive/jdbc/HiveBaseResultSet.java +++ jdbc/src/java/org/apache/hadoop/hive/jdbc/HiveBaseResultSet.java @@ -370,6 +370,16 @@ public abstract class HiveBaseResultSet implements ResultSet{ return getObject(findColumn(columnName)); } + public T getObject(int columnIndex, Class type) throws SQLException { + // TODO method required by JDK 1.7 + throw new SQLException("Method not supported"); + } + + public T getObject(String columnLabel, Class type) throws SQLException { + // TODO method required by JDK 1.7 + throw new SQLException("Method not supported"); + } + public Object getObject(int i, Map> map) throws SQLException { throw new SQLException("Method not supported"); } diff --git jdbc/src/java/org/apache/hadoop/hive/jdbc/HiveCallableStatement.java jdbc/src/java/org/apache/hadoop/hive/jdbc/HiveCallableStatement.java index 556249a..ff961f3 100644 --- jdbc/src/java/org/apache/hadoop/hive/jdbc/HiveCallableStatement.java +++ jdbc/src/java/org/apache/hadoop/hive/jdbc/HiveCallableStatement.java @@ -462,6 +462,17 @@ public class HiveCallableStatement implements java.sql.CallableStatement { throw new SQLException("Method not supported"); } + public T getObject(int parameterIndex, Class type) throws SQLException { + // TODO JDK 1.7 + throw new SQLException("Method not supported"); + } + + public T getObject(String parameterName, Class type) throws SQLException { + // TODO JDK 1.7 + throw new SQLException("Method not supported"); + } + + /* * (non-Javadoc) * @@ -2031,6 +2042,16 @@ public class HiveCallableStatement implements java.sql.CallableStatement { throw new SQLException("Method not supported"); } + public void closeOnCompletion() throws SQLException { + // JDK 1.7 + throw new SQLException("Method not supported"); + } + + public boolean isCloseOnCompletion() throws SQLException { + // JDK 1.7 + throw new SQLException("Method not supported"); + } + /* * (non-Javadoc) * diff --git jdbc/src/java/org/apache/hadoop/hive/jdbc/HiveConnection.java jdbc/src/java/org/apache/hadoop/hive/jdbc/HiveConnection.java index 6618243..d08e05b 100644 --- jdbc/src/java/org/apache/hadoop/hive/jdbc/HiveConnection.java +++ jdbc/src/java/org/apache/hadoop/hive/jdbc/HiveConnection.java @@ -29,6 +29,7 @@ import org.apache.thrift.protocol.TProtocol; import org.apache.thrift.transport.TSocket; import org.apache.thrift.transport.TTransport; import org.apache.thrift.transport.TTransportException; +import java.util.concurrent.Executor; import java.sql.Array; import java.sql.Blob; @@ -120,6 +121,12 @@ public class HiveConnection implements java.sql.Connection { isClosed = false; configureConnection(); } + + + public void abort(Executor executor) throws SQLException { + // JDK 1.7 + throw new SQLException("Method not supported"); + } private void configureConnection() throws SQLException { Statement stmt = createStatement(); @@ -340,6 +347,17 @@ public class HiveConnection implements java.sql.Connection { return new HiveDatabaseMetaData(client); } + + public int getNetworkTimeout() throws SQLException { + // JDK 1.7 + throw new SQLException("Method not supported"); + } + + + public String getSchema() throws SQLException { + // JDK 1.7 + throw new SQLException("Method not supported"); + } /* * (non-Javadoc) * @@ -607,6 +625,11 @@ public class HiveConnection implements java.sql.Connection { throw new SQLException("Method not supported"); } + public void setNetworkTimeout(Executor executor, int milliseconds) throws SQLException { + // JDK 1.7 + throw new SQLException("Method not supported"); + } + /* * (non-Javadoc) * @@ -640,6 +663,11 @@ public class HiveConnection implements java.sql.Connection { throw new SQLException("Method not supported"); } + public void setSchema(String schema) throws SQLException { + // JDK 1.7 + throw new SQLException("Method not supported"); + } + /* * (non-Javadoc) * @@ -673,15 +701,9 @@ public class HiveConnection implements java.sql.Connection { throw new SQLException("Method not supported"); } - /* - * (non-Javadoc) - * - * @see java.sql.Wrapper#unwrap(java.lang.Class) - */ - public T unwrap(Class iface) throws SQLException { // TODO Auto-generated method stub throw new SQLException("Method not supported"); } - } + diff --git jdbc/src/java/org/apache/hadoop/hive/jdbc/HiveDataSource.java jdbc/src/java/org/apache/hadoop/hive/jdbc/HiveDataSource.java index 21599ff..f016d74 100644 --- jdbc/src/java/org/apache/hadoop/hive/jdbc/HiveDataSource.java +++ jdbc/src/java/org/apache/hadoop/hive/jdbc/HiveDataSource.java @@ -21,6 +21,8 @@ package org.apache.hadoop.hive.jdbc; import java.io.PrintWriter; import java.sql.Connection; import java.sql.SQLException; +import java.sql.SQLFeatureNotSupportedException; +import java.util.logging.Logger; import javax.sql.DataSource; @@ -90,6 +92,12 @@ public class HiveDataSource implements DataSource { * @see javax.sql.CommonDataSource#setLogWriter(java.io.PrintWriter) */ + public Logger getParentLogger() throws SQLFeatureNotSupportedException { + // JDK 1.7 + throw new SQLFeatureNotSupportedException("Method not supported"); + } + + public void setLogWriter(PrintWriter arg0) throws SQLException { // TODO Auto-generated method stub throw new SQLException("Method not supported"); @@ -129,3 +137,4 @@ public class HiveDataSource implements DataSource { } } + diff --git jdbc/src/java/org/apache/hadoop/hive/jdbc/HiveDatabaseMetaData.java jdbc/src/java/org/apache/hadoop/hive/jdbc/HiveDatabaseMetaData.java index 41b8048..bda3e0d 100644 --- jdbc/src/java/org/apache/hadoop/hive/jdbc/HiveDatabaseMetaData.java +++ jdbc/src/java/org/apache/hadoop/hive/jdbc/HiveDatabaseMetaData.java @@ -124,6 +124,18 @@ public class HiveDatabaseMetaData implements java.sql.DatabaseMetaData { return false; } } + + public T getObject(String columnLabel, Class type) + throws SQLException { + // JDK 1.7 + throw new SQLException("Method not supported"); + } + + public T getObject(int columnIndex, Class type) + throws SQLException { + // JDK 1.7 + throw new SQLException("Method not supported"); + } }; } catch (Exception e) { throw new SQLException(e); @@ -139,6 +151,17 @@ public class HiveDatabaseMetaData implements java.sql.DatabaseMetaData { throw new SQLException("Method not supported"); } + public ResultSet getPseudoColumns(String catalog, String schemaPattern, + String tableNamePattern, String columnNamePattern) throws SQLException { + throw new SQLException("Method not supported"); + } + + public boolean generatedKeyAlwaysReturned() throws SQLException { + // JDK 1.7 + throw new SQLException("Method not supported"); + } + + /** * Convert a pattern containing JDBC catalog search wildcards into * Java regex patterns. @@ -256,6 +279,18 @@ public class HiveDatabaseMetaData implements java.sql.DatabaseMetaData { return false; } } + + public T getObject(String columnLabel, Class type) + throws SQLException { + // JDK 1.7 + throw new SQLException("Method not supported"); + } + + public T getObject(int columnIndex, Class type) + throws SQLException { + // JDK 1.7 + throw new SQLException("Method not supported"); + } }; } catch (Exception e) { throw new SQLException(e); @@ -514,6 +549,18 @@ public class HiveDatabaseMetaData implements java.sql.DatabaseMetaData { public boolean next() throws SQLException { return false; } + + public T getObject(String columnLabel, Class type) + throws SQLException { + // JDK 1.7 + throw new SQLException("Method not supported"); + } + + public T getObject(int columnIndex, Class type) + throws SQLException { + // JDK 1.7 + throw new SQLException("Method not supported"); + } }; } @@ -563,6 +610,18 @@ public class HiveDatabaseMetaData implements java.sql.DatabaseMetaData { return false; } } + + public T getObject(String columnLabel, Class type) + throws SQLException { + // JDK 1.7 + throw new SQLException("Method not supported"); + } + + public T getObject(int columnIndex, Class type) + throws SQLException { + // JDK 1.7 + throw new SQLException("Method not supported"); + } }; return result; } @@ -630,6 +689,18 @@ public class HiveDatabaseMetaData implements java.sql.DatabaseMetaData { } } + public T getObject(String columnLabel, Class type) + throws SQLException { + // JDK 1.7 + throw new SQLException("Method not supported"); + } + + public T getObject(int columnIndex, Class type) + throws SQLException { + // JDK 1.7 + throw new SQLException("Method not supported"); + } + }; return result; } @@ -689,6 +760,18 @@ public class HiveDatabaseMetaData implements java.sql.DatabaseMetaData { public boolean next() throws SQLException { return false; } + + public T getObject(String columnLabel, Class type) + throws SQLException { + // JDK 1.7 + throw new SQLException("Method not supported"); + } + + public T getObject(int columnIndex, Class type) + throws SQLException { + // JDK 1.7 + throw new SQLException("Method not supported"); + } }; } @@ -1086,4 +1169,6 @@ public class HiveDatabaseMetaData implements java.sql.DatabaseMetaData { System.out.println("DriverName: " + meta.getDriverName()); System.out.println("DriverVersion: " + meta.getDriverVersion()); } + } + diff --git jdbc/src/java/org/apache/hadoop/hive/jdbc/HiveDriver.java jdbc/src/java/org/apache/hadoop/hive/jdbc/HiveDriver.java index c61425f..68c0788 100644 --- jdbc/src/java/org/apache/hadoop/hive/jdbc/HiveDriver.java +++ jdbc/src/java/org/apache/hadoop/hive/jdbc/HiveDriver.java @@ -24,9 +24,11 @@ import java.sql.Connection; import java.sql.Driver; import java.sql.DriverPropertyInfo; import java.sql.SQLException; +import java.sql.SQLFeatureNotSupportedException; import java.util.Properties; import java.util.jar.Attributes; import java.util.jar.Manifest; +import java.util.logging.Logger; import java.util.regex.Pattern; /** @@ -166,6 +168,11 @@ public class HiveDriver implements Driver { return HiveDriver.getMinorDriverVersion(); } + public Logger getParentLogger() throws SQLFeatureNotSupportedException { + // JDK 1.7 + throw new SQLFeatureNotSupportedException("Method not supported"); + } + public DriverPropertyInfo[] getPropertyInfo(String url, Properties info) throws SQLException { if (info == null) { info = new Properties(); @@ -294,4 +301,6 @@ public class HiveDriver implements Driver { } return manifestAttributes.getValue(attributeName); } + } + diff --git jdbc/src/java/org/apache/hadoop/hive/jdbc/HivePreparedStatement.java jdbc/src/java/org/apache/hadoop/hive/jdbc/HivePreparedStatement.java index fae4e29..fb779e0 100644 --- jdbc/src/java/org/apache/hadoop/hive/jdbc/HivePreparedStatement.java +++ jdbc/src/java/org/apache/hadoop/hive/jdbc/HivePreparedStatement.java @@ -843,6 +843,12 @@ public class HivePreparedStatement implements PreparedStatement { warningChain=null; } + + public void closeOnCompletion() throws SQLException { + // JDK 1.7 + throw new SQLException("Method not supported"); + } + /** * Closes the prepared statement. * @@ -1139,6 +1145,11 @@ public class HivePreparedStatement implements PreparedStatement { return isClosed; } + public boolean isCloseOnCompletion() throws SQLException { + //JDK 1.7 + throw new SQLException("Method not supported"); + } + /* * (non-Javadoc) * diff --git jdbc/src/java/org/apache/hadoop/hive/jdbc/HiveQueryResultSet.java jdbc/src/java/org/apache/hadoop/hive/jdbc/HiveQueryResultSet.java index 0f129b6..3215178 100644 --- jdbc/src/java/org/apache/hadoop/hive/jdbc/HiveQueryResultSet.java +++ jdbc/src/java/org/apache/hadoop/hive/jdbc/HiveQueryResultSet.java @@ -190,6 +190,16 @@ public class HiveQueryResultSet extends HiveBaseResultSet { return fetchSize; } + public T getObject(String columnLabel, Class type) throws SQLException { + //JDK 1.7 + throw new SQLException("Method not supported"); + } + + public T getObject(int columnIndex, Class type) throws SQLException { + //JDK 1.7 + throw new SQLException("Method not supported"); + } + /** * Convert a LazyObject to a standard Java object in compliance with JDBC 3.0 (see JDBC 3.0 * Specification, Table B-3: Mapping from JDBC Types to Java Object Types). @@ -207,4 +217,6 @@ public class HiveQueryResultSet extends HiveBaseResultSet { return obj; } + } + diff --git jdbc/src/java/org/apache/hadoop/hive/jdbc/HiveStatement.java jdbc/src/java/org/apache/hadoop/hive/jdbc/HiveStatement.java index 4dc70eb..23cb4cd 100644 --- jdbc/src/java/org/apache/hadoop/hive/jdbc/HiveStatement.java +++ jdbc/src/java/org/apache/hadoop/hive/jdbc/HiveStatement.java @@ -117,6 +117,11 @@ public class HiveStatement implements java.sql.Statement { isClosed = true; } + public void closeOnCompletion() throws SQLException { + // JDK 1.7 + throw new SQLException("Method not supported"); + } + /* * (non-Javadoc) * @@ -400,6 +405,11 @@ public class HiveStatement implements java.sql.Statement { return isClosed; } + public boolean isCloseOnCompletion() throws SQLException { + // JDK 1.7 + throw new SQLException("Method not supported"); + } + /* * (non-Javadoc) * diff --git metastore/build.xml metastore/build.xml index 1129917..9e60b66 100755 --- metastore/build.xml +++ metastore/build.xml @@ -103,7 +103,7 @@ - + diff --git pdk/scripts/build-plugin.xml pdk/scripts/build-plugin.xml index a63582b..a4f0640 100644 --- pdk/scripts/build-plugin.xml +++ pdk/scripts/build-plugin.xml @@ -27,11 +27,19 @@ - + + + + + + + + @@ -99,7 +107,7 @@ - @@ -144,6 +152,7 @@ + -- 1.7.10.4