Files
impala/testdata/workloads/functional-query/queries/QueryTest/udf-init-close.test
Tim Armstrong 88448d1d4a IMPALA-4586: don't constant fold in backend
This patch ensures that setting the query option
enable_expr_rewrites=false will disable both constant folding in the
frontend (which it did already) and constant caching in the backend
(which is enabled in this patch). This gives a way for users to revert
to the old behaviour of non-deterministic UDFs before these
optimisations were added in Impala 2.8.

Before this patch, the backend would cache values based on IsConstant().
This meant that there was no way to override caching of values of
non-deterministic UDFs, e.g. with enable_expr_rewrites.

After this patch, we only cache literal values in the backend. This
offers the same performance as before in the common case where the
frontend will constant fold the expressions anyway.

Also rename some functions to more cleanly separate the backend concepts
of "constant" expressions and expressions that can be evaluated without
a TupleRow. In a future change (IMPALA-4617) we should remove the
IsConstant() analysis logic from the backend entirely and pass the
information from the frontend. We should also fix isConstant() in the
frontend so that it only returns true when it is safe to constant-fold
the expression (IMPALA-4606). Once that is done, we could revert back
to using IsConstant() instead of IsLiteral().

Testing:
Added targeted test to test constant folding of UDFs: we expect
different results depending on whether constant folding is enabled.

Also run TestUdfs with expr rewrites enabled and disabled, since this
can exercise different code paths. Refactored test_udfs somewhat to
avoid running uninteresting combinations of query options for
targeted tests and removed some 'drop * if not exists' statements
that aren't necessary when using unique_database.

This change revealed flakiness in test_mem_limit, which seems
to have only worked by coincidence. Updated TrackAllocation() to
actually set the query status when a memory limit is exceeded.
Looped this test for a while to make sure it isn't flaky any
more.

Also fix other test bugs where the vector argument is modified
in-place, which can leak out to other tests.

Change-Id: I0c76e3c8a8d92749256c312080ecd7aac5d99ce7
Reviewed-on: http://gerrit.cloudera.org:8080/5391
Reviewed-by: Tim Armstrong <tarmstrong@cloudera.com>
Tested-by: Impala Public Jenkins
2016-12-08 04:53:53 +00:00

114 lines
2.1 KiB
Plaintext

====
---- QUERY
# hdfs table sink
drop table if exists udfinserttest;
create table udfinserttest (udf_was_opened boolean);
insert overwrite table udfinserttest
select validate_open(int_col) from functional.alltypestiny limit 1;
====
---- QUERY
select * from udfinserttest;
---- TYPES
boolean
---- RESULTS
true
====
---- QUERY
# merge node
select validate_open(0);
---- TYPES
boolean
---- RESULTS
true
====
---- QUERY
# merge node with conjuncts
select validate_open(0) from functional.alltypestiny where validate_open(0) limit 1;
---- TYPES
boolean
---- RESULTS
true
====
---- QUERY
# hdfs scan node
select count(*) from functional.alltypestiny where validate_open(int_col);
---- TYPES
bigint
---- RESULTS
8
====
---- QUERY
# aggregation
select validate_open(int_col), count(*) from functional.alltypestiny
group by validate_open(int_col)
---- TYPES
boolean, bigint
---- RESULTS
true,8
====
---- QUERY
# aggregation
select count(if(validate_open(int_col), null, 1)) from functional.alltypestiny
---- TYPES
bigint
---- RESULTS
0
====
---- QUERY
# aggregation (conjuncts)
select int_col, count(*) from functional.alltypestiny
group by int_col having validate_open(int_col)
---- TYPES
int, bigint
---- RESULTS
0,4
1,4
====
---- QUERY
# hash join
select b.bool_col from functional.alltypestiny a join functional.alltypestiny b
on validate_open(a.int_col) = b.bool_col
where a.month = 3 and b.month = 3
---- TYPES
boolean
---- RESULTS
true
true
====
---- QUERY
# hash join (other join predicate)
select count(*) from functional.alltypestiny a left outer join functional.alltypessmall b
on (a.bigint_col = b.bigint_col and validate_open(a.int_col))
---- TYPES
bigint
---- RESULTS
96
====
---- QUERY
# hash join (other predicate)
select count(*) from functional.alltypestiny a left outer join functional.alltypessmall b
on (a.bigint_col = b.bigint_col)
where validate_open(a.int_col) = validate_open(b.int_col)
and validate_open(a.int_col)
---- TYPES
bigint
---- RESULTS
96
====
---- QUERY
# coordinator
select validate_open(int_col) from functional.alltypestiny;
---- TYPES
boolean
---- RESULTS
true
true
true
true
true
true
true
true
====