You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by mg...@apache.org on 2020/04/22 16:51:02 UTC

[hive] branch master updated: HIVE-23263 Add fix order to cbo_rp_limit.q queries + improve readability (Miklos Gergely, reviewed by Laszlo Bodor)

This is an automated email from the ASF dual-hosted git repository.

mgergely pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hive.git


The following commit(s) were added to refs/heads/master by this push:
     new df825b9  HIVE-23263 Add fix order to cbo_rp_limit.q queries + improve readability (Miklos Gergely, reviewed by Laszlo Bodor)
df825b9 is described below

commit df825b9ac052e003b32b26efeb844dc0e0f332ed
Author: miklosgergely <mg...@cloudera.com>
AuthorDate: Tue Apr 21 13:22:21 2020 +0200

    HIVE-23263 Add fix order to cbo_rp_limit.q queries + improve readability (Miklos Gergely, reviewed by Laszlo Bodor)
---
 ql/src/test/queries/clientpositive/cbo_rp_limit.q  | 105 +++++++++-
 .../results/clientpositive/llap/cbo_rp_limit.q.out | 218 ++++++++++++++++++---
 2 files changed, 294 insertions(+), 29 deletions(-)

diff --git a/ql/src/test/queries/clientpositive/cbo_rp_limit.q b/ql/src/test/queries/clientpositive/cbo_rp_limit.q
index 19c0522..1fe7edc 100644
--- a/ql/src/test/queries/clientpositive/cbo_rp_limit.q
+++ b/ql/src/test/queries/clientpositive/cbo_rp_limit.q
@@ -9,13 +9,104 @@ set hive.stats.fetch.column.stats=true;
 set hive.auto.convert.join=false;
 
 -- 7. Test Select + TS + Join + Fil + GB + GB Having + Limit
-select key, (c_int+1)+2 as x, sum(c_int) from cbo_t1 group by c_float, cbo_t1.c_int, key order by x,key limit 1;
+  SELECT key, (c_int+1)+2 AS x, sum(c_int)
+    FROM cbo_t1
+GROUP BY c_float, cbo_t1.c_int, key
+ORDER BY x, key
+   LIMIT 1;
+
 -- annoying spaces in the key
-select distinct "<"||key||">", (c_int+c_float+1+2) as x, sum(c_int) as y from cbo_t1 group by c_float, cbo_t1.c_int, key limit 2;
-select x, y, count(*) from (select key, (c_int+c_float+1+2) as x, sum(c_int) as y from cbo_t1 group by c_float, cbo_t1.c_int, key) R group by y, x order by x,y limit 5;
-select key from(select key from (select key from cbo_t1 limit 5)cbo_t2  limit 5)cbo_t3  limit 5;
-select key, c_int from(select key, c_int from (select key, c_int from cbo_t1 order by c_int limit 5)cbo_t1  order by c_int limit 5)cbo_t2  order by c_int limit 5;
+  SELECT DISTINCT "<"||key||">", (c_int+c_float+1+2) AS x, sum(c_int) AS y
+    FROM cbo_t1
+GROUP BY c_float, cbo_t1.c_int, key
+   LIMIT 2;
+
+  SELECT x, y, count(*)
+    FROM (SELECT key, (c_int+c_float+1+2) AS x, sum(c_int) AS y
+            FROM cbo_t1
+        GROUP BY c_float, cbo_t1.c_int, key
+         ) R
+GROUP BY y, x
+ORDER BY x, y
+   LIMIT 5;
+
+SELECT key
+  FROM (SELECT key
+          FROM (SELECT key
+                  FROM cbo_t1
+              ORDER BY key
+                 LIMIT 5
+               ) cbo_t2
+         LIMIT 5
+       ) cbo_t3
+ LIMIT 5;
+
+  SELECT key, c_int
+    FROM (SELECT key, c_int
+            FROM (SELECT key, c_int
+                    FROM cbo_t1
+                ORDER BY c_int, key
+                   LIMIT 5
+                 ) cbo_t1
+        ORDER BY c_int
+           LIMIT 5
+         ) cbo_t2
+ORDER BY c_int
+   LIMIT 5;
 
