phoenix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From maryann...@apache.org
Subject [3/4] phoenix git commit: PHOENIX-1844, PHOENIX-1879
Date Wed, 11 Nov 2015 04:06:13 GMT
http://git-wip-us.apache.org/repos/asf/phoenix/blob/50e4406d/phoenix-core/src/it/java/org/apache/phoenix/calcite/CalciteIT.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/calcite/CalciteIT.java b/phoenix-core/src/it/java/org/apache/phoenix/calcite/CalciteIT.java
index b1720cf..2d904ef 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/calcite/CalciteIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/calcite/CalciteIT.java
@@ -398,8 +398,7 @@ public class CalciteIT extends BaseClientManagedTimeIT {
     @Test public void testTableScan() throws Exception {
         start(false).sql("select * from aTable where a_string = 'a'")
                 .explainIs("PhoenixToEnumerableConverter\n" +
-                           "  PhoenixToClientConverter\n" +
-                           "    PhoenixTableScan(table=[[phoenix, ATABLE]], filter=[=($2, 'a')])\n")
+                           "  PhoenixTableScan(table=[[phoenix, ATABLE]], filter=[=($2, 'a')])\n")
                 .resultIs(new Object[][] {
                           {"00D300000000XHP", "00A123122312312", "a"}, 
                           {"00D300000000XHP", "00A223122312312", "a"}, 
@@ -411,9 +410,8 @@ public class CalciteIT extends BaseClientManagedTimeIT {
     @Test public void testProject() throws Exception {
         start(false).sql("select entity_id, a_string, organization_id from aTable where a_string = 'a'")
                 .explainIs("PhoenixToEnumerableConverter\n" +
-                           "  PhoenixToClientConverter\n" +
-                           "    PhoenixServerProject(ENTITY_ID=[$1], A_STRING=[$2], ORGANIZATION_ID=[$0])\n" +
-                           "      PhoenixTableScan(table=[[phoenix, ATABLE]], filter=[=($2, 'a')])\n")
+                           "  PhoenixServerProject(ENTITY_ID=[$1], A_STRING=[$2], ORGANIZATION_ID=[$0])\n" +
+                           "    PhoenixTableScan(table=[[phoenix, ATABLE]], filter=[=($2, 'a')])\n")
                 .resultIs(new Object[][] {
                           {"00A123122312312", "a", "00D300000000XHP"}, 
                           {"00A223122312312", "a", "00D300000000XHP"}, 
@@ -426,13 +424,11 @@ public class CalciteIT extends BaseClientManagedTimeIT {
         start(false).sql("select t1.entity_id, t2.a_string, t1.organization_id from aTable t1 join aTable t2 on t1.entity_id = t2.entity_id and t1.organization_id = t2.organization_id where t1.a_string = 'a'") 
                 .explainIs("PhoenixToEnumerableConverter\n" +
                            "  PhoenixClientProject(ENTITY_ID=[$4], A_STRING=[$2], ORGANIZATION_ID=[$3])\n" +
-                           "    PhoenixToClientConverter\n" +
-                           "      PhoenixServerJoin(condition=[AND(=($4, $1), =($3, $0))], joinType=[inner])\n" +
-                           "        PhoenixServerProject(ORGANIZATION_ID=[$0], ENTITY_ID=[$1], A_STRING=[$2])\n" +
-                           "          PhoenixTableScan(table=[[phoenix, ATABLE]])\n" +
-                           "        PhoenixToClientConverter\n" +
-                           "          PhoenixServerProject(ORGANIZATION_ID=[$0], ENTITY_ID=[$1], A_STRING=[$2])\n" +
-                           "            PhoenixTableScan(table=[[phoenix, ATABLE]], filter=[=($2, 'a')])\n")
+                           "    PhoenixServerJoin(condition=[AND(=($4, $1), =($3, $0))], joinType=[inner])\n" +
+                           "      PhoenixServerProject(ORGANIZATION_ID=[$0], ENTITY_ID=[$1], A_STRING=[$2])\n" +
+                           "        PhoenixTableScan(table=[[phoenix, ATABLE]])\n" +
+                           "      PhoenixServerProject(ORGANIZATION_ID=[$0], ENTITY_ID=[$1], A_STRING=[$2])\n" +
+                           "        PhoenixTableScan(table=[[phoenix, ATABLE]], filter=[=($2, 'a')])\n")
                 .resultIs(new Object[][] {
                           {"00A123122312312", "a", "00D300000000XHP"}, 
                           {"00A223122312312", "a", "00D300000000XHP"}, 
@@ -443,13 +439,11 @@ public class CalciteIT extends BaseClientManagedTimeIT {
         start(false).sql("SELECT item.\"item_id\", item.name, supp.\"supplier_id\", supp.name FROM " + JOIN_ITEM_TABLE_FULL_NAME + " item JOIN " + JOIN_SUPPLIER_TABLE_FULL_NAME + " supp ON item.\"supplier_id\" = supp.\"supplier_id\"")
                 .explainIs("PhoenixToEnumerableConverter\n" +
                            "  PhoenixClientProject(item_id=[$0], NAME=[$1], supplier_id=[$3], NAME0=[$4])\n" +
-                           "    PhoenixToClientConverter\n" +
-                           "      PhoenixServerJoin(condition=[=($2, $3)], joinType=[inner])\n" +
-                           "        PhoenixServerProject(item_id=[$0], NAME=[$1], supplier_id=[$5])\n" +
-                           "          PhoenixTableScan(table=[[phoenix, Join, ItemTable]])\n" +
-                           "        PhoenixToClientConverter\n" +
-                           "          PhoenixServerProject(supplier_id=[$0], NAME=[$1])\n" +
-                           "            PhoenixTableScan(table=[[phoenix, Join, SupplierTable]])\n")
+                           "    PhoenixServerJoin(condition=[=($2, $3)], joinType=[inner])\n" +
+                           "      PhoenixServerProject(item_id=[$0], NAME=[$1], supplier_id=[$5])\n" +
+                           "        PhoenixTableScan(table=[[phoenix, Join, ItemTable]])\n" +
+                           "      PhoenixServerProject(supplier_id=[$0], NAME=[$1])\n" +
+                           "        PhoenixTableScan(table=[[phoenix, Join, SupplierTable]])\n")
                 .resultIs(new Object[][] {
                           {"0000000001", "T1", "0000000001", "S1"}, 
                           {"0000000002", "T2", "0000000001", "S1"}, 
@@ -462,12 +456,10 @@ public class CalciteIT extends BaseClientManagedTimeIT {
         start(false).sql("SELECT * FROM " + JOIN_ITEM_TABLE_FULL_NAME + " item JOIN " + JOIN_SUPPLIER_TABLE_FULL_NAME + " supp ON item.\"supplier_id\" = supp.\"supplier_id\" AND supp.name = 'S5'")
                 .explainIs("PhoenixToEnumerableConverter\n" +
                            "  PhoenixClientProject(item_id=[$0], NAME=[$1], PRICE=[$2], DISCOUNT1=[$3], DISCOUNT2=[$4], supplier_id=[$5], DESCRIPTION=[$6], supplier_id0=[$7], NAME0=[$8], PHONE=[$9], ADDRESS=[$10], LOC_ID=[$11])\n" +
-                           "    PhoenixToClientConverter\n" +
-                           "      PhoenixServerJoin(condition=[=($5, $7)], joinType=[inner])\n" +
-                           "        PhoenixTableScan(table=[[phoenix, Join, ItemTable]])\n" +
-                           "        PhoenixToClientConverter\n" +
-                           "          PhoenixServerProject(supplier_id=[$0], NAME=[$1], PHONE=[$2], ADDRESS=[$3], LOC_ID=[$4], NAME5=[CAST($1):VARCHAR(2) CHARACTER SET \"ISO-8859-1\" COLLATE \"ISO-8859-1$en_US$primary\"])\n" +
-                           "            PhoenixTableScan(table=[[phoenix, Join, SupplierTable]], filter=[=(CAST($1):VARCHAR(2) CHARACTER SET \"ISO-8859-1\" COLLATE \"ISO-8859-1$en_US$primary\", 'S5')])\n")
+                           "    PhoenixServerJoin(condition=[=($5, $7)], joinType=[inner])\n" +
+                           "      PhoenixTableScan(table=[[phoenix, Join, ItemTable]])\n" +
+                           "      PhoenixServerProject(supplier_id=[$0], NAME=[$1], PHONE=[$2], ADDRESS=[$3], LOC_ID=[$4], NAME5=[CAST($1):VARCHAR(2) CHARACTER SET \"ISO-8859-1\" COLLATE \"ISO-8859-1$en_US$primary\"])\n" +
+                           "        PhoenixTableScan(table=[[phoenix, Join, SupplierTable]], filter=[=(CAST($1):VARCHAR(2) CHARACTER SET \"ISO-8859-1\" COLLATE \"ISO-8859-1$en_US$primary\", 'S5')])\n")
                 .resultIs(new Object[][] {
                           {"0000000005", "T5", 500, 8, 15, "0000000005", "Item T5", "0000000005", "S5", "888-888-5555", "505 YYY Street", "10005"}})
                 .close();
@@ -476,13 +468,11 @@ public class CalciteIT extends BaseClientManagedTimeIT {
                 + JOIN_ITEM_TABLE_FULL_NAME + " i ON o.\"item_id\" = i.\"item_id\" AND o.price = (i.price * (100 - discount2)) / 100.0 WHERE quantity < 5000")
                 .explainIs("PhoenixToEnumerableConverter\n" +
                            "  PhoenixClientProject(order_id=[$5], NAME=[$1], PRICE=[$2], DISCOUNT2=[$3], QUANTITY=[$7])\n" +
-                           "    PhoenixToClientConverter\n" +
-                           "      PhoenixServerJoin(condition=[AND(=($6, $0), =($8, $4))], joinType=[inner])\n" +
-                           "        PhoenixServerProject(item_id=[$0], NAME=[$1], PRICE=[$2], DISCOUNT2=[$4], $f7=[/(*($2, -(100, $4)), 100.0)])\n" +
-                           "          PhoenixTableScan(table=[[phoenix, Join, ItemTable]])\n" +
-                           "        PhoenixToClientConverter\n" +
-                           "          PhoenixServerProject(order_id=[$0], item_id=[$2], QUANTITY=[$4], PRICE7=[CAST($3):DECIMAL(17, 6)])\n" +
-                           "            PhoenixTableScan(table=[[phoenix, Join, OrderTable]], filter=[<($4, 5000)])\n")
+                           "    PhoenixServerJoin(condition=[AND(=($6, $0), =($8, $4))], joinType=[inner])\n" +
+                           "      PhoenixServerProject(item_id=[$0], NAME=[$1], PRICE=[$2], DISCOUNT2=[$4], $f7=[/(*($2, -(100, $4)), 100.0)])\n" +
+                           "        PhoenixTableScan(table=[[phoenix, Join, ItemTable]])\n" +
+                           "      PhoenixServerProject(order_id=[$0], item_id=[$2], QUANTITY=[$4], PRICE7=[CAST($3):DECIMAL(17, 6)])\n" +
+                           "        PhoenixTableScan(table=[[phoenix, Join, OrderTable]], filter=[<($4, 5000)])\n")
                 .resultIs(new Object[][] {
                           {"000000000000004", "T6", 600, 15, 4000}})
                 .close();
@@ -492,13 +482,11 @@ public class CalciteIT extends BaseClientManagedTimeIT {
         start(false).sql("SELECT item.\"item_id\", item.name, supp.\"supplier_id\", supp.name FROM " + JOIN_ITEM_TABLE_FULL_NAME + " item RIGHT OUTER JOIN " + JOIN_SUPPLIER_TABLE_FULL_NAME + " supp ON item.\"supplier_id\" = supp.\"supplier_id\"")
                 .explainIs("PhoenixToEnumerableConverter\n" +
                            "  PhoenixClientProject(item_id=[$2], NAME=[$3], supplier_id=[$0], NAME0=[$1])\n" +
-                           "    PhoenixToClientConverter\n" +
-                           "      PhoenixServerJoin(condition=[=($4, $0)], joinType=[left])\n" +
-                           "        PhoenixServerProject(supplier_id=[$0], NAME=[$1])\n" +
-                           "          PhoenixTableScan(table=[[phoenix, Join, SupplierTable]])\n" +
-                           "        PhoenixToClientConverter\n" +
-                           "          PhoenixServerProject(item_id=[$0], NAME=[$1], supplier_id=[$5])\n" +
-                           "            PhoenixTableScan(table=[[phoenix, Join, ItemTable]])\n")
+                           "    PhoenixServerJoin(condition=[=($4, $0)], joinType=[left])\n" +
+                           "      PhoenixServerProject(supplier_id=[$0], NAME=[$1])\n" +
+                           "        PhoenixTableScan(table=[[phoenix, Join, SupplierTable]])\n" +
+                           "      PhoenixServerProject(item_id=[$0], NAME=[$1], supplier_id=[$5])\n" +
+                           "        PhoenixTableScan(table=[[phoenix, Join, ItemTable]])\n")
                 .resultIs(new Object[][] {
                           {"0000000001", "T1", "0000000001", "S1"}, 
                           {"0000000002", "T2", "0000000001", "S1"}, 
@@ -520,9 +508,8 @@ public class CalciteIT extends BaseClientManagedTimeIT {
                            "        PhoenixServerSort(sort0=[$2], dir0=[ASC])\n" +
                            "          PhoenixServerProject(item_id=[$0], NAME=[$1], supplier_id=[$5])\n" +
                            "            PhoenixTableScan(table=[[phoenix, Join, ItemTable]])\n" +
-                           "        PhoenixToClientConverter\n" +
-                           "          PhoenixServerProject(supplier_id=[$0], NAME=[$1])\n" +
-                           "            PhoenixTableScan(table=[[phoenix, Join, SupplierTable]])\n")
+                           "        PhoenixServerProject(supplier_id=[$0], NAME=[$1])\n" +
+                           "          PhoenixTableScan(table=[[phoenix, Join, SupplierTable]], scanOrder=[FORWARD])\n")
                 .resultIs(new Object[][] {
                         {null, null, "0000000003", "S3"},
                         {null, null, "0000000004", "S4"},
@@ -539,12 +526,10 @@ public class CalciteIT extends BaseClientManagedTimeIT {
                 .explainIs("PhoenixToEnumerableConverter\n" +
                            "  PhoenixClientProject(ENTITY_ID=[$1], A_STRING=[$4], ORGANIZATION_ID=[$0])\n" +
                            "    PhoenixClientJoin(condition=[AND(=($0, $2), =($1, $3))], joinType=[inner])\n" +
-                           "      PhoenixToClientConverter\n" +
-                           "        PhoenixServerProject(ORGANIZATION_ID=[$0], ENTITY_ID=[$1])\n" +
-                           "          PhoenixTableScan(table=[[phoenix, ATABLE]])\n" +
-                           "      PhoenixToClientConverter\n" +
-                           "        PhoenixServerProject(ORGANIZATION_ID=[$0], ENTITY_ID=[$1], A_STRING=[$2])\n" +
-                           "          PhoenixTableScan(table=[[phoenix, ATABLE]])\n")
+                           "      PhoenixServerProject(ORGANIZATION_ID=[$0], ENTITY_ID=[$1])\n" +
+                           "        PhoenixTableScan(table=[[phoenix, ATABLE]], scanOrder=[FORWARD])\n" +
+                           "      PhoenixServerProject(ORGANIZATION_ID=[$0], ENTITY_ID=[$1], A_STRING=[$2])\n" +
+                           "        PhoenixTableScan(table=[[phoenix, ATABLE]], scanOrder=[FORWARD])\n")
                 .resultIs(new Object[][] {
                           {"00A123122312312", "a", "00D300000000XHP"},
                           {"00A223122312312", "a", "00D300000000XHP"},
@@ -563,13 +548,22 @@ public class CalciteIT extends BaseClientManagedTimeIT {
         start(false).sql("SELECT item.\"item_id\", item.name, supp.\"supplier_id\", supp.name FROM " + JOIN_ITEM_TABLE_FULL_NAME + " item JOIN " + JOIN_SUPPLIER_TABLE_FULL_NAME + " supp ON item.\"supplier_id\" = supp.\"supplier_id\" order by supp.\"supplier_id\"")
                 .explainIs("PhoenixToEnumerableConverter\n" +
                            "  PhoenixClientProject(item_id=[$2], NAME=[$3], supplier_id=[$0], NAME0=[$1])\n" +
-                           "    PhoenixToClientConverter\n" +
-                           "      PhoenixServerJoin(condition=[=($4, $0)], joinType=[inner])\n" +
-                           "        PhoenixServerProject(supplier_id=[$0], NAME=[$1])\n" +
-                           "          PhoenixTableScan(table=[[phoenix, Join, SupplierTable]])\n" +
-                           "        PhoenixToClientConverter\n" +
-                           "          PhoenixServerProject(item_id=[$0], NAME=[$1], supplier_id=[$5])\n" +
-                           "            PhoenixTableScan(table=[[phoenix, Join, ItemTable]])\n")
+                           "    PhoenixServerJoin(condition=[=($4, $0)], joinType=[inner])\n" +
+                           "      PhoenixServerProject(supplier_id=[$0], NAME=[$1])\n" +
+                           "        PhoenixTableScan(table=[[phoenix, Join, SupplierTable]], scanOrder=[FORWARD])\n" +
+                           "      PhoenixServerProject(item_id=[$0], NAME=[$1], supplier_id=[$5])\n" +
+                           "        PhoenixTableScan(table=[[phoenix, Join, ItemTable]])\n")
+                .close();
+        
+        // Server-join with LHS reversely sorted on order-by fields
+        start(false).sql("SELECT item.\"item_id\", item.name, supp.\"supplier_id\", supp.name FROM " + JOIN_ITEM_TABLE_FULL_NAME + " item JOIN " + JOIN_SUPPLIER_TABLE_FULL_NAME + " supp ON item.\"supplier_id\" = supp.\"supplier_id\" order by supp.\"supplier_id\" DESC")
+                .explainIs("PhoenixToEnumerableConverter\n" +
+                           "  PhoenixClientProject(item_id=[$2], NAME=[$3], supplier_id=[$0], NAME0=[$1])\n" +
+                           "    PhoenixServerJoin(condition=[=($4, $0)], joinType=[inner])\n" +
+                           "      PhoenixServerProject(supplier_id=[$0], NAME=[$1])\n" +
+                           "        PhoenixTableScan(table=[[phoenix, Join, SupplierTable]], scanOrder=[REVERSE])\n" +
+                           "      PhoenixServerProject(item_id=[$0], NAME=[$1], supplier_id=[$5])\n" +
+                           "        PhoenixTableScan(table=[[phoenix, Join, ItemTable]])\n")
                 .close();
         
         // Join key being order-by fields with the other side sorted on order-by fields
@@ -580,9 +574,8 @@ public class CalciteIT extends BaseClientManagedTimeIT {
                            "      PhoenixServerSort(sort0=[$2], dir0=[ASC])\n" +
                            "        PhoenixServerProject(item_id=[$0], NAME=[$1], supplier_id=[$5])\n" +
                            "          PhoenixTableScan(table=[[phoenix, Join, ItemTable]])\n" +
-                           "      PhoenixToClientConverter\n" +
-                           "        PhoenixServerProject(supplier_id=[$0], NAME=[$1])\n" +
-                           "          PhoenixTableScan(table=[[phoenix, Join, SupplierTable]])\n")
+                           "      PhoenixServerProject(supplier_id=[$0], NAME=[$1])\n" +
+                           "        PhoenixTableScan(table=[[phoenix, Join, SupplierTable]], scanOrder=[FORWARD])\n")
                 .close();
         
         start(false).sql("SELECT \"order_id\", i.name, i.price, discount2, quantity FROM " + JOIN_ORDER_TABLE_FULL_NAME + " o LEFT JOIN " 
@@ -593,12 +586,10 @@ public class CalciteIT extends BaseClientManagedTimeIT {
                 		   "      PhoenixClientJoin(condition=[=($1, $3)], joinType=[left])\n" +
                 		   "        PhoenixClientSort(sort0=[$1], dir0=[ASC])\n" +
                 		   "          PhoenixLimit(fetch=[2])\n" +
-                		   "            PhoenixToClientConverter\n" +
-                		   "              PhoenixServerProject(order_id=[$0], item_id=[$2], QUANTITY=[$4])\n" +
-                		   "                PhoenixTableScan(table=[[phoenix, Join, OrderTable]])\n" +
-                		   "        PhoenixToClientConverter\n" +
-                		   "          PhoenixServerProject(item_id=[$0], NAME=[$1], PRICE=[$2], DISCOUNT2=[$4])\n" +
-                		   "            PhoenixTableScan(table=[[phoenix, Join, ItemTable]])\n")
+                		   "            PhoenixServerProject(order_id=[$0], item_id=[$2], QUANTITY=[$4])\n" +
+                		   "              PhoenixTableScan(table=[[phoenix, Join, OrderTable]])\n" +
+                		   "        PhoenixServerProject(item_id=[$0], NAME=[$1], PRICE=[$2], DISCOUNT2=[$4])\n" +
+                		   "          PhoenixTableScan(table=[[phoenix, Join, ItemTable]], scanOrder=[FORWARD])\n")
                 .close();
     }
     
@@ -606,15 +597,12 @@ public class CalciteIT extends BaseClientManagedTimeIT {
         start(false).sql("select t1.entity_id, t2.a_string, t3.organization_id from aTable t1 join aTable t2 on t1.entity_id = t2.entity_id and t1.organization_id = t2.organization_id join atable t3 on t1.entity_id = t3.entity_id and t1.organization_id = t3.organization_id where t1.a_string = 'a'") 
                 .explainIs("PhoenixToEnumerableConverter\n" +
                            "  PhoenixClientProject(ENTITY_ID=[$19], A_STRING=[$38], ORGANIZATION_ID=[$0])\n" +
-                           "    PhoenixToClientConverter\n" +
-                           "      PhoenixServerJoin(condition=[AND(=($19, $1), =($18, $0))], joinType=[inner])\n" +
-                           "        PhoenixTableScan(table=[[phoenix, ATABLE]])\n" +
-                           "        PhoenixClientProject(ORGANIZATION_ID=[$18], ENTITY_ID=[$19], A_STRING=[$20], B_STRING=[$21], A_INTEGER=[$22], A_DATE=[$23], A_TIME=[$24], A_TIMESTAMP=[$25], X_DECIMAL=[$26], X_LONG=[$27], X_INTEGER=[$28], Y_INTEGER=[$29], A_BYTE=[$30], A_SHORT=[$31], A_FLOAT=[$32], A_DOUBLE=[$33], A_UNSIGNED_FLOAT=[$34], A_UNSIGNED_DOUBLE=[$35], ORGANIZATION_ID0=[$0], ENTITY_ID0=[$1], A_STRING0=[$2], B_STRING0=[$3], A_INTEGER0=[$4], A_DATE0=[$5], A_TIME0=[$6], A_TIMESTAMP0=[$7], X_DECIMAL0=[$8], X_LONG0=[$9], X_INTEGER0=[$10], Y_INTEGER0=[$11], A_BYTE0=[$12], A_SHORT0=[$13], A_FLOAT0=[$14], A_DOUBLE0=[$15], A_UNSIGNED_FLOAT0=[$16], A_UNSIGNED_DOUBLE0=[$17])\n" +
-                           "          PhoenixToClientConverter\n" +
-                           "            PhoenixServerJoin(condition=[AND(=($19, $1), =($18, $0))], joinType=[inner])\n" +
-                           "              PhoenixTableScan(table=[[phoenix, ATABLE]])\n" +
-                           "              PhoenixToClientConverter\n" +
-                           "                PhoenixTableScan(table=[[phoenix, ATABLE]], filter=[=($2, 'a')])\n")
+                           "    PhoenixServerJoin(condition=[AND(=($19, $1), =($18, $0))], joinType=[inner])\n" +
+                           "      PhoenixTableScan(table=[[phoenix, ATABLE]])\n" +
+                           "      PhoenixClientProject(ORGANIZATION_ID=[$18], ENTITY_ID=[$19], A_STRING=[$20], B_STRING=[$21], A_INTEGER=[$22], A_DATE=[$23], A_TIME=[$24], A_TIMESTAMP=[$25], X_DECIMAL=[$26], X_LONG=[$27], X_INTEGER=[$28], Y_INTEGER=[$29], A_BYTE=[$30], A_SHORT=[$31], A_FLOAT=[$32], A_DOUBLE=[$33], A_UNSIGNED_FLOAT=[$34], A_UNSIGNED_DOUBLE=[$35], ORGANIZATION_ID0=[$0], ENTITY_ID0=[$1], A_STRING0=[$2], B_STRING0=[$3], A_INTEGER0=[$4], A_DATE0=[$5], A_TIME0=[$6], A_TIMESTAMP0=[$7], X_DECIMAL0=[$8], X_LONG0=[$9], X_INTEGER0=[$10], Y_INTEGER0=[$11], A_BYTE0=[$12], A_SHORT0=[$13], A_FLOAT0=[$14], A_DOUBLE0=[$15], A_UNSIGNED_FLOAT0=[$16], A_UNSIGNED_DOUBLE0=[$17])\n" +
+                           "        PhoenixServerJoin(condition=[AND(=($19, $1), =($18, $0))], joinType=[inner])\n" +
+                           "          PhoenixTableScan(table=[[phoenix, ATABLE]])\n" +
+                           "          PhoenixTableScan(table=[[phoenix, ATABLE]], filter=[=($2, 'a')])\n")
                 .resultIs(new Object[][] {
                           {"00A123122312312", "a", "00D300000000XHP"}, 
                           {"00A223122312312", "a", "00D300000000XHP"}, 
@@ -625,14 +613,11 @@ public class CalciteIT extends BaseClientManagedTimeIT {
         start(false).sql("select t1.entity_id, t2.a_string, t3.organization_id from aTable t1 join aTable t2 on t1.entity_id = t2.entity_id and t1.organization_id = t2.organization_id join atable t3 on t1.entity_id = t3.entity_id and t1.organization_id = t3.organization_id")
                 .explainIs("PhoenixToEnumerableConverter\n" +
                            "  PhoenixClientProject(ENTITY_ID=[$19], A_STRING=[$2], ORGANIZATION_ID=[$36])\n" +
-                           "    PhoenixToClientConverter\n" +
-                           "      PhoenixServerJoin(condition=[AND(=($19, $1), =($18, $0))], joinType=[inner])\n" +
+                           "    PhoenixServerJoin(condition=[AND(=($19, $1), =($18, $0))], joinType=[inner])\n" +
+                           "      PhoenixTableScan(table=[[phoenix, ATABLE]])\n" +
+                           "      PhoenixServerJoin(condition=[AND(=($1, $19), =($0, $18))], joinType=[inner])\n" +
                            "        PhoenixTableScan(table=[[phoenix, ATABLE]])\n" +
-                           "        PhoenixToClientConverter\n" +
-                           "          PhoenixServerJoin(condition=[AND(=($1, $19), =($0, $18))], joinType=[inner])\n" +
-                           "            PhoenixTableScan(table=[[phoenix, ATABLE]])\n" +
-                           "            PhoenixToClientConverter\n" +
-                           "              PhoenixTableScan(table=[[phoenix, ATABLE]])\n")
+                           "        PhoenixTableScan(table=[[phoenix, ATABLE]])\n")
                 .resultIs(new Object[][] {
                           {"00A123122312312", "a", "00D300000000XHP"},
                           {"00A223122312312", "a", "00D300000000XHP"},
@@ -658,15 +643,15 @@ public class CalciteIT extends BaseClientManagedTimeIT {
         start(false).sql("select organization_id, count(b_string) from atable group by organization_id")
                 .explainIs("PhoenixToEnumerableConverter\n" +
                            "  PhoenixServerAggregate(group=[{0}], EXPR$1=[COUNT($3)], isOrdered=[true])\n" +
-                           "    PhoenixTableScan(table=[[phoenix, ATABLE]])\n")
+                           "    PhoenixTableScan(table=[[phoenix, ATABLE]], scanOrder=[FORWARD])\n")
                 .resultIs(new Object[][] {
                           {"00D300000000XHP", 9L}})
                 .close();
         
-        start(false).sql("select organization_id, entity_id, count(b_string) from atable group by organization_id, entity_id")
+        start(false).sql("select organization_id, entity_id, count(b_string) from atable group by entity_id ,organization_id")
                 .explainIs("PhoenixToEnumerableConverter\n" +
                            "  PhoenixServerAggregate(group=[{0, 1}], EXPR$2=[COUNT($3)], isOrdered=[true])\n" +
-                           "    PhoenixTableScan(table=[[phoenix, ATABLE]])\n")
+                           "    PhoenixTableScan(table=[[phoenix, ATABLE]], scanOrder=[FORWARD])\n")
                 .resultIs(new Object[][] {
                           {"00D300000000XHP", "00A123122312312", 1L}, 
                           {"00D300000000XHP", "00A223122312312", 1L}, 
@@ -718,13 +703,12 @@ public class CalciteIT extends BaseClientManagedTimeIT {
         
         start(false).sql("select s.name, count(\"item_id\") from " + JOIN_SUPPLIER_TABLE_FULL_NAME + " s join " + JOIN_ITEM_TABLE_FULL_NAME + " i on s.\"supplier_id\" = i.\"supplier_id\" group by s.name")
                 .explainIs("PhoenixToEnumerableConverter\n" +
-                           "  PhoenixServerAggregate(group=[{3}], EXPR$1=[COUNT()], isOrdered=[false])\n" +
-                           "    PhoenixServerJoin(condition=[=($2, $1)], joinType=[inner])\n" +
-                           "      PhoenixServerProject(item_id=[$0], supplier_id=[$5])\n" +
+                           "  PhoenixServerAggregate(group=[{2}], EXPR$1=[COUNT()], isOrdered=[false])\n" +
+                           "    PhoenixServerJoin(condition=[=($1, $0)], joinType=[inner])\n" +
+                           "      PhoenixServerProject(supplier_id=[$5])\n" +
                            "        PhoenixTableScan(table=[[phoenix, Join, ItemTable]])\n" +
-                           "      PhoenixToClientConverter\n" +
-                           "        PhoenixServerProject(supplier_id=[$0], NAME=[$1])\n" +
-                           "          PhoenixTableScan(table=[[phoenix, Join, SupplierTable]])\n")
+                           "      PhoenixServerProject(supplier_id=[$0], NAME=[$1])\n" +
+                           "        PhoenixTableScan(table=[[phoenix, Join, SupplierTable]])\n")
                 .resultIs(new Object[][] {
                           {"S1", 2L},
                           {"S2", 2L},
@@ -736,12 +720,11 @@ public class CalciteIT extends BaseClientManagedTimeIT {
         start(false).sql("select s.\"supplier_id\", count(*) from " + JOIN_SUPPLIER_TABLE_FULL_NAME + " s join " + JOIN_ITEM_TABLE_FULL_NAME + " i on s.\"supplier_id\" = i.\"supplier_id\" group by s.\"supplier_id\"")
                 .explainIs("PhoenixToEnumerableConverter\n" +
                            "  PhoenixServerAggregate(group=[{0}], EXPR$1=[COUNT()], isOrdered=[true])\n" +
-                           "    PhoenixServerJoin(condition=[=($0, $2)], joinType=[inner])\n" +
+                           "    PhoenixServerJoin(condition=[=($0, $1)], joinType=[inner])\n" +
                            "      PhoenixServerProject(supplier_id=[$0])\n" +
-                           "        PhoenixTableScan(table=[[phoenix, Join, SupplierTable]])\n" +
-                           "      PhoenixToClientConverter\n" +
-                           "        PhoenixServerProject(item_id=[$0], supplier_id=[$5])\n" +
-                           "          PhoenixTableScan(table=[[phoenix, Join, ItemTable]])\n")
+                           "        PhoenixTableScan(table=[[phoenix, Join, SupplierTable]], scanOrder=[FORWARD])\n" +
+                           "      PhoenixServerProject(supplier_id=[$5])\n" +
+                           "        PhoenixTableScan(table=[[phoenix, Join, ItemTable]])\n")
                 .resultIs(new Object[][] {
                           {"0000000001", 2L},
                           {"0000000002", 2L},
@@ -763,7 +746,7 @@ public class CalciteIT extends BaseClientManagedTimeIT {
                 .explainIs("PhoenixToEnumerableConverter\n" +
                            "  PhoenixClientProject(MYPK0=[$0], EXPR$1=[CAST(/($1, $2)):INTEGER NOT NULL])\n" +
                            "    PhoenixServerAggregate(group=[{0}], agg#0=[$SUM0($1)], agg#1=[COUNT()], isOrdered=[true])\n" +
-                           "      PhoenixTableScan(table=[[phoenix, SALTED_TEST_TABLE]])\n")
+                           "      PhoenixTableScan(table=[[phoenix, SALTED_TEST_TABLE]], scanOrder=[FORWARD])\n")
                 .resultIs(new Object[][] {
                         {1, 2},
                         {2, 3},
@@ -803,9 +786,8 @@ public class CalciteIT extends BaseClientManagedTimeIT {
         
         start(false).sql("select organization_id, entity_id, a_string from aTable order by organization_id, entity_id")
                 .explainIs("PhoenixToEnumerableConverter\n" +
-                           "  PhoenixToClientConverter\n" +
-                           "    PhoenixServerProject(ORGANIZATION_ID=[$0], ENTITY_ID=[$1], A_STRING=[$2])\n" +
-                           "      PhoenixTableScan(table=[[phoenix, ATABLE]])\n")
+                           "  PhoenixServerProject(ORGANIZATION_ID=[$0], ENTITY_ID=[$1], A_STRING=[$2])\n" +
+                           "    PhoenixTableScan(table=[[phoenix, ATABLE]], scanOrder=[FORWARD])\n")
                 .resultIs(new Object[][] {
                           {"00D300000000XHP", "00A123122312312", "a"}, 
                           {"00D300000000XHP", "00A223122312312", "a"}, 
@@ -818,6 +800,55 @@ public class CalciteIT extends BaseClientManagedTimeIT {
                           {"00D300000000XHP", "00C923122312312", "c"}})
                 .close();
         
+        start(false).sql("select organization_id, entity_id, a_string from aTable order by organization_id DESC")
+                .explainIs("PhoenixToEnumerableConverter\n" +
+                           "  PhoenixServerProject(ORGANIZATION_ID=[$0], ENTITY_ID=[$1], A_STRING=[$2])\n" +
+                           "    PhoenixTableScan(table=[[phoenix, ATABLE]], scanOrder=[REVERSE])\n")
+                .resultIs(new Object[][] {
+                          {"00D300000000XHP", "00C923122312312", "c"},
+                          {"00D300000000XHP", "00B823122312312", "b"}, 
+                          {"00D300000000XHP", "00B723122312312", "b"}, 
+                          {"00D300000000XHP", "00B623122312312", "b"}, 
+                          {"00D300000000XHP", "00B523122312312", "b"}, 
+                          {"00D300000000XHP", "00A423122312312", "a"}, 
+                          {"00D300000000XHP", "00A323122312312", "a"}, 
+                          {"00D300000000XHP", "00A223122312312", "a"}, 
+                          {"00D300000000XHP", "00A123122312312", "a"}})
+                .close();
+        
+        start(false).sql("select organization_id, entity_id, a_string from aTable order by organization_id DESC, entity_id DESC")
+                .explainIs("PhoenixToEnumerableConverter\n" +
+                           "  PhoenixServerProject(ORGANIZATION_ID=[$0], ENTITY_ID=[$1], A_STRING=[$2])\n" +
+                           "    PhoenixTableScan(table=[[phoenix, ATABLE]], scanOrder=[REVERSE])\n")
+                .resultIs(new Object[][] {
+                          {"00D300000000XHP", "00C923122312312", "c"},
+                          {"00D300000000XHP", "00B823122312312", "b"}, 
+                          {"00D300000000XHP", "00B723122312312", "b"}, 
+                          {"00D300000000XHP", "00B623122312312", "b"}, 
+                          {"00D300000000XHP", "00B523122312312", "b"}, 
+                          {"00D300000000XHP", "00A423122312312", "a"}, 
+                          {"00D300000000XHP", "00A323122312312", "a"}, 
+                          {"00D300000000XHP", "00A223122312312", "a"}, 
+                          {"00D300000000XHP", "00A123122312312", "a"}})
+                .close();
+
+        start(false).sql("select organization_id, entity_id, a_string from aTable order by organization_id ASC, entity_id DESC")
+                .explainIs("PhoenixToEnumerableConverter\n" +
+                           "  PhoenixServerSort(sort0=[$0], sort1=[$1], dir0=[ASC], dir1=[DESC])\n" +
+                           "    PhoenixServerProject(ORGANIZATION_ID=[$0], ENTITY_ID=[$1], A_STRING=[$2])\n" +
+                           "      PhoenixTableScan(table=[[phoenix, ATABLE]])\n")
+                .resultIs(new Object[][] {
+                          {"00D300000000XHP", "00C923122312312", "c"},
+                          {"00D300000000XHP", "00B823122312312", "b"}, 
+                          {"00D300000000XHP", "00B723122312312", "b"}, 
+                          {"00D300000000XHP", "00B623122312312", "b"}, 
+                          {"00D300000000XHP", "00B523122312312", "b"}, 
+                          {"00D300000000XHP", "00A423122312312", "a"}, 
+                          {"00D300000000XHP", "00A323122312312", "a"}, 
+                          {"00D300000000XHP", "00A223122312312", "a"}, 
+                          {"00D300000000XHP", "00A123122312312", "a"}})
+                .close();
+        
         start(false).sql("select count(entity_id), a_string from atable group by a_string order by count(entity_id), a_string desc")
                 .explainIs("PhoenixToEnumerableConverter\n" +
                            "  PhoenixClientProject(EXPR$0=[$1], A_STRING=[$0])\n" +
@@ -833,13 +864,12 @@ public class CalciteIT extends BaseClientManagedTimeIT {
         start(false).sql("select s.name, count(\"item_id\") from " + JOIN_SUPPLIER_TABLE_FULL_NAME + " s join " + JOIN_ITEM_TABLE_FULL_NAME + " i on s.\"supplier_id\" = i.\"supplier_id\" group by s.name order by count(\"item_id\"), s.name desc")
                 .explainIs("PhoenixToEnumerableConverter\n" +
                            "  PhoenixCompactClientSort(sort0=[$1], sort1=[$0], dir0=[ASC], dir1=[DESC])\n" +
-                           "    PhoenixServerAggregate(group=[{3}], EXPR$1=[COUNT()], isOrdered=[false])\n" +
-                           "      PhoenixServerJoin(condition=[=($2, $1)], joinType=[inner])\n" +
-                           "        PhoenixServerProject(item_id=[$0], supplier_id=[$5])\n" +
+                           "    PhoenixServerAggregate(group=[{2}], EXPR$1=[COUNT()], isOrdered=[false])\n" +
+                           "      PhoenixServerJoin(condition=[=($1, $0)], joinType=[inner])\n" +
+                           "        PhoenixServerProject(supplier_id=[$5])\n" +
                            "          PhoenixTableScan(table=[[phoenix, Join, ItemTable]])\n" +
-                           "        PhoenixToClientConverter\n" +
-                           "          PhoenixServerProject(supplier_id=[$0], NAME=[$1])\n" +
-                           "            PhoenixTableScan(table=[[phoenix, Join, SupplierTable]])\n")
+                           "        PhoenixServerProject(supplier_id=[$0], NAME=[$1])\n" +
+                           "          PhoenixTableScan(table=[[phoenix, Join, SupplierTable]])\n")
                 .resultIs(new Object[][] {
                           {"S6", 1L},
                           {"S5", 1L},
@@ -854,9 +884,8 @@ public class CalciteIT extends BaseClientManagedTimeIT {
                            "      PhoenixServerJoin(condition=[=($2, $3)], joinType=[inner])\n" +
                            "        PhoenixServerProject(item_id=[$0], NAME=[$1], supplier_id=[$5])\n" +
                            "          PhoenixTableScan(table=[[phoenix, Join, ItemTable]])\n" +
-                           "        PhoenixToClientConverter\n" +
-                           "          PhoenixServerProject(supplier_id=[$0], NAME=[$1])\n" +
-                           "            PhoenixTableScan(table=[[phoenix, Join, SupplierTable]])\n")
+                           "        PhoenixServerProject(supplier_id=[$0], NAME=[$1])\n" +
+                           "          PhoenixTableScan(table=[[phoenix, Join, SupplierTable]])\n")
                 .resultIs(new Object[][] {
                           {"0000000006", "T6", "0000000006", "S6"}, 
                           {"0000000005", "T5", "0000000005", "S5"}, 
@@ -885,9 +914,8 @@ public class CalciteIT extends BaseClientManagedTimeIT {
         start(false).sql("select organization_id, entity_id, a_string from aTable order by organization_id, entity_id limit 5")
                 .explainIs("PhoenixToEnumerableConverter\n" +
                            "  PhoenixLimit(fetch=[5])\n" +
-                           "    PhoenixToClientConverter\n" +
-                           "      PhoenixServerProject(ORGANIZATION_ID=[$0], ENTITY_ID=[$1], A_STRING=[$2])\n" +
-                           "        PhoenixTableScan(table=[[phoenix, ATABLE]])\n")
+                           "    PhoenixServerProject(ORGANIZATION_ID=[$0], ENTITY_ID=[$1], A_STRING=[$2])\n" +
+                           "      PhoenixTableScan(table=[[phoenix, ATABLE]], scanOrder=[FORWARD])\n")
                 .resultIs(new Object[][] {
                           {"00D300000000XHP", "00A123122312312", "a"}, 
                           {"00D300000000XHP", "00A223122312312", "a"}, 
@@ -896,6 +924,46 @@ public class CalciteIT extends BaseClientManagedTimeIT {
                           {"00D300000000XHP", "00B523122312312", "b"}})
                 .close();
         
+        start(false).sql("select organization_id, entity_id, a_string from aTable order by organization_id DESC limit 5")
+                .explainIs("PhoenixToEnumerableConverter\n" +
+                           "  PhoenixLimit(fetch=[5])\n" +
+                           "    PhoenixServerProject(ORGANIZATION_ID=[$0], ENTITY_ID=[$1], A_STRING=[$2])\n" +
+                           "      PhoenixTableScan(table=[[phoenix, ATABLE]], scanOrder=[REVERSE])\n")
+                .resultIs(new Object[][] {
+                          {"00D300000000XHP", "00C923122312312", "c"},
+                          {"00D300000000XHP", "00B823122312312", "b"}, 
+                          {"00D300000000XHP", "00B723122312312", "b"}, 
+                          {"00D300000000XHP", "00B623122312312", "b"}, 
+                          {"00D300000000XHP", "00B523122312312", "b"}})
+                .close();
+        
+        start(false).sql("select organization_id, entity_id, a_string from aTable order by organization_id DESC, entity_id DESC limit 5")
+                .explainIs("PhoenixToEnumerableConverter\n" +
+                           "  PhoenixLimit(fetch=[5])\n" +
+                           "    PhoenixServerProject(ORGANIZATION_ID=[$0], ENTITY_ID=[$1], A_STRING=[$2])\n" +
+                           "      PhoenixTableScan(table=[[phoenix, ATABLE]], scanOrder=[REVERSE])\n")
+                .resultIs(new Object[][] {
+                          {"00D300000000XHP", "00C923122312312", "c"},
+                          {"00D300000000XHP", "00B823122312312", "b"}, 
+                          {"00D300000000XHP", "00B723122312312", "b"}, 
+                          {"00D300000000XHP", "00B623122312312", "b"}, 
+                          {"00D300000000XHP", "00B523122312312", "b"}})
+                .close();
+
+        start(false).sql("select organization_id, entity_id, a_string from aTable order by organization_id ASC, entity_id DESC limit 5")
+                .explainIs("PhoenixToEnumerableConverter\n" +
+                           "  PhoenixLimit(fetch=[5])\n" +
+                           "    PhoenixServerSort(sort0=[$0], sort1=[$1], dir0=[ASC], dir1=[DESC])\n" +
+                           "      PhoenixServerProject(ORGANIZATION_ID=[$0], ENTITY_ID=[$1], A_STRING=[$2])\n" +
+                           "        PhoenixTableScan(table=[[phoenix, ATABLE]])\n")
+                .resultIs(new Object[][] {
+                          {"00D300000000XHP", "00C923122312312", "c"},
+                          {"00D300000000XHP", "00B823122312312", "b"}, 
+                          {"00D300000000XHP", "00B723122312312", "b"}, 
+                          {"00D300000000XHP", "00B623122312312", "b"}, 
+                          {"00D300000000XHP", "00B523122312312", "b"}})
+                .close();
+        
         start(false).sql("select count(entity_id), a_string from atable group by a_string order by count(entity_id), a_string desc limit 2")
                 .explainIs("PhoenixToEnumerableConverter\n" +
                            "  PhoenixClientProject(EXPR$0=[$1], A_STRING=[$0])\n" +
@@ -912,13 +980,12 @@ public class CalciteIT extends BaseClientManagedTimeIT {
                 .explainIs("PhoenixToEnumerableConverter\n" +
                            "  PhoenixLimit(fetch=[3])\n" +
                            "    PhoenixCompactClientSort(sort0=[$1], sort1=[$0], dir0=[ASC], dir1=[DESC])\n" +
-                           "      PhoenixServerAggregate(group=[{3}], EXPR$1=[COUNT()], isOrdered=[false])\n" +
-                           "        PhoenixServerJoin(condition=[=($2, $1)], joinType=[inner])\n" +
-                           "          PhoenixServerProject(item_id=[$0], supplier_id=[$5])\n" +
+                           "      PhoenixServerAggregate(group=[{2}], EXPR$1=[COUNT()], isOrdered=[false])\n" +
+                           "        PhoenixServerJoin(condition=[=($1, $0)], joinType=[inner])\n" +
+                           "          PhoenixServerProject(supplier_id=[$5])\n" +
                            "            PhoenixTableScan(table=[[phoenix, Join, ItemTable]])\n" +
-                           "          PhoenixToClientConverter\n" +
-                           "            PhoenixServerProject(supplier_id=[$0], NAME=[$1])\n" +
-                           "              PhoenixTableScan(table=[[phoenix, Join, SupplierTable]])\n")
+                           "          PhoenixServerProject(supplier_id=[$0], NAME=[$1])\n" +
+                           "            PhoenixTableScan(table=[[phoenix, Join, SupplierTable]])\n")
                 .resultIs(new Object[][] {
                           {"S6", 1L},
                           {"S5", 1L},
@@ -933,9 +1000,8 @@ public class CalciteIT extends BaseClientManagedTimeIT {
                            "        PhoenixServerJoin(condition=[=($2, $3)], joinType=[inner])\n" +
                            "          PhoenixServerProject(item_id=[$0], NAME=[$1], supplier_id=[$5])\n" +
                            "            PhoenixTableScan(table=[[phoenix, Join, ItemTable]])\n" +
-                           "          PhoenixToClientConverter\n" +
-                           "            PhoenixServerProject(supplier_id=[$0], NAME=[$1])\n" +
-                           "              PhoenixTableScan(table=[[phoenix, Join, SupplierTable]])\n")
+                           "          PhoenixServerProject(supplier_id=[$0], NAME=[$1])\n" +
+                           "            PhoenixTableScan(table=[[phoenix, Join, SupplierTable]])\n")
                 .resultIs(new Object[][] {
                           {"0000000006", "T6", "0000000006", "S6"}, 
                           {"0000000005", "T5", "0000000005", "S5"}, 
@@ -947,9 +1013,8 @@ public class CalciteIT extends BaseClientManagedTimeIT {
         start(false).sql("select organization_id, entity_id, a_string from aTable limit 5")
                 .explainIs("PhoenixToEnumerableConverter\n" +
                            "  PhoenixLimit(fetch=[5])\n" +
-                           "    PhoenixToClientConverter\n" +
-                           "      PhoenixServerProject(ORGANIZATION_ID=[$0], ENTITY_ID=[$1], A_STRING=[$2])\n" +
-                           "        PhoenixTableScan(table=[[phoenix, ATABLE]])\n")
+                           "    PhoenixServerProject(ORGANIZATION_ID=[$0], ENTITY_ID=[$1], A_STRING=[$2])\n" +
+                           "      PhoenixTableScan(table=[[phoenix, ATABLE]])\n")
                 .resultIs(new Object[][] {
                           {"00D300000000XHP", "00A123122312312", "a"}, 
                           {"00D300000000XHP", "00A223122312312", "a"}, 
@@ -972,13 +1037,12 @@ public class CalciteIT extends BaseClientManagedTimeIT {
         start(false).sql("select s.name, count(\"item_id\") from " + JOIN_SUPPLIER_TABLE_FULL_NAME + " s join " + JOIN_ITEM_TABLE_FULL_NAME + " i on s.\"supplier_id\" = i.\"supplier_id\" group by s.name limit 3")
                 .explainIs("PhoenixToEnumerableConverter\n" +
                            "  PhoenixLimit(fetch=[3])\n" +
-                           "    PhoenixServerAggregate(group=[{3}], EXPR$1=[COUNT()], isOrdered=[false])\n" +
-                           "      PhoenixServerJoin(condition=[=($2, $1)], joinType=[inner])\n" +
-                           "        PhoenixServerProject(item_id=[$0], supplier_id=[$5])\n" +
+                           "    PhoenixServerAggregate(group=[{2}], EXPR$1=[COUNT()], isOrdered=[false])\n" +
+                           "      PhoenixServerJoin(condition=[=($1, $0)], joinType=[inner])\n" +
+                           "        PhoenixServerProject(supplier_id=[$5])\n" +
                            "          PhoenixTableScan(table=[[phoenix, Join, ItemTable]])\n" +
-                           "        PhoenixToClientConverter\n" +
-                           "          PhoenixServerProject(supplier_id=[$0], NAME=[$1])\n" +
-                           "            PhoenixTableScan(table=[[phoenix, Join, SupplierTable]])\n")
+                           "        PhoenixServerProject(supplier_id=[$0], NAME=[$1])\n" +
+                           "          PhoenixTableScan(table=[[phoenix, Join, SupplierTable]])\n")
                 .resultIs(new Object[][] {
                           {"S1", 2L},
                           {"S2", 2L},
@@ -989,13 +1053,11 @@ public class CalciteIT extends BaseClientManagedTimeIT {
                 .explainIs("PhoenixToEnumerableConverter\n" +
                            "  PhoenixClientProject(item_id=[$0], NAME=[$1], supplier_id=[$3], NAME0=[$4])\n" +
                            "    PhoenixLimit(fetch=[3])\n" +
-                           "      PhoenixToClientConverter\n" +
-                           "        PhoenixServerJoin(condition=[=($2, $3)], joinType=[inner])\n" +
-                           "          PhoenixServerProject(item_id=[$0], NAME=[$1], supplier_id=[$5])\n" +
-                           "            PhoenixTableScan(table=[[phoenix, Join, ItemTable]])\n" +
-                           "          PhoenixToClientConverter\n" +
-                           "            PhoenixServerProject(supplier_id=[$0], NAME=[$1])\n" +
-                           "              PhoenixTableScan(table=[[phoenix, Join, SupplierTable]])\n")
+                           "      PhoenixServerJoin(condition=[=($2, $3)], joinType=[inner])\n" +
+                           "        PhoenixServerProject(item_id=[$0], NAME=[$1], supplier_id=[$5])\n" +
+                           "          PhoenixTableScan(table=[[phoenix, Join, ItemTable]])\n" +
+                           "        PhoenixServerProject(supplier_id=[$0], NAME=[$1])\n" +
+                           "          PhoenixTableScan(table=[[phoenix, Join, SupplierTable]])\n")
                 .resultIs(new Object[][] {
                           {"0000000001", "T1", "0000000001", "S1"}, 
                           {"0000000002", "T2", "0000000001", "S1"}, 
@@ -1017,15 +1079,13 @@ public class CalciteIT extends BaseClientManagedTimeIT {
             + "from " + JOIN_ITEM_TABLE_FULL_NAME + " i")
             .explainIs("PhoenixToEnumerableConverter\n" +
                        "  PhoenixClientProject(item_id=[$0], NAME=[$1], EXPR$2=[$8])\n" +
-                       "    PhoenixToClientConverter\n" +
-                       "      PhoenixServerJoin(condition=[=($0, $7)], joinType=[left], isSingleValueRhs=[true])\n" +
-                       "        PhoenixTableScan(table=[[phoenix, Join, ItemTable]])\n" +
-                       "        PhoenixServerAggregate(group=[{0}], SQ=[MAX($5)], isOrdered=[true])\n" +
-                       "          PhoenixServerJoin(condition=[=($3, $0)], joinType=[inner])\n" +
-                       "            PhoenixServerProject(item_id=[$0])\n" +
-                       "              PhoenixTableScan(table=[[phoenix, Join, ItemTable]])\n" +
-                       "            PhoenixToClientConverter\n" +
-                       "              PhoenixTableScan(table=[[phoenix, Join, OrderTable]])\n")
+                       "    PhoenixServerJoin(condition=[=($0, $7)], joinType=[left], isSingleValueRhs=[true])\n" +
+                       "      PhoenixTableScan(table=[[phoenix, Join, ItemTable]])\n" +
+                       "      PhoenixServerAggregate(group=[{0}], SQ=[MAX($5)], isOrdered=[true])\n" +
+                       "        PhoenixServerJoin(condition=[=($3, $0)], joinType=[inner])\n" +
+                       "          PhoenixServerProject(item_id=[$0])\n" +
+                       "            PhoenixTableScan(table=[[phoenix, Join, ItemTable]], scanOrder=[FORWARD])\n" +
+                       "          PhoenixTableScan(table=[[phoenix, Join, OrderTable]])\n")
             .resultIs(new Object[][] {
                     new Object[] {"0000000001", "T1", 1000},
                     new Object[] {"0000000002", "T2", 3000},
@@ -1041,16 +1101,13 @@ public class CalciteIT extends BaseClientManagedTimeIT {
                     + "from " + JOIN_ITEM_TABLE_FULL_NAME + " i where \"item_id\" < '0000000006'")
                .explainIs("PhoenixToEnumerableConverter\n" +
                           "  PhoenixClientProject(item_id=[$0], NAME=[$1], EXPR$2=[$8])\n" +
-                          "    PhoenixToClientConverter\n" +
-                          "      PhoenixServerJoin(condition=[=($0, $7)], joinType=[left], isSingleValueRhs=[true])\n" +
-                          "        PhoenixTableScan(table=[[phoenix, Join, ItemTable]], filter=[<($0, '0000000006')])\n" +
-                          "        PhoenixClientProject(item_id0=[$7], SQ=[$4])\n" +
-                          "          PhoenixToClientConverter\n" +
-                          "            PhoenixServerJoin(condition=[=($2, $7)], joinType=[inner])\n" +
-                          "              PhoenixTableScan(table=[[phoenix, Join, OrderTable]])\n" +
-                          "              PhoenixToClientConverter\n" +
-                          "                PhoenixServerProject(item_id=[$0])\n" +
-                          "                  PhoenixTableScan(table=[[phoenix, Join, ItemTable]], filter=[<($0, '0000000006')])\n")
+                          "    PhoenixServerJoin(condition=[=($0, $7)], joinType=[left], isSingleValueRhs=[true])\n" +
+                          "      PhoenixTableScan(table=[[phoenix, Join, ItemTable]], filter=[<($0, '0000000006')])\n" +
+                          "      PhoenixClientProject(item_id0=[$7], SQ=[$4])\n" +
+                          "        PhoenixServerJoin(condition=[=($2, $7)], joinType=[inner])\n" +
+                          "          PhoenixTableScan(table=[[phoenix, Join, OrderTable]])\n" +
+                          "          PhoenixServerProject(item_id=[$0])\n" +
+                          "            PhoenixTableScan(table=[[phoenix, Join, ItemTable]], filter=[<($0, '0000000006')])\n")
                .resultIs(new Object[][] {
                          new Object[] {"0000000001", "T1", 1000},
                          new Object[] {"0000000002", "T2", 3000},
@@ -1063,27 +1120,23 @@ public class CalciteIT extends BaseClientManagedTimeIT {
     @Test public void testIndex() {
         start(true).sql("select * from aTable where b_string = 'b'")
             .explainIs("PhoenixToEnumerableConverter\n" +
-                   "  PhoenixToClientConverter\n" +
-                   "    PhoenixServerProject(ORGANIZATION_ID=[$1], ENTITY_ID=[$2], A_STRING=[$3], B_STRING=[$0], A_INTEGER=[$4], A_DATE=[$5], A_TIME=[$6], A_TIMESTAMP=[$7], X_DECIMAL=[$8], X_LONG=[$9], X_INTEGER=[$10], Y_INTEGER=[$11], A_BYTE=[$12], A_SHORT=[$13], A_FLOAT=[$14], A_DOUBLE=[$15], A_UNSIGNED_FLOAT=[$16], A_UNSIGNED_DOUBLE=[$17])\n" +
-                   "      PhoenixTableScan(table=[[phoenix, IDX_FULL]], filter=[=($0, 'b')])\n")
+                       "  PhoenixServerProject(ORGANIZATION_ID=[$1], ENTITY_ID=[$2], A_STRING=[$3], B_STRING=[$0], A_INTEGER=[$4], A_DATE=[$5], A_TIME=[$6], A_TIMESTAMP=[$7], X_DECIMAL=[$8], X_LONG=[$9], X_INTEGER=[$10], Y_INTEGER=[$11], A_BYTE=[$12], A_SHORT=[$13], A_FLOAT=[$14], A_DOUBLE=[$15], A_UNSIGNED_FLOAT=[$16], A_UNSIGNED_DOUBLE=[$17])\n" +
+                       "    PhoenixTableScan(table=[[phoenix, IDX_FULL]], filter=[=($0, 'b')])\n")
             .close();
         start(true).sql("select x_integer from aTable")
             .explainIs("PhoenixToEnumerableConverter\n" +
-                       "  PhoenixToClientConverter\n" +
-                       "    PhoenixServerProject(X_INTEGER=[$4])\n" +
-                       "      PhoenixTableScan(table=[[phoenix, IDX1]])\n")
+                       "  PhoenixServerProject(X_INTEGER=[$4])\n" +
+                       "    PhoenixTableScan(table=[[phoenix, IDX1]])\n")
             .close();
         start(true).sql("select a_string from aTable order by a_string")
             .explainIs("PhoenixToEnumerableConverter\n" +
-                       "  PhoenixToClientConverter\n" +
-                       "    PhoenixServerProject(A_STRING=[$0])\n" +
-                       "      PhoenixTableScan(table=[[phoenix, IDX1]])\n")
+                       "  PhoenixServerProject(A_STRING=[$0])\n" +
+                       "    PhoenixTableScan(table=[[phoenix, IDX1]], scanOrder=[FORWARD])\n")
             .close();
         start(true).sql("select a_string from aTable order by organization_id")
             .explainIs("PhoenixToEnumerableConverter\n" +
-                       "  PhoenixToClientConverter\n" +
-                       "    PhoenixServerProject(A_STRING=[$2], ORGANIZATION_ID=[$0])\n" +
-                       "      PhoenixTableScan(table=[[phoenix, ATABLE]])\n")
+                       "  PhoenixServerProject(A_STRING=[$2], ORGANIZATION_ID=[$0])\n" +
+                       "    PhoenixTableScan(table=[[phoenix, ATABLE]], scanOrder=[FORWARD])\n")
             .close();
         start(true).sql("select a_integer from aTable order by a_string")
             .explainIs("PhoenixToEnumerableConverter\n" +
@@ -1093,26 +1146,23 @@ public class CalciteIT extends BaseClientManagedTimeIT {
             .close();
         start(true).sql("select a_string, b_string from aTable where a_string = 'a'")
             .explainIs("PhoenixToEnumerableConverter\n" +
-                       "  PhoenixToClientConverter\n" +
-                       "    PhoenixServerProject(A_STRING=[$0], B_STRING=[$3])\n" +
-                       "      PhoenixTableScan(table=[[phoenix, IDX1]], filter=[=($0, 'a')])\n")
+                       "  PhoenixServerProject(A_STRING=[$0], B_STRING=[$3])\n" +
+                       "    PhoenixTableScan(table=[[phoenix, IDX1]], filter=[=($0, 'a')])\n")
             .close();
         start(true).sql("select a_string, b_string from aTable where b_string = 'b'")
             .explainIs("PhoenixToEnumerableConverter\n" +
-                       "  PhoenixToClientConverter\n" +
-                       "    PhoenixServerProject(A_STRING=[$3], B_STRING=[$0])\n" +
-                       "      PhoenixTableScan(table=[[phoenix, IDX2]], filter=[=($0, 'b')])\n")
+                       "  PhoenixServerProject(A_STRING=[$3], B_STRING=[$0])\n" +
+                       "    PhoenixTableScan(table=[[phoenix, IDX2]], filter=[=($0, 'b')])\n")
             .close();
         start(true).sql("select a_string, b_string, x_integer, y_integer from aTable where b_string = 'b'")
             .explainIs("PhoenixToEnumerableConverter\n" +
-                       "  PhoenixToClientConverter\n" +
-                       "    PhoenixServerProject(A_STRING=[$3], B_STRING=[$0], X_INTEGER=[$10], Y_INTEGER=[$11])\n" +
-                       "      PhoenixTableScan(table=[[phoenix, IDX_FULL]], filter=[=($0, 'b')])\n")
+                       "  PhoenixServerProject(A_STRING=[$3], B_STRING=[$0], X_INTEGER=[$10], Y_INTEGER=[$11])\n" +
+                       "    PhoenixTableScan(table=[[phoenix, IDX_FULL]], filter=[=($0, 'b')])\n")
             .close();
         start(true).sql("select a_string, count(*) from aTable group by a_string")
             .explainIs("PhoenixToEnumerableConverter\n" +
                        "  PhoenixServerAggregate(group=[{0}], EXPR$1=[COUNT()], isOrdered=[true])\n" +
-                       "    PhoenixTableScan(table=[[phoenix, IDX1]])\n")
+                       "    PhoenixTableScan(table=[[phoenix, IDX1]], scanOrder=[FORWARD])\n")
             .close();
     }
     
@@ -1134,12 +1184,10 @@ public class CalciteIT extends BaseClientManagedTimeIT {
         start(false).sql("select entity_id from atable where a_string = 'a' union all select entity_id from atable where a_string = 'b'")
                 .explainIs("PhoenixToEnumerableConverter\n" +
                            "  PhoenixUnion(all=[true])\n" +
-                           "    PhoenixToClientConverter\n" +
-                           "      PhoenixServerProject(ENTITY_ID=[$1])\n" +
-                           "        PhoenixTableScan(table=[[phoenix, ATABLE]], filter=[=($2, 'a')])\n" +
-                           "    PhoenixToClientConverter\n" +
-                           "      PhoenixServerProject(ENTITY_ID=[$1])\n" +
-                           "        PhoenixTableScan(table=[[phoenix, ATABLE]], filter=[=($2, 'b')])\n")
+                           "    PhoenixServerProject(ENTITY_ID=[$1])\n" +
+                           "      PhoenixTableScan(table=[[phoenix, ATABLE]], filter=[=($2, 'a')])\n" +
+                           "    PhoenixServerProject(ENTITY_ID=[$1])\n" +
+                           "      PhoenixTableScan(table=[[phoenix, ATABLE]], filter=[=($2, 'b')])\n")
                 .resultIs(new Object[][] {
                         {"00A123122312312"},
                         {"00A223122312312"},
@@ -1191,9 +1239,8 @@ public class CalciteIT extends BaseClientManagedTimeIT {
         start(false).sql("SELECT t.s FROM UNNEST((SELECT scores FROM " + SCORES_TABLE_NAME + ")) AS t(s)")
                 .explainIs("PhoenixToEnumerableConverter\n" +
                            "  PhoenixUncollect\n" +
-                           "    PhoenixToClientConverter\n" +
-                           "      PhoenixServerProject(EXPR$0=[$2])\n" +
-                           "        PhoenixTableScan(table=[[phoenix, SCORES]])\n")
+                           "    PhoenixServerProject(EXPR$0=[$2])\n" +
+                           "      PhoenixTableScan(table=[[phoenix, SCORES]])\n")
                 .resultIs(new Object[][] {
                         {85}, 
                         {80}, 
@@ -1206,12 +1253,10 @@ public class CalciteIT extends BaseClientManagedTimeIT {
                 .explainIs("PhoenixToEnumerableConverter\n" +
                            "  PhoenixClientProject(STUDENT_ID=[$0], SCORE=[$3])\n" +
                            "    PhoenixCorrelate(correlation=[$cor0], joinType=[INNER], requiredColumns=[{0}])\n" +
-                           "      PhoenixToClientConverter\n" +
-                           "        PhoenixTableScan(table=[[phoenix, SCORES]])\n" +
+                           "      PhoenixTableScan(table=[[phoenix, SCORES]])\n" +
                            "      PhoenixUncollect\n" +
-                           "        PhoenixToClientConverter\n" +
-                           "          PhoenixServerProject(EXPR$0=[$2])\n" +
-                           "            PhoenixTableScan(table=[[phoenix, SCORES]], filter=[=($cor0.STUDENT_ID, $0)])\n")
+                           "        PhoenixServerProject(EXPR$0=[$2])\n" +
+                           "          PhoenixTableScan(table=[[phoenix, SCORES]], filter=[=($cor0.STUDENT_ID, $0)])\n")
                 .resultIs(new Object[][] {
                         {1, 85}, 
                         {1, 80}, 
@@ -1239,21 +1284,19 @@ public class CalciteIT extends BaseClientManagedTimeIT {
                 "  PhoenixClientProject(order_id=[$0], QUANTITY=[$4])\n" +
                 "    PhoenixFilter(condition=[=($4, $7)])\n" +
                 "      PhoenixCorrelate(correlation=[$cor0], joinType=[LEFT], requiredColumns=[{2}])\n" +
-                "        PhoenixToClientConverter\n" +
-                "          PhoenixTableScan(table=[[phoenix, Join, OrderTable]])\n" +
+                "        PhoenixTableScan(table=[[phoenix, Join, OrderTable]])\n" +
                 "        PhoenixServerAggregate(group=[{}], EXPR$0=[MAX($4)])\n" +
                 "          PhoenixTableScan(table=[[phoenix, Join, OrderTable]], filter=[=($cor0.item_id, $2)])\n";
         String p1Decorrelated = 
                 "PhoenixToEnumerableConverter\n" +
                 "  PhoenixClientProject(order_id=[$0], QUANTITY=[$4])\n" +
-                "    PhoenixToClientConverter\n" +
-                "      PhoenixServerJoin(condition=[AND(=($2, $7), =($4, $8))], joinType=[inner])\n" +
-                "        PhoenixTableScan(table=[[phoenix, Join, OrderTable]])\n" +
-                "        PhoenixServerAggregate(group=[{7}], EXPR$0=[MAX($4)], isOrdered=[false])\n" +
-                "          PhoenixServerJoin(condition=[=($7, $2)], joinType=[inner])\n" +
-                "            PhoenixTableScan(table=[[phoenix, Join, OrderTable]])\n" +
-                "            PhoenixServerAggregate(group=[{2}], isOrdered=[false])\n" +
-                "              PhoenixTableScan(table=[[phoenix, Join, OrderTable]])\n";
+                "    PhoenixServerJoin(condition=[AND(=($2, $7), =($4, $8))], joinType=[inner])\n" +
+                "      PhoenixTableScan(table=[[phoenix, Join, OrderTable]])\n" +
+                "      PhoenixServerAggregate(group=[{7}], EXPR$0=[MAX($4)], isOrdered=[false])\n" +
+                "        PhoenixServerJoin(condition=[=($7, $2)], joinType=[inner])\n" +
+                "          PhoenixTableScan(table=[[phoenix, Join, OrderTable]])\n" +
+                "          PhoenixServerAggregate(group=[{2}], isOrdered=[false])\n" +
+                "            PhoenixTableScan(table=[[phoenix, Join, OrderTable]])\n";
         start(correlProps).sql(q1).explainIs(p1Correlate).resultIs(r1).close();
         start(decorrelProps).sql(q1).explainIs(p1Decorrelated).resultIs(r1).close();
                 
@@ -1270,79 +1313,50 @@ public class CalciteIT extends BaseClientManagedTimeIT {
                 "  PhoenixClientProject(NAME=[$1])\n" +
                 "    PhoenixFilter(condition=[=($2, $7)])\n" +
                 "      PhoenixCorrelate(correlation=[$cor0], joinType=[LEFT], requiredColumns=[{0, 1}])\n" +
-                "        PhoenixToClientConverter\n" +
-                "          PhoenixTableScan(table=[[phoenix, Join, ItemTable]])\n" +
+                "        PhoenixTableScan(table=[[phoenix, Join, ItemTable]])\n" +
                 "        PhoenixServerAggregate(group=[{}], EXPR$0=[MAX($2)])\n" +
                 "          PhoenixTableScan(table=[[phoenix, Join, ItemTable]], filter=[AND(=($cor0.item_id, $0), =($cor0.NAME, $1), <>($0, 'invalid001'))])\n";
         String p2Decorrelated = 
                 "PhoenixToEnumerableConverter\n" +
                 "  PhoenixClientProject(NAME=[$1])\n" +
-                "    PhoenixToClientConverter\n" +
-                "      PhoenixServerJoin(condition=[AND(=($0, $7), =($1, $8), =($2, $9))], joinType=[inner])\n" +
-                "        PhoenixTableScan(table=[[phoenix, Join, ItemTable]])\n" +
-                "        PhoenixServerAggregate(group=[{0, 1}], EXPR$0=[MAX($4)], isOrdered=[false])\n" +
-                "          PhoenixServerJoin(condition=[AND(=($0, $2), =($1, $3))], joinType=[inner])\n" +
-                "            PhoenixServerProject(item_id=[$0], NAME=[$1])\n" +
-                "              PhoenixTableScan(table=[[phoenix, Join, ItemTable]])\n" +
-                "            PhoenixToClientConverter\n" +
-                "              PhoenixTableScan(table=[[phoenix, Join, ItemTable]], filter=[<>($0, 'invalid001')])\n";
+                "    PhoenixServerJoin(condition=[AND(=($0, $7), =($1, $8), =($2, $9))], joinType=[inner])\n" +
+                "      PhoenixTableScan(table=[[phoenix, Join, ItemTable]])\n" +
+                "      PhoenixServerAggregate(group=[{0, 1}], EXPR$0=[MAX($4)], isOrdered=[false])\n" +
+                "        PhoenixServerJoin(condition=[AND(=($0, $2), =($1, $3))], joinType=[inner])\n" +
+                "          PhoenixServerProject(item_id=[$0], NAME=[$1])\n" +
+                "            PhoenixTableScan(table=[[phoenix, Join, ItemTable]])\n" +
+                "          PhoenixTableScan(table=[[phoenix, Join, ItemTable]], filter=[<>($0, 'invalid001')])\n";
         start(correlProps).sql(q2).explainIs(p2Correlate).resultIs(r2).close();
         start(decorrelProps).sql(q2).explainIs(p2Decorrelated).resultIs(r2).close();
         
-        String q3a = "select \"item_id\", name from " + JOIN_ITEM_TABLE_FULL_NAME + " i where exists (select 1 from " + JOIN_ORDER_TABLE_FULL_NAME + " o where i.\"item_id\" = o.\"item_id\")";
-        Object[][] r3a = new Object[][] {
+        // Test PhoenixClientSemiJoin
+        String q3 = "select \"item_id\", name from " + JOIN_ITEM_TABLE_FULL_NAME + " i where exists (select 1 from " + JOIN_ORDER_TABLE_FULL_NAME + " o where i.\"item_id\" = o.\"item_id\")";
+        Object[][] r3 = new Object[][] {
                 {"0000000001", "T1"},
                 {"0000000002", "T2"},
                 {"0000000003", "T3"},
                 {"0000000006", "T6"}};
-        String p3aCorrelate = 
+        String p3Correlate = 
                 "PhoenixToEnumerableConverter\n" +
                 "  PhoenixClientProject(item_id=[$0], NAME=[$1])\n" +
                 "    PhoenixFilter(condition=[IS NOT NULL($7)])\n" +
                 "      PhoenixCorrelate(correlation=[$cor0], joinType=[LEFT], requiredColumns=[{0}])\n" +
-                "        PhoenixToClientConverter\n" +
-                "          PhoenixTableScan(table=[[phoenix, Join, ItemTable]])\n" +
+                "        PhoenixTableScan(table=[[phoenix, Join, ItemTable]])\n" +
                 "        PhoenixServerAggregate(group=[{}], agg#0=[MIN($0)])\n" +
                 "          PhoenixServerProject($f0=[true])\n" +
                 "            PhoenixTableScan(table=[[phoenix, Join, OrderTable]], filter=[=($cor0.item_id, $2)])\n";
-        String p3aDecorrelated = 
+        String p3Decorrelated = 
                 "PhoenixToEnumerableConverter\n" +
                 "  PhoenixClientProject(item_id=[$0], NAME=[$1])\n" +
-                "    PhoenixToClientConverter\n" +
-                "      PhoenixServerSemiJoin(condition=[=($0, $7)], joinType=[inner])\n" +
-                "        PhoenixTableScan(table=[[phoenix, Join, ItemTable]])\n" +
-                "        PhoenixClientProject(item_id0=[$0], $f0=[true])\n" +
-                "          PhoenixToClientConverter\n" +
-                "            PhoenixServerJoin(condition=[=($0, $3)], joinType=[inner])\n" +
-                "              PhoenixServerProject(item_id=[$0])\n" +
-                "                PhoenixTableScan(table=[[phoenix, Join, ItemTable]])\n" +
-                "              PhoenixToClientConverter\n" +
-                "                PhoenixTableScan(table=[[phoenix, Join, OrderTable]])\n";
-        start(correlProps).sql(q3a).explainIs(p3aCorrelate).resultIs(r3a).close();
-        start(decorrelProps).sql(q3a).explainIs(p3aDecorrelated).resultIs(r3a).close();
-        // Test PhoenixClientSemiJoin
-        String q3b = "select \"item_id\", name from " + JOIN_ITEM_TABLE_FULL_NAME + " i where exists (select 1 from " + JOIN_ITEM_TABLE_FULL_NAME + " o where i.\"item_id\" = o.\"item_id\" and name <> 'INVALID-1')";
-        Object[][] r3b = new Object[][] {
-                {"0000000001", "T1"},
-                {"0000000002", "T2"},
-                {"0000000003", "T3"},
-                {"0000000004", "T4"},
-                {"0000000005", "T5"},
-                {"0000000006", "T6"}};
-        String p3bDecorrelated =
-                "PhoenixToEnumerableConverter\n" +
-                "  PhoenixClientProject(item_id=[$0], NAME=[$1])\n" +
-                "    PhoenixClientSemiJoin(condition=[=($0, $8)], joinType=[inner])\n" +
-                "      PhoenixToClientConverter\n" +
-                "        PhoenixTableScan(table=[[phoenix, Join, ItemTable]])\n" +
-                "      PhoenixClientProject($f0=[true], item_id0=[$0])\n" +
-                "        PhoenixClientJoin(condition=[=($0, $1)], joinType=[inner])\n" +
-                "          PhoenixToClientConverter\n" +
-                "            PhoenixServerProject(item_id=[$0])\n" +
-                "              PhoenixTableScan(table=[[phoenix, Join, ItemTable]])\n" +
-                "          PhoenixToClientConverter\n" +
-                "            PhoenixTableScan(table=[[phoenix, Join, ItemTable]], filter=[<>(CAST($1):VARCHAR(9) CHARACTER SET \"ISO-8859-1\" COLLATE \"ISO-8859-1$en_US$primary\", 'INVALID-1')])\n";
-        start(decorrelProps).sql(q3b).explainIs(p3bDecorrelated).resultIs(r3b).close();
+                "    PhoenixClientSemiJoin(condition=[=($0, $7)], joinType=[inner])\n" +
+                "      PhoenixTableScan(table=[[phoenix, Join, ItemTable]], scanOrder=[FORWARD])\n" +
+                "      PhoenixClientProject(item_id0=[$0], $f0=[true])\n" +
+                "        PhoenixServerJoin(condition=[=($0, $3)], joinType=[inner])\n" +
+                "          PhoenixServerProject(item_id=[$0])\n" +
+                "            PhoenixTableScan(table=[[phoenix, Join, ItemTable]], scanOrder=[FORWARD])\n" +
+                "          PhoenixTableScan(table=[[phoenix, Join, OrderTable]])\n";
+        start(correlProps).sql(q3).explainIs(p3Correlate).resultIs(r3).close();
+        start(decorrelProps).sql(q3).explainIs(p3Decorrelated).resultIs(r3).close();
         
         String q4 = "select \"item_id\", name from " + JOIN_ITEM_TABLE_FULL_NAME + " i where \"item_id\" in (select \"item_id\" from " + JOIN_ORDER_TABLE_FULL_NAME + ")";
         Object[][] r4 = new Object[][] {
@@ -1352,12 +1366,10 @@ public class CalciteIT extends BaseClientManagedTimeIT {
                 {"0000000006", "T6"}};
         String p4Decorrelated = 
                 "PhoenixToEnumerableConverter\n" +
-                "  PhoenixToClientConverter\n" +
-                "    PhoenixServerSemiJoin(condition=[=($0, $4)], joinType=[inner])\n" +
-                "      PhoenixServerProject(item_id=[$0], NAME=[$1])\n" +
-                "        PhoenixTableScan(table=[[phoenix, Join, ItemTable]])\n" +
-                "      PhoenixToClientConverter\n" +
-                "        PhoenixTableScan(table=[[phoenix, Join, OrderTable]])\n";
+                "  PhoenixServerSemiJoin(condition=[=($0, $4)], joinType=[inner])\n" +
+                "    PhoenixServerProject(item_id=[$0], NAME=[$1])\n" +
+                "      PhoenixTableScan(table=[[phoenix, Join, ItemTable]])\n" +
+                "    PhoenixTableScan(table=[[phoenix, Join, OrderTable]])\n";
         start(decorrelProps).sql(q4).explainIs(p4Decorrelated).resultIs(r4).close();
         
         // CALCITE-864: switching orders and items in the first join wouldn't work.
@@ -1371,36 +1383,29 @@ public class CalciteIT extends BaseClientManagedTimeIT {
                 "  PhoenixClientProject(order_id=[$7])\n" +
                 "    PhoenixFilter(condition=[=($11, $14)])\n" +
                 "      PhoenixCorrelate(correlation=[$cor0], joinType=[LEFT], requiredColumns=[{5}])\n" +
-                "        PhoenixToClientConverter\n" +
-                "          PhoenixServerJoin(condition=[=($9, $0)], joinType=[inner])\n" +
-                "            PhoenixTableScan(table=[[phoenix, Join, ItemTable]])\n" +
-                "            PhoenixToClientConverter\n" +
-                "              PhoenixTableScan(table=[[phoenix, Join, OrderTable]])\n" +
+                "        PhoenixServerJoin(condition=[=($9, $0)], joinType=[inner])\n" +
+                "          PhoenixTableScan(table=[[phoenix, Join, ItemTable]])\n" +
+                "          PhoenixTableScan(table=[[phoenix, Join, OrderTable]])\n" +
                 "        PhoenixServerAggregate(group=[{}], EXPR$0=[MAX($4)])\n" +
                 "          PhoenixServerJoin(condition=[=($2, $7)], joinType=[inner])\n" +
                 "            PhoenixTableScan(table=[[phoenix, Join, OrderTable]])\n" +
-                "            PhoenixToClientConverter\n" +
-                "              PhoenixTableScan(table=[[phoenix, Join, ItemTable]], filter=[=($cor0.supplier_id, $5)])\n";
+                "            PhoenixTableScan(table=[[phoenix, Join, ItemTable]], filter=[=($cor0.supplier_id, $5)])\n";
         String p5Decorrelated =
                 "PhoenixToEnumerableConverter\n" +
                 "  PhoenixClientProject(order_id=[$7])\n" +
-                "    PhoenixToClientConverter\n" +
-                "      PhoenixServerJoin(condition=[AND(=($9, $0), =($5, $14))], joinType=[inner])\n" +
-                "        PhoenixTableScan(table=[[phoenix, Join, ItemTable]])\n" +
-                "        PhoenixToClientConverter\n" +
-                "          PhoenixServerJoin(condition=[=($4, $8)], joinType=[inner])\n" +
+                "    PhoenixServerJoin(condition=[AND(=($5, $14), =($9, $0))], joinType=[inner])\n" +
+                "      PhoenixTableScan(table=[[phoenix, Join, ItemTable]])\n" +
+                "      PhoenixServerJoin(condition=[=($4, $8)], joinType=[inner])\n" +
+                "        PhoenixTableScan(table=[[phoenix, Join, OrderTable]])\n" +
+                "        PhoenixServerAggregate(group=[{14}], EXPR$0=[MAX($4)], isOrdered=[false])\n" +
+                "          PhoenixServerJoin(condition=[=($2, $7)], joinType=[inner])\n" +
                 "            PhoenixTableScan(table=[[phoenix, Join, OrderTable]])\n" +
-                "            PhoenixServerAggregate(group=[{14}], EXPR$0=[MAX($4)], isOrdered=[false])\n" +
-                "              PhoenixServerJoin(condition=[=($2, $7)], joinType=[inner])\n" +
-                "                PhoenixTableScan(table=[[phoenix, Join, OrderTable]])\n" +
-                "                PhoenixToClientConverter\n" +
-                "                  PhoenixServerJoin(condition=[=($7, $5)], joinType=[inner])\n" +
-                "                    PhoenixTableScan(table=[[phoenix, Join, ItemTable]])\n" +
-                "                    PhoenixServerAggregate(group=[{5}], isOrdered=[false])\n" +
-                "                      PhoenixServerJoin(condition=[=($9, $0)], joinType=[inner])\n" +
-                "                        PhoenixTableScan(table=[[phoenix, Join, ItemTable]])\n" +
-                "                        PhoenixToClientConverter\n" +
-                "                          PhoenixTableScan(table=[[phoenix, Join, OrderTable]])\n";
+                "            PhoenixServerJoin(condition=[=($7, $5)], joinType=[inner])\n" +
+                "              PhoenixTableScan(table=[[phoenix, Join, ItemTable]])\n" +
+                "              PhoenixServerAggregate(group=[{5}], isOrdered=[false])\n" +
+                "                PhoenixServerJoin(condition=[=($9, $0)], joinType=[inner])\n" +
+                "                  PhoenixTableScan(table=[[phoenix, Join, ItemTable]])\n" +
+                "                  PhoenixTableScan(table=[[phoenix, Join, OrderTable]])\n";
         start(correlProps).sql(q5).explainIs(p5Correlate).resultIs(r5).close();
         start(decorrelProps).sql(q5).explainIs(p5Decorrelated).resultIs(r5).close();
         
@@ -1414,21 +1419,19 @@ public class CalciteIT extends BaseClientManagedTimeIT {
                 "  PhoenixClientProject(ORGANIZATION_ID=[$0], ENTITY_ID=[$1], A_INTEGER=[$4])\n" +
                 "    PhoenixFilter(condition=[=($4, $18)])\n" +
                 "      PhoenixCorrelate(correlation=[$cor0], joinType=[LEFT], requiredColumns=[{0, 3}])\n" +
-                "        PhoenixToClientConverter\n" +
-                "          PhoenixTableScan(table=[[phoenix, ATABLE]], filter=[=($2, 'a')])\n" +
+                "        PhoenixTableScan(table=[[phoenix, ATABLE]], filter=[=($2, 'a')])\n" +
                 "        PhoenixServerAggregate(group=[{}], EXPR$0=[MIN($4)])\n" +
                 "          PhoenixTableScan(table=[[phoenix, ATABLE]], filter=[AND(=($2, 'a'), =($cor0.ORGANIZATION_ID, $0), =($cor0.B_STRING, $3))])\n";
         String p6Decorrelated = 
                 "PhoenixToEnumerableConverter\n" +
                 "  PhoenixClientProject(ORGANIZATION_ID=[$0], ENTITY_ID=[$1], A_INTEGER=[$4])\n" +
-                "    PhoenixToClientConverter\n" +
-                "      PhoenixServerJoin(condition=[AND(=($0, $18), =($3, $19), =($4, $20))], joinType=[inner])\n" +
-                "        PhoenixTableScan(table=[[phoenix, ATABLE]], filter=[=($2, 'a')])\n" +
-                "        PhoenixServerAggregate(group=[{18, 19}], EXPR$0=[MIN($4)], isOrdered=[false])\n" +
-                "          PhoenixServerJoin(condition=[AND(=($18, $0), =($19, $3))], joinType=[inner])\n" +
-                "            PhoenixTableScan(table=[[phoenix, ATABLE]], filter=[=($2, 'a')])\n" +
-                "            PhoenixServerAggregate(group=[{0, 3}], isOrdered=[false])\n" +
-                "              PhoenixTableScan(table=[[phoenix, ATABLE]], filter=[=($2, 'a')])\n";
+                "    PhoenixServerJoin(condition=[AND(=($0, $18), =($3, $19), =($4, $20))], joinType=[inner])\n" +
+                "      PhoenixTableScan(table=[[phoenix, ATABLE]], filter=[=($2, 'a')])\n" +
+                "      PhoenixServerAggregate(group=[{18, 19}], EXPR$0=[MIN($4)], isOrdered=[false])\n" +
+                "        PhoenixServerJoin(condition=[AND(=($18, $0), =($19, $3))], joinType=[inner])\n" +
+                "          PhoenixTableScan(table=[[phoenix, ATABLE]], filter=[=($2, 'a')])\n" +
+                "          PhoenixServerAggregate(group=[{0, 3}], isOrdered=[false])\n" +
+                "            PhoenixTableScan(table=[[phoenix, ATABLE]], filter=[=($2, 'a')])\n";
         start(correlProps).sql(q6).explainIs(p6Correlate).resultIs(r6).close();
         start(decorrelProps).sql(q6).explainIs(p6Decorrelated).resultIs(r6).close();
     }
@@ -1436,9 +1439,8 @@ public class CalciteIT extends BaseClientManagedTimeIT {
     @Test public void testInValueList() {
         start(false).sql("select entity_id from aTable where organization_id = '00D300000000XHP' and entity_id in ('00A123122312312', '00A223122312312', '00B523122312312', '00B623122312312', '00C923122312312')")
             .explainIs("PhoenixToEnumerableConverter\n" +
-                       "  PhoenixToClientConverter\n" +
-                       "    PhoenixServerProject(ENTITY_ID=[$1])\n" +
-                       "      PhoenixTableScan(table=[[phoenix, ATABLE]], filter=[AND(=($0, '00D300000000XHP'), OR(=($1, '00A123122312312'), =($1, '00A223122312312'), =($1, '00B523122312312'), =($1, '00B623122312312'), =($1, '00C923122312312')))])\n")
+                       "  PhoenixServerProject(ENTITY_ID=[$1])\n" +
+                       "    PhoenixTableScan(table=[[phoenix, ATABLE]], filter=[AND(=($0, '00D300000000XHP'), OR(=($1, '00A123122312312'), =($1, '00A223122312312'), =($1, '00B523122312312'), =($1, '00B623122312312'), =($1, '00C923122312312')))])\n")
             .resultIs(new Object[][] {
                     {"00A123122312312"},
                     {"00A223122312312"},
@@ -1451,8 +1453,7 @@ public class CalciteIT extends BaseClientManagedTimeIT {
     @Test public void testSelectFromView() {
         start(false).sql("select * from v")
                 .explainIs("PhoenixToEnumerableConverter\n" +
-                           "  PhoenixToClientConverter\n" +
-                           "    PhoenixTableScan(table=[[phoenix, ATABLE]], filter=[=($2, 'a')])\n")
+                           "  PhoenixTableScan(table=[[phoenix, ATABLE]], filter=[=($2, 'a')])\n")
                 .resultIs(new Object[][] {
                         {"00D300000000XHP", "00A123122312312", "a"}, 
                         {"00D300000000XHP", "00A223122312312", "a"}, 
@@ -1465,23 +1466,20 @@ public class CalciteIT extends BaseClientManagedTimeIT {
         start(true).sql("select count(*) from " + NOSALT_TABLE_NAME + " where col0 > 3")
                 .explainIs("PhoenixToEnumerableConverter\n" +
                            "  PhoenixServerAggregate(group=[{}], EXPR$0=[COUNT()])\n" +
-                           "    PhoenixServerProject(DUMMY=[0])\n" +
-                           "      PhoenixTableScan(table=[[phoenix, IDXSALTED_NOSALT_TEST_TABLE:unordered]], filter=[>(CAST($0):INTEGER, 3)])\n")
+                           "    PhoenixTableScan(table=[[phoenix, IDXSALTED_NOSALT_TEST_TABLE]], filter=[>(CAST($0):INTEGER, 3)])\n")
                 .resultIs(new Object[][]{{2L}})
                 .close();
         start(true).sql("select mypk0, mypk1, col0 from " + NOSALT_TABLE_NAME + " where col0 <= 4")
                 .explainIs("PhoenixToEnumerableConverter\n" +
-                           "  PhoenixToClientConverter\n" +
-                           "    PhoenixServerProject(MYPK0=[$1], MYPK1=[$2], COL0=[CAST($0):INTEGER])\n" +
-                           "      PhoenixTableScan(table=[[phoenix, IDXSALTED_NOSALT_TEST_TABLE:unordered]], filter=[<=(CAST($0):INTEGER, 4)])\n")
+                           "  PhoenixServerProject(MYPK0=[$1], MYPK1=[$2], COL0=[CAST($0):INTEGER])\n" +
+                           "    PhoenixTableScan(table=[[phoenix, IDXSALTED_NOSALT_TEST_TABLE]], filter=[<=(CAST($0):INTEGER, 4)])\n")
                 .resultIs(new Object[][] {
                         {2, 3, 4},
                         {1, 2, 3}})
                 .close();
         start(true).sql("select * from " + SALTED_TABLE_NAME + " where mypk0 < 3")
                 .explainIs("PhoenixToEnumerableConverter\n" +
-                           "  PhoenixToClientConverter\n" +
-                           "    PhoenixTableScan(table=[[phoenix, SALTED_TEST_TABLE:unordered]], filter=[<($0, 3)])\n")
+                           "  PhoenixTableScan(table=[[phoenix, SALTED_TEST_TABLE]], filter=[<($0, 3)])\n")
                 .resultIs(new Object[][] {
                         {1, 2, 3, 4},
                         {2, 3, 4, 5}})
@@ -1489,15 +1487,13 @@ public class CalciteIT extends BaseClientManagedTimeIT {
         start(true).sql("select count(*) from " + SALTED_TABLE_NAME + " where col0 > 3")
                 .explainIs("PhoenixToEnumerableConverter\n" +
                            "  PhoenixServerAggregate(group=[{}], EXPR$0=[COUNT()])\n" +
-                           "    PhoenixServerProject(DUMMY=[0])\n" +
-                           "      PhoenixTableScan(table=[[phoenix, IDX_SALTED_TEST_TABLE:unordered]], filter=[>(CAST($0):INTEGER, 3)])\n")
+                           "    PhoenixTableScan(table=[[phoenix, IDX_SALTED_TEST_TABLE]], filter=[>(CAST($0):INTEGER, 3)])\n")
                 .resultIs(new Object[][]{{2L}})
                 .close();
         start(true).sql("select mypk0, mypk1, col0 from " + SALTED_TABLE_NAME + " where col0 <= 4")
                 .explainIs("PhoenixToEnumerableConverter\n" +
-                           "  PhoenixToClientConverter\n" +
-                           "    PhoenixServerProject(MYPK0=[$1], MYPK1=[$2], COL0=[CAST($0):INTEGER])\n" +
-                           "      PhoenixTableScan(table=[[phoenix, IDX_SALTED_TEST_TABLE:unordered]], filter=[<=(CAST($0):INTEGER, 4)])\n")
+                           "  PhoenixServerProject(MYPK0=[$1], MYPK1=[$2], COL0=[CAST($0):INTEGER])\n" +
+                           "    PhoenixTableScan(table=[[phoenix, IDX_SALTED_TEST_TABLE]], filter=[<=(CAST($0):INTEGER, 4)])\n")
                 .resultIs(new Object[][] {
                         {2, 3, 4},
                         {1, 2, 3}})
@@ -1505,27 +1501,23 @@ public class CalciteIT extends BaseClientManagedTimeIT {
         start(true).sql("select count(*) from " + SALTED_TABLE_NAME + " where col1 > 4")
                 .explainIs("PhoenixToEnumerableConverter\n" +
                            "  PhoenixServerAggregate(group=[{}], EXPR$0=[COUNT()])\n" +
-                           "    PhoenixServerProject(DUMMY=[0])\n" +
-                           "      PhoenixTableScan(table=[[phoenix, IDXSALTED_SALTED_TEST_TABLE:unordered]], filter=[>(CAST($0):INTEGER, 4)])\n")
+                           "    PhoenixTableScan(table=[[phoenix, IDXSALTED_SALTED_TEST_TABLE]], filter=[>(CAST($0):INTEGER, 4)])\n")
                 .resultIs(new Object[][]{{2L}})
                 .close();
         start(true).sql("select * from " + SALTED_TABLE_NAME + " where col1 <= 5 order by col1")
                 .explainIs("PhoenixToEnumerableConverter\n" +
-                           "  PhoenixToClientConverter\n" +
-                           "    PhoenixServerProject(MYPK0=[$1], MYPK1=[$2], COL0=[$3], COL1=[CAST($0):INTEGER])\n" +
-                           "      PhoenixTableScan(table=[[phoenix, IDXSALTED_SALTED_TEST_TABLE]], filter=[<=(CAST($0):INTEGER, 5)])\n")
+                           "  PhoenixServerProject(MYPK0=[$1], MYPK1=[$2], COL0=[$3], COL1=[CAST($0):INTEGER])\n" +
+                           "    PhoenixTableScan(table=[[phoenix, IDXSALTED_SALTED_TEST_TABLE]], filter=[<=(CAST($0):INTEGER, 5)], scanOrder=[FORWARD])\n")
                 .resultIs(new Object[][] {
                         {1, 2, 3, 4},
                         {2, 3, 4, 5}})
                 .close();
         start(true).sql("select * from " + SALTED_TABLE_NAME + " s1, " + SALTED_TABLE_NAME + " s2 where s1.mypk0 = s2.mypk0 and s1.mypk1 = s2.mypk1 and s1.mypk0 > 1 and s2.col1 < 6")
                 .explainIs("PhoenixToEnumerableConverter\n" +
-                           "  PhoenixToClientConverter\n" +
-                           "    PhoenixServerJoin(condition=[AND(=($0, $4), =($1, $5))], joinType=[inner])\n" +
-                           "      PhoenixTableScan(table=[[phoenix, SALTED_TEST_TABLE:unordered]], filter=[>($0, 1)])\n" +
-                           "      PhoenixToClientConverter\n" +
-                           "        PhoenixServerProject(MYPK0=[$1], MYPK1=[$2], COL0=[$3], COL1=[CAST($0):INTEGER])\n" +
-                           "          PhoenixTableScan(table=[[phoenix, IDXSALTED_SALTED_TEST_TABLE:unordered]], filter=[<(CAST($0):INTEGER, 6)])\n")
+                           "  PhoenixServerJoin(condition=[AND(=($0, $4), =($1, $5))], joinType=[inner])\n" +
+                           "    PhoenixTableScan(table=[[phoenix, SALTED_TEST_TABLE]], filter=[>($0, 1)])\n" +
+                           "    PhoenixServerProject(MYPK0=[$1], MYPK1=[$2], COL0=[$3], COL1=[CAST($0):INTEGER])\n" +
+                           "      PhoenixTableScan(table=[[phoenix, IDXSALTED_SALTED_TEST_TABLE]], filter=[<(CAST($0):INTEGER, 6)])\n")
                 .resultIs(new Object[][] {
                         {2, 3, 4, 5, 2, 3, 4, 5}})
                 .close();
@@ -1554,8 +1546,7 @@ public class CalciteIT extends BaseClientManagedTimeIT {
             .explainIs("EnumerableCalc(expr#0..8=[{inputs}], THE_YEAR=[$t6], Q=[$t4], EXPR$2=[$t8])\n" +
                        "  EnumerableJoin(condition=[=($6, $7)], joinType=[left])\n" +
   

<TRUNCATED>

Mime
View raw message