Repository: incubator-trafodion
Updated Branches:
  refs/heads/master cbf8fd07d -> 667174421


jira TRAFODION-2184 Fix to order by on renamed expressions


Project: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/commit/6ad9a9a4
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/tree/6ad9a9a4
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/diff/6ad9a9a4

Branch: refs/heads/master
Commit: 6ad9a9a4f651dbf03f7d808d2e3f426a67773ddd
Parents: 552b949
Author: Anoop Sharma <anoop.sha...@esgyn.com>
Authored: Wed Sep 21 14:56:26 2016 +0000
Committer: Anoop Sharma <anoop.sha...@esgyn.com>
Committed: Wed Sep 21 14:56:26 2016 +0000

----------------------------------------------------------------------
 core/sql/optimizer/BindRelExpr.cpp   |  8 ++++++
 core/sql/regress/seabase/EXPECTED032 | 41 ++++++++++++++++++++++++++++---
 core/sql/regress/seabase/TEST032     |  4 +++
 3 files changed, 50 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/6ad9a9a4/core/sql/optimizer/BindRelExpr.cpp
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/BindRelExpr.cpp 
b/core/sql/optimizer/BindRelExpr.cpp
index ac7c162..8e1d4d8 100644
--- a/core/sql/optimizer/BindRelExpr.cpp
+++ b/core/sql/optimizer/BindRelExpr.cpp
@@ -3856,9 +3856,17 @@ RelRoot * RelRoot::transformOrderByWithExpr(BindWA 
*bindWA)
           NABoolean found = FALSE;
           Lng32 selListIndex = 0;
           ItemExpr * selItem = NULL;
+          ItemExpr * renameColEntry = NULL;
           while ((NOT found) && (selListIndex < selListCount))
             {
               selItem = origSelectList[selListIndex];
+              
+              if (selItem->getOperatorType() == ITM_RENAME_COL)
+                {
+                  renameColEntry = selItem;
+                  selItem = selItem->child(0);
+                }
+              
               found = currOrderByItemExpr->duplicateMatch(*selItem);
               if (NOT found)
                 selListIndex++;

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/6ad9a9a4/core/sql/regress/seabase/EXPECTED032
----------------------------------------------------------------------
diff --git a/core/sql/regress/seabase/EXPECTED032 
b/core/sql/regress/seabase/EXPECTED032
index 836b3cd..6658d3a 100644
--- a/core/sql/regress/seabase/EXPECTED032
+++ b/core/sql/regress/seabase/EXPECTED032
@@ -15,7 +15,7 @@
 >>invoke t032t1;
 
 -- Definition of Trafodion table TRAFODION.SCH.T032T1
--- Definition current  Wed Sep 14 14:50:10 2016
+-- Definition current  Wed Sep 21 02:57:14 2016
 
   (
     A                                INT NO DEFAULT NOT NULL NOT DROPPABLE
@@ -140,7 +140,7 @@ B
 (EXPR)                        
 ------------------------------
 
-RANDOMVAL=1244080372          
+RANDOMVAL=323996797           
 
 --- 1 row(s) selected.
 >>select random() from (values(1)) x(a);
@@ -205,6 +205,33 @@ AA
                    3
 
 --- 2 row(s) selected.
+>>select a+1 aa from t032t1 order by a+1;
+
+AA                  
+--------------------
+
+                   2
+                   3
+
+--- 2 row(s) selected.
+>>select a+1 aa from t032t1 order by aa;
+
+AA                  
+--------------------
+
+                   2
+                   3
+
+--- 2 row(s) selected.
+>>select a+1 aa from t032t1 order by 1;
+
+AA                  
+--------------------
+
+                   2
+                   3
+
+--- 2 row(s) selected.
 >>select * from (select b from t032t1 order by b desc) x(z);
 
 Z   
@@ -238,6 +265,14 @@ Z
                    2
 
 --- 1 row(s) selected.
+>>select count(*) cc from t032t1 order by count(*) desc;
+
+CC                  
+--------------------
+
+                   2
+
+--- 1 row(s) selected.
 >>select count(distinct a) from t032t1 order by count(distinct a);
 
 (EXPR)              
@@ -361,7 +396,7 @@ A
 >>invoke t032t2;
 
 -- Definition of Trafodion table TRAFODION.T032SCH.T032T2
--- Definition current  Wed Sep 14 14:50:21 2016
+-- Definition current  Wed Sep 21 02:57:30 2016
 
   (
     SYSKEY                           LARGEINT NO DEFAULT NOT NULL NOT DROPPABLE

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/6ad9a9a4/core/sql/regress/seabase/TEST032
----------------------------------------------------------------------
diff --git a/core/sql/regress/seabase/TEST032 b/core/sql/regress/seabase/TEST032
index cafd1f9..c16fd8e 100644
--- a/core/sql/regress/seabase/TEST032
+++ b/core/sql/regress/seabase/TEST032
@@ -70,10 +70,14 @@ select cast('a' as int) from dual;
 select a aa from t032t1 group by aa;
 select a+1 from t032t1 group by a+1;
 select a+1 from t032t1 order by a+1;
+select a+1 aa from t032t1 order by a+1;
+select a+1 aa from t032t1 order by aa;
+select a+1 aa from t032t1 order by 1;
 select * from (select b from t032t1 order by b desc) x(z);
 select * from (select [first 1] a from t032t1) x(z);
 select count(*) from t032t1 order by count(*);
 select count(*) from t032t1 order by count(*) desc;
+select count(*) cc from t032t1 order by count(*) desc;
 select count(distinct a) from t032t1 order by count(distinct a);
 
 -- error cases

Reply via email to