-select cbo_t3.c_int, c, count(*) from (select key as a, c_int+1 as b, sum(c_int) as c from cbo_t1 where (cbo_t1.c_int + 1 >= 0) and (cbo_t1.c_int > 0 or cbo_t1.c_float >= 0) group by c_float, cbo_t1.c_int, key order by a limit 5) cbo_t1 join (select key as p, c_int+1 as q, sum(c_int) as r from cbo_t2 where (cbo_t2.c_int + 1 >= 0) and (cbo_t2.c_int > 0 or cbo_t2.c_float >= 0)  group by c_float, cbo_t2.c_int, key order by q/10 desc, r asc limit 5) cbo_t2 on cbo_t1.a=p join cbo_t3 on cbo_t1 [...]
+  SELECT cbo_t3.c_int, c, count(*)
+    FROM (SELECT key AS a, c_int+1 AS b, sum(c_int) AS c
+            FROM cbo_t1
+           WHERE (cbo_t1.c_int + 1 >= 0)
+             AND (cbo_t1.c_int > 0 OR cbo_t1.c_float >= 0)
+        GROUP BY c_float, cbo_t1.c_int, key
+        ORDER BY a, b
+           LIMIT 5
+         ) cbo_t1
+    JOIN (SELECT key AS p, c_int+1 AS q, sum(c_int) AS r
+            FROM cbo_t2
+           WHERE (cbo_t2.c_int + 1 >= 0)
+             AND (cbo_t2.c_int > 0 OR cbo_t2.c_float >= 0)
+        GROUP BY c_float, cbo_t2.c_int, key
+        ORDER BY q/10 DESC, r ASC, p ASC
+           LIMIT 5
+         ) cbo_t2 ON cbo_t1.a = p
+    JOIN cbo_t3 ON cbo_t1.a = key
+   WHERE (b + cbo_t2.q >= 0)
+     AND (b > 0 OR c_int >= 0)
+GROUP BY cbo_t3.c_int, c
+ORDER BY cbo_t3.c_int + c DESC, c ASC
+   LIMIT 5;
 
