Files
impala/testdata/workloads/functional-query/queries/QueryTest/query-resource-limits.test
poojanilangekar 6601327af6 IMPALA-8096: Add rows produced limit per query
This patch limits the number of rows produced by a query by
tracking it at the PlanRootSink level. When the
NUM_ROWS_PRODUCED_LIMIT is set, it cancels a query when its
execution produces more rows than the specified limit. This limit
only applies when the results are returned to a client, e.g. for a
SELECT query, but not an INSERT query.

Testing:
Added tests to query-resource-limits.test to verify that the rows
produced limit is honored.
Manually tested on various combinations of tables, fileformats
and ROWS_RETURNED_LIMIT values.

Change-Id: I7b22dbe130a368f4be1f3662a559eb9aae7f0c1d
Reviewed-on: http://gerrit.cloudera.org:8080/12328
Reviewed-by: Tim Armstrong <tarmstrong@cloudera.com>
Tested-by: Impala Public Jenkins <impala-public-jenkins@cloudera.com>
2019-02-07 21:41:52 +00:00

71 lines
2.5 KiB
Plaintext

====
---- QUERY
# Query should succeed.
set CPU_LIMIT_S=10000;
set SCAN_BYTES_LIMIT="10G";
select id from functional.alltypessmall order by 1 limit 1
---- TYPES
INT
---- RESULTS
0
====
---- QUERY
# Query should fail due to exceeding scan bytes limit.
# Added a sleep to make sure it runs long enough to get a non-zero update from the
# fragment instances on the num of bytes read and cpu time.
set SCAN_BYTES_LIMIT="100M";
select sleep(10000) union select count(*) from tpch.lineitem l1,tpch.lineitem l2,
tpch.lineitem l3 where l1.l_suppkey = l2.l_linenumber and l1.l_orderkey = l2.l_orderkey
and l1.l_orderkey = l3.l_orderkey group by l1.l_comment, l2.l_comment having count(*) = 99
---- CATCH
row_regex:.*terminated due to scan bytes limit of 100.00 M.*
====
---- QUERY
# Query should fail due to CPU time limit.
# Added a sleep to make sure it runs long enough to get a non-zero update from the
# fragment instances on the num of bytes read and cpu time.
set CPU_LIMIT_S=1;
select sleep(10000) union select count(*) from tpch.lineitem l1,tpch.lineitem l2,
tpch.lineitem l3 where l1.l_suppkey = l2.l_linenumber and l1.l_orderkey = l2.l_orderkey
and l1.l_orderkey = l3.l_orderkey group by l1.l_comment, l2.l_comment having count(*) = 99
---- CATCH
row_regex:.*terminated due to CPU limit of 1s000ms.*
====
---- QUERY
# Query should fail due to CPU time limit.
# Added a sleep to make sure it runs long enough to get a non-zero update from the
# fragment instances on the num of bytes read and cpu time.
set CPU_LIMIT_S=1;
set SCAN_BYTES_LIMIT="100G";
select sleep(10000) union select count(*) from tpch.lineitem l1,tpch.lineitem l2,
tpch.lineitem l3 where l1.l_suppkey = l2.l_linenumber and l1.l_orderkey = l2.l_orderkey
and l1.l_orderkey = l3.l_orderkey group by l1.l_comment, l2.l_comment having count(*) = 99
---- CATCH
row_regex:.*terminated due to CPU limit of 1s000ms.*
====
---- QUERY
# Query should fail due to exceeding time limit.
set EXEC_TIME_LIMIT_S=2;
select sleep(10000)
---- CATCH
row_regex:.*expired due to execution time limit of 2s000ms.*
====
---- QUERY
# Query should fail due to exceeding rows produced limit.
set NUM_ROWS_PRODUCED_LIMIT = 10000;
select * from tpch.lineitem;
---- CATCH
row_regex:.*terminated due to rows produced limit of 10000.*
====
---- QUERY
# The query should succeed when it doesn't exceed the rows produced limit.
set NUM_ROWS_PRODUCED_LIMIT = 3;
select * from functional.tinytable;
---- TYPES
STRING,STRING
---- RESULTS
'aaaaaaa','bbbbbbb'
'ccccc','dddd'
'eeeeeeee','f'
====