From 7b235eebd5dda9074e2b7724e6b290f49c1bb8ce Mon Sep 17 00:00:00 2001 From: Joe McDonnell Date: Wed, 6 Apr 2022 14:41:18 -0700 Subject: [PATCH] IMPALA-11230: Add test for crash in partitioned Top-N codegen code User workloads hit a crash for certain queries that use partitioned Top-N operators. The crash occurred only when codegen is enabled. After investigation, the crash was due to a nullptr being passed into TupleRowComparator::Compare(). The issue was fixed as part of IMPALA-10961. This adds a test case with a SQL statement that triggers a crash if IMPALA-10961 is not present. Change-Id: I6909ef660b01ad3d301273deb8a8c31120445f79 Reviewed-on: http://gerrit.cloudera.org:8080/18389 Reviewed-by: Aman Sinha Tested-by: Impala Public Jenkins --- .../analytic-fns-tpcds-partitioned-topn.test | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/testdata/workloads/functional-query/queries/QueryTest/analytic-fns-tpcds-partitioned-topn.test b/testdata/workloads/functional-query/queries/QueryTest/analytic-fns-tpcds-partitioned-topn.test index 87b1110a1..8cbaac883 100644 --- a/testdata/workloads/functional-query/queries/QueryTest/analytic-fns-tpcds-partitioned-topn.test +++ b/testdata/workloads/functional-query/queries/QueryTest/analytic-fns-tpcds-partitioned-topn.test @@ -323,3 +323,17 @@ STRING, STRING, STRING, STRING, DECIMAL, DECIMAL, DECIMAL, DECIMAL, DECIMAL, DEC # Confirm that heaps were actually evicted due to memory pressure. row_regex: .*InMemoryHeapsEvicted: .* \([1-9][0-9]*\) ==== +---- QUERY +# IMPALA-11230: This is a minimal reproducing case for a crash in +# partitioned top-n codegen. This query requires a valid ScalarExprEvaluator +# in the TupleRowComparator::Compare() call. This was fixed by IMPALA-10961. +select count(*) +from ( + select row_number() OVER (PARTITION BY ss_sold_date_sk ORDER BY CASE WHEN ss_promo_sk IN (101, 84) THEN 1 ELSE 0 END DESC) RN + from tpcds.store_sales) c +where c.rn = 1; +---- RESULTS +1824 +---- TYPES +BIGINT +==== \ No newline at end of file