mirror of
https://github.com/apache/impala.git
synced 2026-01-06 06:01:03 -05:00
There was a new test file in cdh4 which had the wrong datatypes for tpcds. Change-Id: Ide1300d0a539d1f40a4c0763b44d06fd81c96204 Reviewed-on: http://gerrit.sjc.cloudera.com:8080/4590 Reviewed-by: Ishaan Joshi <ishaan@cloudera.com> Tested-by: Ishaan Joshi <ishaan@cloudera.com>
176 lines
3.8 KiB
Plaintext
176 lines
3.8 KiB
Plaintext
====
|
|
---- QUERY
|
|
# Analyic function with no partition
|
|
select i_item_sk, i_current_price,
|
|
SUM (i_current_price)
|
|
OVER (ORDER BY i_item_sk) running_total
|
|
from item
|
|
order by
|
|
i_brand,
|
|
i_item_sk
|
|
limit 10
|
|
---- RESULTS
|
|
462,5.94,4489.26
|
|
780,NULL,7182.69
|
|
1146,NULL,11135.77
|
|
1329,0.63,12916.92
|
|
2029,NULL,19805.63
|
|
2723,0.46,26728.77
|
|
2999,NULL,29348.44
|
|
3016,NULL,29496.80
|
|
4099,NULL,40021.33
|
|
5030,NULL,48186.57
|
|
---- TYPES
|
|
BIGINT, DECIMAL, DECIMAL
|
|
====
|
|
---- QUERY
|
|
# Same as above, but with partition
|
|
select i_item_sk, i_brand, i_current_price,
|
|
SUM (i_current_price)
|
|
OVER (partition by i_brand ORDER BY i_item_sk) running_total
|
|
from item
|
|
order by
|
|
i_brand,
|
|
i_item_sk
|
|
limit 10
|
|
---- RESULTS
|
|
462,'',5.94,5.94
|
|
780,'',NULL,5.94
|
|
1146,'',NULL,5.94
|
|
1329,'',0.63,6.57
|
|
2029,'',NULL,6.57
|
|
2723,'',0.46,7.03
|
|
2999,'',NULL,7.03
|
|
3016,'',NULL,7.03
|
|
4099,'',NULL,7.03
|
|
5030,'',NULL,7.03
|
|
---- TYPES
|
|
BIGINT, STRING, DECIMAL, DECIMAL
|
|
====
|
|
---- QUERY
|
|
# Same as above, but the order by column in the analytic function has repeating values
|
|
select i_item_sk, i_brand, i_current_price,
|
|
SUM (i_current_price)
|
|
OVER (partition by i_brand ORDER BY i_current_price) running_total
|
|
from item
|
|
order by
|
|
i_brand,
|
|
i_item_sk
|
|
limit 10
|
|
---- RESULTS
|
|
462,'',5.94,22.57
|
|
780,'',NULL,127.10
|
|
1146,'',NULL,127.10
|
|
1329,'',0.63,1.45
|
|
2029,'',NULL,127.10
|
|
2723,'',0.46,0.82
|
|
2999,'',NULL,127.10
|
|
3016,'',NULL,127.10
|
|
4099,'',NULL,127.10
|
|
5030,'',NULL,127.10
|
|
---- TYPES
|
|
BIGINT, STRING, DECIMAL, DECIMAL
|
|
====
|
|
---- QUERY
|
|
# Nested analyic functions
|
|
select i_item_sk, i_brand, running_total,
|
|
SUM (running_total)
|
|
OVER (partition by i_manufact_id ORDER BY running_total) running_total2
|
|
from (
|
|
select i_item_sk, i_brand, i_current_price, i_manufact_id,
|
|
SUM (i_current_price)
|
|
OVER (partition by i_brand ORDER BY i_current_price) running_total
|
|
from item
|
|
order by
|
|
i_brand,
|
|
i_item_sk
|
|
) sub
|
|
order by
|
|
i_item_sk,
|
|
i_brand desc
|
|
limit 10
|
|
---- RESULTS
|
|
1,'exportischolar #2',988.61,5055.15
|
|
2,'amalgamalg #1',17.76,92.01
|
|
3,'brandbrand #4',37.69,243.96
|
|
4,'importoexporti #1',26.69,82.85
|
|
5,'importoimporto #2',243.76,1132.66
|
|
6,'exportiimporto #1',10.73,38.84
|
|
7,'amalgexporti #2',850.23,6619.62
|
|
8,'exportiexporti #1',100.41,514.95
|
|
9,'edu packamalg #2',292.44,1274.12
|
|
10,'namelessunivamalg #11',16.46,51.79
|
|
---- TYPES
|
|
BIGINT, STRING, DECIMAL, DECIMAL
|
|
====
|
|
---- QUERY
|
|
# 2 analyic functions on different partition and order by columns
|
|
select i_item_sk, i_brand, i_current_price, i_manufact_id,
|
|
SUM (i_current_price)
|
|
OVER (partition by i_brand ORDER BY i_current_price) running_total,
|
|
MAX (i_current_price)
|
|
OVER (partition by i_manufact_id ORDER BY i_item_sk) running_max
|
|
from item
|
|
order by
|
|
i_brand,
|
|
i_item_sk
|
|
limit 10
|
|
---- RESULTS
|
|
462,'',5.94,NULL,22.57,5.94
|
|
780,'',NULL,NULL,127.10,5.94
|
|
1146,'',NULL,510,127.10,3.11
|
|
1329,'',0.63,139,1.45,1.07
|
|
2029,'',NULL,169,127.10,7.56
|
|
2723,'',0.46,NULL,0.82,5.94
|
|
2999,'',NULL,NULL,127.10,5.94
|
|
3016,'',NULL,272,127.10,4.85
|
|
4099,'',NULL,273,127.10,24.17
|
|
5030,'',NULL,289,127.10,28.80
|
|
---- TYPES
|
|
BIGINT, STRING, DECIMAL, INT, DECIMAL, DECIMAL
|
|
====
|
|
---- QUERY
|
|
# Union all in the FROM subquery
|
|
select i_item_sk, i_brand, i_current_price,
|
|
SUM (i_current_price)
|
|
OVER (partition by i_brand ORDER BY i_item_sk) running_total
|
|
from (
|
|
select * from item
|
|
union all
|
|
select * from item
|
|
) sub
|
|
order by
|
|
i_brand,
|
|
i_item_sk
|
|
limit 10
|
|
---- RESULTS
|
|
462,'',5.94,11.88
|
|
462,'',5.94,11.88
|
|
780,'',NULL,11.88
|
|
780,'',NULL,11.88
|
|
1146,'',NULL,11.88
|
|
1146,'',NULL,11.88
|
|
1329,'',0.63,13.14
|
|
1329,'',0.63,13.14
|
|
2029,'',NULL,13.14
|
|
2029,'',NULL,13.14
|
|
---- TYPES
|
|
BIGINT, STRING, DECIMAL, DECIMAL
|
|
====
|
|
---- QUERY
|
|
# Aggregate the column generated by the analytic function
|
|
select max(running_total)
|
|
from (
|
|
select i_item_sk, i_current_price,
|
|
SUM (i_current_price)
|
|
OVER (partition by i_brand ORDER BY i_current_price) running_total
|
|
from item
|
|
order by
|
|
i_brand,
|
|
i_item_sk
|
|
) sub
|
|
---- RESULTS
|
|
2815.26
|
|
---- TYPES
|
|
DECIMAL
|
|
==== |