-select cbo_t3.c_int, c, count(*) from (select key as a, c_int+1 as b, sum(c_int) as c from cbo_t1 where (cbo_t1.c_int + 1 >= 0) and (cbo_t1.c_int > 0 or cbo_t1.c_float >= 0)  group by c_float, cbo_t1.c_int, key having cbo_t1.c_float > 0 and (c_int >=1 or c_float >= 1) and (c_int + c_float) >= 0 order by b % c asc, b desc limit 5) cbo_t1 left outer join (select key as p, c_int+1 as q, sum(c_int) as r from cbo_t2 where (cbo_t2.c_int + 1 >= 0) and (cbo_t2.c_int > 0 or cbo_t2.c_float >= 0)   [...]
+   SELECT cbo_t3.c_int, c, count(*)
+     FROM (SELECT key AS a, c_int+1 AS b, sum(c_int) AS c
+             FROM cbo_t1
+            WHERE (cbo_t1.c_int + 1 >= 0)
+              AND (cbo_t1.c_int > 0 OR cbo_t1.c_float >= 0)
+         GROUP BY c_float, cbo_t1.c_int, key
+           HAVING cbo_t1.c_float > 0
+              AND (c_int >=1 OR c_float >= 1)
+              AND (c_int + c_float) >= 0
+         ORDER BY b % c ASC, b DESC, a ASC
+            LIMIT 5
+          ) cbo_t1
+LEFT JOIN (SELECT key AS p, c_int+1 AS q, sum(c_int) AS r
+             FROM cbo_t2
+            WHERE (cbo_t2.c_int + 1 >= 0)
+              AND (cbo_t2.c_int > 0 OR cbo_t2.c_float >= 0)
+         GROUP BY c_float, cbo_t2.c_int, key
+           HAVING cbo_t2.c_float > 0
+              AND (c_int >=1 OR c_float >= 1)
+              AND (c_int + c_float) >= 0
+         ORDER BY p, q
+            LIMIT 5
+          ) cbo_t2 ON cbo_t1.a = p
+LEFT JOIN cbo_t3 ON cbo_t1.a = key
+    WHERE (b + cbo_t2.q >= 0)
+      AND (b > 0 OR c_int >= 0)
+ GROUP BY cbo_t3.c_int, c
+   HAVING cbo_t3.c_int > 0
+      AND (c_int >=1 OR c >= 1)
+      AND (c_int + c) >= 0
+ ORDER BY cbo_t3.c_int % c ASC, cbo_t3.c_int, c DESC
+    LIMIT 5;
diff --git a/ql/src/test/results/clientpositive/llap/cbo_rp_limit.q.out b/ql/src/test/results/clientpositive/llap/cbo_rp_limit.q.out
index ecba6e7..e9bb890 100644
--- a/ql/src/test/results/clientpositive/llap/cbo_rp_limit.q.out
+++ b/ql/src/test/results/clientpositive/llap/cbo_rp_limit.q.out
@@ -1,32 +1,60 @@
-PREHOOK: query: select key, (c_int+1)+2 as x, sum(c_int) from cbo_t1 group by c_float, cbo_t1.c_int, key order by x,key limit 1
+PREHOOK: query: SELECT key, (c_int+1)+2 AS x, sum(c_int)
+    FROM cbo_t1
+GROUP BY c_float, cbo_t1.c_int, key
+ORDER BY x, key
+   LIMIT 1
 PREHOOK: type: QUERY
 PREHOOK: Input: default@cbo_t1
 PREHOOK: Input: default@cbo_t1@dt=2014
 #### A masked pattern was here ####
-POSTHOOK: query: select key, (c_int+1)+2 as x, sum(c_int) from cbo_t1 group by c_float, cbo_t1.c_int, key order by x,key limit 1
+POSTHOOK: query: SELECT key, (c_int+1)+2 AS x, sum(c_int)
+    FROM cbo_t1
+GROUP BY c_float, cbo_t1.c_int, key
+ORDER BY x, key
+   LIMIT 1
 POSTHOOK: type: QUERY
 POSTHOOK: Input: default@cbo_t1
 POSTHOOK: Input: default@cbo_t1@dt=2014
 #### A masked pattern was here ####
  1	4	2
-PREHOOK: query: select distinct "<"||key||">", (c_int+c_float+1+2) as x, sum(c_int) as y from cbo_t1 group by c_float, cbo_t1.c_int, key limit 2
+PREHOOK: query: SELECT DISTINCT "<"||key||">", (c_int+c_float+1+2) AS x, sum(c_int) AS y
+    FROM cbo_t1
+GROUP BY c_float, cbo_t1.c_int, key
+   LIMIT 2
 PREHOOK: type: QUERY
 PREHOOK: Input: default@cbo_t1
 PREHOOK: Input: default@cbo_t1@dt=2014
 #### A masked pattern was here ####
-POSTHOOK: query: select distinct "<"||key||">", (c_int+c_float+1+2) as x, sum(c_int) as y from cbo_t1 group by c_float, cbo_t1.c_int, key limit 2
+POSTHOOK: query: SELECT DISTINCT "<"||key||">", (c_int+c_float+1+2) AS x, sum(c_int) AS y
+    FROM cbo_t1
+GROUP BY c_float, cbo_t1.c_int, key
+   LIMIT 2
 POSTHOOK: type: QUERY
 POSTHOOK: Input: default@cbo_t1
 POSTHOOK: Input: default@cbo_t1@dt=2014
 #### A masked pattern was here ####
 < 1 >	5.0	2
 < 1>	5.0	2
-PREHOOK: query: select x, y, count(*) from (select key, (c_int+c_float+1+2) as x, sum(c_int) as y from cbo_t1 group by c_float, cbo_t1.c_int, key) R group by y, x order by x,y limit 5
+PREHOOK: query: SELECT x, y, count(*)
+    FROM (SELECT key, (c_int+c_float+1+2) AS x, sum(c_int) AS y
+            FROM cbo_t1
+        GROUP BY c_float, cbo_t1.c_int, key
+         ) R
+GROUP BY y, x
+ORDER BY x, y
+   LIMIT 5
 PREHOOK: type: QUERY
 PREHOOK: Input: default@cbo_t1
 PREHOOK: Input: default@cbo_t1@dt=2014
 #### A masked pattern was here ####
-POSTHOOK: query: select x, y, count(*) from (select key, (c_int+c_float+1+2) as x, sum(c_int) as y from cbo_t1 group by c_float, cbo_t1.c_int, key) R group by y, x order by x,y limit 5
+POSTHOOK: query: SELECT x, y, count(*)
+    FROM (SELECT key, (c_int+c_float+1+2) AS x, sum(c_int) AS y
+            FROM cbo_t1
+        GROUP BY c_float, cbo_t1.c_int, key
+         ) R
+GROUP BY y, x
+ORDER BY x, y
+   LIMIT 5
 POSTHOOK: type: QUERY
 POSTHOOK: Input: default@cbo_t1
 POSTHOOK: Input: default@cbo_t1@dt=2014
@@ -34,37 +62,99 @@ POSTHOOK: Input: default@cbo_t1@dt=2014
 5.0	2	3
 5.0	12	1
 NULL	NULL	1
-PREHOOK: query: select key from(select key from (select key from cbo_t1 limit 5)cbo_t2  limit 5)cbo_t3  limit 5
+PREHOOK: query: SELECT key
+  FROM (SELECT key
+          FROM (SELECT key
+                  FROM cbo_t1
+              ORDER BY key
+                 LIMIT 5
+               ) cbo_t2
+         LIMIT 5
+       ) cbo_t3
+ LIMIT 5
 PREHOOK: type: QUERY
 PREHOOK: Input: default@cbo_t1
 PREHOOK: Input: default@cbo_t1@dt=2014
 #### A masked pattern was here ####
-POSTHOOK: query: select key from(select key from (select key from cbo_t1 limit 5)cbo_t2  limit 5)cbo_t3  limit 5
+POSTHOOK: query: SELECT key
+  FROM (SELECT key
+          FROM (SELECT key
+                  FROM cbo_t1
+              ORDER BY key
+                 LIMIT 5
+               ) cbo_t2
+         LIMIT 5
+       ) cbo_t3
+ LIMIT 5
 POSTHOOK: type: QUERY
 POSTHOOK: Input: default@cbo_t1
 POSTHOOK: Input: default@cbo_t1@dt=2014
 #### A masked pattern was here ####
+ 1
+ 1
+ 1 
+ 1 
 1
-1
-1
-1
-1
-PREHOOK: query: select key, c_int from(select key, c_int from (select key, c_int from cbo_t1 order by c_int limit 5)cbo_t1  order by c_int limit 5)cbo_t2  order by c_int limit 5
+PREHOOK: query: SELECT key, c_int
+    FROM (SELECT key, c_int
+            FROM (SELECT key, c_int
+                    FROM cbo_t1
+                ORDER BY c_int, key
+                   LIMIT 5
+                 ) cbo_t1
+        ORDER BY c_int
+           LIMIT 5
+         ) cbo_t2
+ORDER BY c_int
+   LIMIT 5
 PREHOOK: type: QUERY
 PREHOOK: Input: default@cbo_t1
 PREHOOK: Input: default@cbo_t1@dt=2014
 #### A masked pattern was here ####
-POSTHOOK: query: select key, c_int from(select key, c_int from (select key, c_int from cbo_t1 order by c_int limit 5)cbo_t1  order by c_int limit 5)cbo_t2  order by c_int limit 5
+POSTHOOK: query: SELECT key, c_int
+    FROM (SELECT key, c_int
+            FROM (SELECT key, c_int
+                    FROM cbo_t1
+                ORDER BY c_int, key
+                   LIMIT 5
+                 ) cbo_t1
+        ORDER BY c_int
+           LIMIT 5
+         ) cbo_t2
+ORDER BY c_int
+   LIMIT 5
 POSTHOOK: type: QUERY
 POSTHOOK: Input: default@cbo_t1
 POSTHOOK: Input: default@cbo_t1@dt=2014
 #### A masked pattern was here ####
+ 1	1
+ 1	1
+ 1 	1
+ 1 	1
 1	1
-1	1
-1	1
-1	1
-1	1
-PREHOOK: query: select cbo_t3.c_int, c, count(*) from (select key as a, c_int+1 as b, sum(c_int) as c from cbo_t1 where (cbo_t1.c_int + 1 >= 0) and (cbo_t1.c_int > 0 or cbo_t1.c_float >= 0) group by c_float, cbo_t1.c_int, key order by a limit 5) cbo_t1 join (select key as p, c_int+1 as q, sum(c_int) as r from cbo_t2 where (cbo_t2.c_int + 1 >= 0) and (cbo_t2.c_int > 0 or cbo_t2.c_float >= 0)  group by c_float, cbo_t2.c_int, key order by q/10 desc, r asc limit 5) cbo_t2 on cbo_t1.a=p join  [...]
+PREHOOK: query: SELECT cbo_t3.c_int, c, count(*)
+    FROM (SELECT key AS a, c_int+1 AS b, sum(c_int) AS c
+            FROM cbo_t1
+           WHERE (cbo_t1.c_int + 1 >= 0)
+             AND (cbo_t1.c_int > 0 OR cbo_t1.c_float >= 0)
+        GROUP BY c_float, cbo_t1.c_int, key
+        ORDER BY a, b
+           LIMIT 5
+         ) cbo_t1
+    JOIN (SELECT key AS p, c_int+1 AS q, sum(c_int) AS r
+            FROM cbo_t2
+           WHERE (cbo_t2.c_int + 1 >= 0)
+             AND (cbo_t2.c_int > 0 OR cbo_t2.c_float >= 0)
+        GROUP BY c_float, cbo_t2.c_int, key
+        ORDER BY q/10 DESC, r ASC, p ASC
+           LIMIT 5
+         ) cbo_t2 ON cbo_t1.a = p
+    JOIN cbo_t3 ON cbo_t1.a = key
+   WHERE (b + cbo_t2.q >= 0)
+     AND (b > 0 OR c_int >= 0)
+GROUP BY cbo_t3.c_int, c
+ORDER BY cbo_t3.c_int + c DESC, c ASC
+   LIMIT 5
 PREHOOK: type: QUERY
 PREHOOK: Input: default@cbo_t1
 PREHOOK: Input: default@cbo_t1@dt=2014
@@ -72,7 +162,29 @@ PREHOOK: Input: default@cbo_t2
 PREHOOK: Input: default@cbo_t2@dt=2014
 PREHOOK: Input: default@cbo_t3
 #### A masked pattern was here ####
-POSTHOOK: query: select cbo_t3.c_int, c, count(*) from (select key as a, c_int+1 as b, sum(c_int) as c from cbo_t1 where (cbo_t1.c_int + 1 >= 0) and (cbo_t1.c_int > 0 or cbo_t1.c_float >= 0) group by c_float, cbo_t1.c_int, key order by a limit 5) cbo_t1 join (select key as p, c_int+1 as q, sum(c_int) as r from cbo_t2 where (cbo_t2.c_int + 1 >= 0) and (cbo_t2.c_int > 0 or cbo_t2.c_float >= 0)  group by c_float, cbo_t2.c_int, key order by q/10 desc, r asc limit 5) cbo_t2 on cbo_t1.a=p join [...]
+POSTHOOK: query: SELECT cbo_t3.c_int, c, count(*)
+    FROM (SELECT key AS a, c_int+1 AS b, sum(c_int) AS c
+            FROM cbo_t1
+           WHERE (cbo_t1.c_int + 1 >= 0)
+             AND (cbo_t1.c_int > 0 OR cbo_t1.c_float >= 0)
+        GROUP BY c_float, cbo_t1.c_int, key
+        ORDER BY a, b
+           LIMIT 5
+         ) cbo_t1
+    JOIN (SELECT key AS p, c_int+1 AS q, sum(c_int) AS r
+            FROM cbo_t2
+           WHERE (cbo_t2.c_int + 1 >= 0)
+             AND (cbo_t2.c_int > 0 OR cbo_t2.c_float >= 0)
+        GROUP BY c_float, cbo_t2.c_int, key
+        ORDER BY q/10 DESC, r ASC, p ASC
+           LIMIT 5
+         ) cbo_t2 ON cbo_t1.a = p
+    JOIN cbo_t3 ON cbo_t1.a = key
+   WHERE (b + cbo_t2.q >= 0)
+     AND (b > 0 OR c_int >= 0)
+GROUP BY cbo_t3.c_int, c
+ORDER BY cbo_t3.c_int + c DESC, c ASC
+   LIMIT 5
 POSTHOOK: type: QUERY
 POSTHOOK: Input: default@cbo_t1
 POSTHOOK: Input: default@cbo_t1@dt=2014
@@ -82,7 +194,38 @@ POSTHOOK: Input: default@cbo_t3
 #### A masked pattern was here ####
 1	12	6
 1	2	6
-PREHOOK: query: select cbo_t3.c_int, c, count(*) from (select key as a, c_int+1 as b, sum(c_int) as c from cbo_t1 where (cbo_t1.c_int + 1 >= 0) and (cbo_t1.c_int > 0 or cbo_t1.c_float >= 0)  group by c_float, cbo_t1.c_int, key having cbo_t1.c_float > 0 and (c_int >=1 or c_float >= 1) and (c_int + c_float) >= 0 order by b % c asc, b desc limit 5) cbo_t1 left outer join (select key as p, c_int+1 as q, sum(c_int) as r from cbo_t2 where (cbo_t2.c_int + 1 >= 0) and (cbo_t2.c_int > 0 or cbo_t2 [...]
+PREHOOK: query: SELECT cbo_t3.c_int, c, count(*)
+     FROM (SELECT key AS a, c_int+1 AS b, sum(c_int) AS c
+             FROM cbo_t1
+            WHERE (cbo_t1.c_int + 1 >= 0)
+              AND (cbo_t1.c_int > 0 OR cbo_t1.c_float >= 0)
+         GROUP BY c_float, cbo_t1.c_int, key
+           HAVING cbo_t1.c_float > 0
+              AND (c_int >=1 OR c_float >= 1)
+              AND (c_int + c_float) >= 0
+         ORDER BY b % c ASC, b DESC, a ASC
+            LIMIT 5
+          ) cbo_t1
+LEFT JOIN (SELECT key AS p, c_int+1 AS q, sum(c_int) AS r
+             FROM cbo_t2
+            WHERE (cbo_t2.c_int + 1 >= 0)
+              AND (cbo_t2.c_int > 0 OR cbo_t2.c_float >= 0)
+         GROUP BY c_float, cbo_t2.c_int, key
+           HAVING cbo_t2.c_float > 0
+              AND (c_int >=1 OR c_float >= 1)
+              AND (c_int + c_float) >= 0
+         ORDER BY p, q
+            LIMIT 5
+          ) cbo_t2 ON cbo_t1.a = p
+LEFT JOIN cbo_t3 ON cbo_t1.a = key
+    WHERE (b + cbo_t2.q >= 0)
+      AND (b > 0 OR c_int >= 0)
+ GROUP BY cbo_t3.c_int, c
+   HAVING cbo_t3.c_int > 0
+      AND (c_int >=1 OR c >= 1)
+      AND (c_int + c) >= 0
+ ORDER BY cbo_t3.c_int % c ASC, cbo_t3.c_int, c DESC
+    LIMIT 5
 PREHOOK: type: QUERY
 PREHOOK: Input: default@cbo_t1
 PREHOOK: Input: default@cbo_t1@dt=2014
@@ -90,7 +233,38 @@ PREHOOK: Input: default@cbo_t2
 PREHOOK: Input: default@cbo_t2@dt=2014
 PREHOOK: Input: default@cbo_t3
 #### A masked pattern was here ####
-POSTHOOK: query: select cbo_t3.c_int, c, count(*) from (select key as a, c_int+1 as b, sum(c_int) as c from cbo_t1 where (cbo_t1.c_int + 1 >= 0) and (cbo_t1.c_int > 0 or cbo_t1.c_float >= 0)  group by c_float, cbo_t1.c_int, key having cbo_t1.c_float > 0 and (c_int >=1 or c_float >= 1) and (c_int + c_float) >= 0 order by b % c asc, b desc limit 5) cbo_t1 left outer join (select key as p, c_int+1 as q, sum(c_int) as r from cbo_t2 where (cbo_t2.c_int + 1 >= 0) and (cbo_t2.c_int > 0 or cbo_t [...]
+POSTHOOK: query: SELECT cbo_t3.c_int, c, count(*)
+     FROM (SELECT key AS a, c_int+1 AS b, sum(c_int) AS c
+             FROM cbo_t1
+            WHERE (cbo_t1.c_int + 1 >= 0)
+              AND (cbo_t1.c_int > 0 OR cbo_t1.c_float >= 0)
+         GROUP BY c_float, cbo_t1.c_int, key
+           HAVING cbo_t1.c_float > 0
+              AND (c_int >=1 OR c_float >= 1)
+              AND (c_int + c_float) >= 0
+         ORDER BY b % c ASC, b DESC, a ASC
+            LIMIT 5
+          ) cbo_t1
+LEFT JOIN (SELECT key AS p, c_int+1 AS q, sum(c_int) AS r
+             FROM cbo_t2
+            WHERE (cbo_t2.c_int + 1 >= 0)
+              AND (cbo_t2.c_int > 0 OR cbo_t2.c_float >= 0)
+         GROUP BY c_float, cbo_t2.c_int, key
+           HAVING cbo_t2.c_float > 0
+              AND (c_int >=1 OR c_float >= 1)
+              AND (c_int + c_float) >= 0
+         ORDER BY p, q
+            LIMIT 5
+          ) cbo_t2 ON cbo_t1.a = p
+LEFT JOIN cbo_t3 ON cbo_t1.a = key
+    WHERE (b + cbo_t2.q >= 0)
+      AND (b > 0 OR c_int >= 0)
+ GROUP BY cbo_t3.c_int, c
+   HAVING cbo_t3.c_int > 0
+      AND (c_int >=1 OR c >= 1)
+      AND (c_int + c) >= 0
+ ORDER BY cbo_t3.c_int % c ASC, cbo_t3.c_int, c DESC
+    LIMIT 5
 POSTHOOK: type: QUERY
 POSTHOOK: Input: default@cbo_t1
 POSTHOOK: Input: default@cbo_t1@dt=2014