hive-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pxi...@apache.org
Subject [3/3] hive git commit: HIVE-11894: CBO: Calcite Operator To Hive Operator (Calcite Return Path): correct table column name in CTAS queries (Pengcheng Xiong, reviewed by Ashutosh Chauhan)
Date Tue, 13 Oct 2015 17:42:22 GMT
HIVE-11894: CBO: Calcite Operator To Hive Operator (Calcite Return Path): correct table column
name in CTAS queries (Pengcheng Xiong, reviewed by Ashutosh Chauhan)


Project: http://git-wip-us.apache.org/repos/asf/hive/repo
Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/c1708ac8
Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/c1708ac8
Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/c1708ac8

Branch: refs/heads/master
Commit: c1708ac81d343c6731f486f3e850b60e73bb7b2a
Parents: a85c83d
Author: Pengcheng Xiong <pxiong@apache.org>
Authored: Tue Oct 13 10:41:47 2015 -0700
Committer: Pengcheng Xiong <pxiong@apache.org>
Committed: Tue Oct 13 10:41:47 2015 -0700

----------------------------------------------------------------------
 .../org/apache/hive/jdbc/TestJdbcDriver2.java   |   28 +-
 .../hive/jdbc/cbo_rp_TestJdbcDriver2.java       | 2419 ++++++++++++++++++
 .../ql/optimizer/ColumnPrunerProcFactory.java   |    9 +-
 .../translator/PlanModifierForASTConv.java      |   11 +
 .../translator/PlanModifierForReturnPath.java   |   26 +
 .../hadoop/hive/ql/parse/CalcitePlanner.java    |   27 +-
 .../hadoop/hive/ql/parse/SemanticAnalyzer.java  |   12 +-
 .../queries/clientpositive/cbo_rp_lineage2.q    |  117 +
 .../clientpositive/cbo_rp_auto_join1.q.out      |  151 +-
 .../cbo_rp_cross_product_check_2.q.out          |   18 +-
 .../clientpositive/cbo_rp_lineage2.q.out        |  677 +++++
 11 files changed, 3363 insertions(+), 132 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hive/blob/c1708ac8/itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestJdbcDriver2.java
----------------------------------------------------------------------
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 3aa6bce..100ad42 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
@@ -1636,7 +1636,7 @@ public class TestJdbcDriver2 {
     assertEquals(meta.getPrecision(12), colRS.getInt("COLUMN_SIZE"));
     assertEquals(meta.getScale(12), colRS.getInt("DECIMAL_DIGITS"));
 
-    assertEquals("_c12", meta.getColumnName(13));
+    assertEquals("c12_1", meta.getColumnName(13));
     assertEquals(Types.INTEGER, meta.getColumnType(13));
     assertEquals("int", meta.getColumnTypeName(13));
     assertEquals(11, meta.getColumnDisplaySize(13));
@@ -1747,6 +1747,32 @@ public class TestJdbcDriver2 {
     }
   }
 
+  @Test
+  public void testResultSetMetaDataDuplicateColumnNames() throws SQLException {
+    Statement stmt = con.createStatement();
+
+    ResultSet res = stmt.executeQuery("select c1 as c2_1, c2, c1*2 from "
+        + dataTypeTableName + " limit 1");
+    ResultSetMetaData meta = res.getMetaData();
+
+    ResultSet colRS = con.getMetaData().getColumns(null, null,
+        dataTypeTableName.toLowerCase(), null);
+
+    assertEquals(3, meta.getColumnCount());
+
+    assertTrue(colRS.next());
+
+    assertEquals("c2_1", meta.getColumnName(1));
+
+    assertTrue(colRS.next());
+
+    assertEquals("c2", meta.getColumnName(2));
+
+    assertTrue(colRS.next());
+
+    assertEquals("c2_2", meta.getColumnName(3));
+
+  }
   // [url] [host] [port] [db]
   private static final String[][] URL_PROPERTIES = new String[][] {
     // binary mode


Mime
View raw message