pvary commented on a change in pull request #2052:
URL: https://github.com/apache/iceberg/pull/2052#discussion_r553877050



##########
File path: 
mr/src/test/java/org/apache/iceberg/mr/hive/TestHiveIcebergStorageHandlerWithEngine.java
##########
@@ -142,29 +164,61 @@ public void testScanTable() throws IOException {
 
     // Adding the ORDER BY clause will cause Hive to spawn a local MR job this 
time.
     List<Object[]> descRows =
-        shell.executeStatement("SELECT first_name, customer_id FROM 
default.customers ORDER BY customer_id DESC");
+            shell.executeStatement("SELECT first_name, customer_id FROM 
default.customers ORDER BY customer_id DESC");
 
     Assert.assertEquals(3, descRows.size());
-    Assert.assertArrayEquals(new Object[] {"Trudy", 2L}, descRows.get(0));
-    Assert.assertArrayEquals(new Object[] {"Bob", 1L}, descRows.get(1));
-    Assert.assertArrayEquals(new Object[] {"Alice", 0L}, descRows.get(2));
+    Assert.assertArrayEquals(new Object[]{"Trudy", 2L}, descRows.get(0));
+    Assert.assertArrayEquals(new Object[]{"Bob", 1L}, descRows.get(1));
+    Assert.assertArrayEquals(new Object[]{"Alice", 0L}, descRows.get(2));
+  }
+
+  @Test
+  public void testSelectedColumnsNoOverlapJoin() throws IOException {
+    testTables.createTable(shell, "products", PRODUCT_SCHEMA, fileFormat, 
PRODUCT_RECORDS);
+    testTables.createTable(shell, "orders", ORDER_SCHEMA, fileFormat, 
ORDER_RECORDS);
+
+    List<Object[]> rows = shell.executeStatement(
+            "SELECT o.order_id, o.customer_id, o.total, p.name " +
+                    "FROM default.orders o JOIN default.products p ON 
o.product_id = p.id ORDER BY o.order_id"
+    );
+
+    Assert.assertEquals(3, rows.size());
+    Assert.assertArrayEquals(new Object[]{100L, 0L, 11.11d, "skirt"}, 
rows.get(0));
+    Assert.assertArrayEquals(new Object[]{101L, 0L, 22.22d, "tee"}, 
rows.get(1));
+    Assert.assertArrayEquals(new Object[]{102L, 1L, 33.33d, "watch"}, 
rows.get(2));
   }
 
   @Test
-  public void testJoinTables() throws IOException {
+  public void testSelectedColumnsOverlapJoin() throws IOException {
     testTables.createTable(shell, "customers", 
HiveIcebergStorageHandlerTestUtils.CUSTOMER_SCHEMA, fileFormat,
-        HiveIcebergStorageHandlerTestUtils.CUSTOMER_RECORDS);
+            HiveIcebergStorageHandlerTestUtils.CUSTOMER_RECORDS);
+    testTables.createTable(shell, "orders", ORDER_SCHEMA, fileFormat, 
ORDER_RECORDS);
+
+    List<Object[]> rows = shell.executeStatement(
+            "SELECT c.first_name, o.order_id " +
+                    "FROM default.orders o JOIN default.customers c ON 
o.customer_id = c.customer_id " +
+                    "ORDER BY o.order_id DESC"
+    );
+
+    Assert.assertEquals(3, rows.size());
+    Assert.assertArrayEquals(new Object[]{"Bob", 102L}, rows.get(0));
+    Assert.assertArrayEquals(new Object[]{"Alice", 101L}, rows.get(1));
+    Assert.assertArrayEquals(new Object[]{"Alice", 100L}, rows.get(2));
+  }
+
+  @Test
+  public void testSelfJoin() throws IOException {
     testTables.createTable(shell, "orders", ORDER_SCHEMA, fileFormat, 
ORDER_RECORDS);
 
     List<Object[]> rows = shell.executeStatement(
-            "SELECT c.customer_id, c.first_name, o.order_id, o.total " +
-                    "FROM default.customers c JOIN default.orders o ON 
c.customer_id = o.customer_id " +
-                    "ORDER BY c.customer_id, o.order_id"
+            "SELECT o1.order_id, o1.customer_id, o1.total " +
+                    "FROM default.orders o1 JOIN default.orders o2 ON 
o1.order_id = o2.order_id ORDER BY o1.order_id"

Review comment:
       Why was this change needed?
   Could you please help?
   Thanks,
   Peter




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to