add test

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

Branch: refs/heads/master
Commit: fda906dcd94ff28957b32c825e04206e57160841
Parents: e45745f
Author: Liu Ming <ovis_p...@sina.com>
Authored: Sat Jun 2 03:33:32 2018 -0400
Committer: Liu Ming <ovis_p...@sina.com>
Committed: Sat Jun 2 03:33:32 2018 -0400

----------------------------------------------------------------------
 core/sql/optimizer/NormRelExpr.cpp      |  1 -
 core/sql/regress/core/EXPECTED002.LINUX | 15 +++++++++++++++
 core/sql/regress/core/TEST002           |  5 +++++
 3 files changed, 20 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafodion/blob/fda906dc/core/sql/optimizer/NormRelExpr.cpp
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/NormRelExpr.cpp 
b/core/sql/optimizer/NormRelExpr.cpp
index 07df1b0..a30cdbb 100644
--- a/core/sql/optimizer/NormRelExpr.cpp
+++ b/core/sql/optimizer/NormRelExpr.cpp
@@ -7692,7 +7692,6 @@ RelExpr * RelRoot::normalizeNode(NormWA & normWARef)
   if ((reqdOrder().entries() > 0) && 
       (child(0)->getOperatorType() == REL_FIRST_N))
     {
-printf("LMDBG root push order by to firstn\n");
       FirstN * firstn = (FirstN *)child(0)->castToRelExpr();
       if (firstn->isFirstN())  // that is, [first n], not [any n] or [last n]
         firstn->reqdOrder().insert(reqdOrder());

http://git-wip-us.apache.org/repos/asf/trafodion/blob/fda906dc/core/sql/regress/core/EXPECTED002.LINUX
----------------------------------------------------------------------
diff --git a/core/sql/regress/core/EXPECTED002.LINUX 
b/core/sql/regress/core/EXPECTED002.LINUX
index fd9659c..b7dee45 100644
--- a/core/sql/regress/core/EXPECTED002.LINUX
+++ b/core/sql/regress/core/EXPECTED002.LINUX
@@ -867,12 +867,18 @@ A            AMAX         B                   BMAX        
        C            C
 >>create table t002FUI(x int);
 
 --- SQL operation complete.
+>>create table t002sol(x int);
+
+--- SQL operation complete.
 >>insert into  t002FU  values(3),(4);
 
 --- 2 row(s) inserted.
 >>insert into  t002FUI values(13);
 
 --- 1 row(s) inserted.
+>>insert into t002sol values(2),(5),(4),(3),(7);
+
+--- 5 row(s) inserted.
 >>
 >>-- Tables t002ZZ and t002ZZI are empty (have zero rows), tables t002FU and 
 >>t002FUI are full.
 >>--
@@ -1264,4 +1270,13 @@ RESULT_VALUE
 
 --- 1 row(s) selected.
 >>
+>>-- Should return 7
+>>select x from (select [first 1] x from t002sol order by x desc );
+
+X
+----------
+
+ 7
+
+--- 1 row(s) selected.
 >>log;

http://git-wip-us.apache.org/repos/asf/trafodion/blob/fda906dc/core/sql/regress/core/TEST002
----------------------------------------------------------------------
diff --git a/core/sql/regress/core/TEST002 b/core/sql/regress/core/TEST002
index 34529c7..a9db00c 100755
--- a/core/sql/regress/core/TEST002
+++ b/core/sql/regress/core/TEST002
@@ -480,8 +480,10 @@ create table t002ZZ (x int);
 create table t002ZZI(x int);
 create table t002FU (x int);
 create table t002FUI(x int);
+create table t002sol(x int);
 insert into  t002FU  values(3),(4);
 insert into  t002FUI values(13);
+insert into  t002sol values(2),(5),(4),(3),(7);
 
 -- Tables t002ZZ and t002ZZI are empty (have zero rows), tables t002FU and 
t002FUI are full.
 --
@@ -586,6 +588,8 @@ select
 (select [last 0] x from t002sub) as result_value
 from t002main;
 
+-- Should return 7
+select x from (select [first 1] x from t002sol order by x desc );
 log;
 obey TEST002(clnup);
 exit;
@@ -601,6 +605,7 @@ drop table t002ZZ;
 drop table t002ZZI;
 drop table t002FU;
 drop table t002FUI;
+drop table t002sol;
 
 #ifMX
 drop table t002ut1;

Reply via email to