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 2014/11/29 21:12:02 UTC
svn commit: r1642470 - in /hive/trunk:
itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestJdbcDriver2.java
jdbc/src/java/org/apache/hive/jdbc/HiveBaseResultSet.java
Author: brock
Date: Sat Nov 29 20:12:02 2014
New Revision: 1642470
URL: http://svn.apache.org/r1642470
Log:
HIVE-8889 - JDBC Driver ResultSet.getXXXXXX(String columnLabel) methods Broken (Chaoyu Tang via Brock)
Modified:
hive/trunk/itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestJdbcDriver2.java
hive/trunk/jdbc/src/java/org/apache/hive/jdbc/HiveBaseResultSet.java
Modified: hive/trunk/itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestJdbcDriver2.java
URL: http://svn.apache.org/viewvc/hive/trunk/itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestJdbcDriver2.java?rev=1642470&r1=1642469&r2=1642470&view=diff
==============================================================================
--- hive/trunk/itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestJdbcDriver2.java (original)
+++ hive/trunk/itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestJdbcDriver2.java Sat Nov 29 20:12:02 2014
@@ -628,6 +628,12 @@ public class TestJdbcDriver2 {
}
@Test
+ public final void testSelectAllFromView() throws Exception {
+ doTestSelectAll(viewName, -1, -1); // tests not setting maxRows (return all)
+ doTestSelectAll(viewName, 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)
@@ -922,17 +928,20 @@ public class TestJdbcDriver2 {
assertEquals(
"Unexpected column count", expectedColCount, meta.getColumnCount());
- String colQualifier = ((tableName != null) && !tableName.isEmpty()) ? tableName.toLowerCase() + "." : "";
boolean moreRow = res.next();
while (moreRow) {
try {
i++;
- assertEquals(res.getInt(1), res.getInt(colQualifier + "under_col"));
- assertEquals(res.getString(1), res.getString(colQualifier + "under_col"));
- assertEquals(res.getString(2), res.getString(colQualifier + "value"));
+ assertEquals(res.getInt(1), res.getInt(tableName + ".under_col"));
+ assertEquals(res.getInt(1), res.getInt("under_col"));
+ assertEquals(res.getString(1), res.getString(tableName + ".under_col"));
+ assertEquals(res.getString(1), res.getString("under_col"));
+ assertEquals(res.getString(2), res.getString(tableName + ".value"));
+ assertEquals(res.getString(2), res.getString("value"));
if (isPartitionTable) {
assertEquals(res.getString(3), partitionedColumnValue);
- assertEquals(res.getString(3), res.getString(colQualifier + partitionedColumnName));
+ assertEquals(res.getString(3), res.getString(partitionedColumnName));
+ assertEquals(res.getString(3), res.getString(tableName + "."+ partitionedColumnName));
}
assertFalse("Last result value was not null", res.wasNull());
assertNull("No warnings should be found on ResultSet", res
Modified: hive/trunk/jdbc/src/java/org/apache/hive/jdbc/HiveBaseResultSet.java
URL: http://svn.apache.org/viewvc/hive/trunk/jdbc/src/java/org/apache/hive/jdbc/HiveBaseResultSet.java?rev=1642470&r1=1642469&r2=1642470&view=diff
==============================================================================
--- hive/trunk/jdbc/src/java/org/apache/hive/jdbc/HiveBaseResultSet.java (original)
+++ hive/trunk/jdbc/src/java/org/apache/hive/jdbc/HiveBaseResultSet.java Sat Nov 29 20:12:02 2014
@@ -85,11 +85,21 @@ public abstract class HiveBaseResultSet
}
public int findColumn(String columnName) throws SQLException {
- int columnIndex = normalizedColumnNames.indexOf(columnName.toLowerCase());
- if (columnIndex==-1) {
- throw new SQLException();
+ int columnIndex = 0;
+ boolean findColumn = false;
+ for (String normalizedColumnName : normalizedColumnNames) {
+ ++columnIndex;
+ String[] names = normalizedColumnName.split("\\.");
+ String name = names[names.length -1];
+ if (name.equalsIgnoreCase(columnName) || normalizedColumnName.equalsIgnoreCase(columnName)) {
+ findColumn = true;
+ break;
+ }
+ }
+ if (!findColumn) {
+ throw new SQLException("Could not find " + columnName + " in " + normalizedColumnNames);
} else {
- return ++columnIndex;
+ return columnIndex;
}
}