IMPALA-5262: test_analytic_order_by_random fails with assert

This was a poorly written test that relies on assumptions about
the behavior of 'rand' and the order that rows get processed in
a table that Impala doesn't actually guarantee.

The new version is still sensitive to the precise behavior of
'rand()', but shouldn't be flaky unless that behavior is changed.

Change-Id: If1ba8154c2b6a8d508916d85391b95885ef915a9
Reviewed-on: http://gerrit.cloudera.org:8080/6775
Reviewed-by: Alex Behm <alex.behm@cloudera.com>
Tested-by: Impala Public Jenkins
This commit is contained in:
Thomas Tauber-Marshall
2017-05-01 16:13:40 -07:00
committed by Impala Public Jenkins
parent 5803a0b074
commit 698f4a34c6

View File

@@ -188,10 +188,8 @@ class TestRandomSort(ImpalaTestSuite):
def test_analytic_order_by_random(self):
"""Tests that a window function over 'order by random()' works as expected."""
# Since we use the same random seed and a very small table, the following queries
# should be equivalent.
results = transpose_results(self.execute_query("select id from "
"functional.alltypestiny order by random(2)").data)
analytic_results = transpose_results(self.execute_query("select last_value(id) over "
"(order by random(2)) from functional.alltypestiny").data)
assert results == analytic_results
# Since we use the same random seed, the results should be returned in order.
query = """select last_value(rand(2)) over (order by rand(2)) from
functional.alltypestiny"""
results = transpose_results(self.execute_query(query).data, lambda x: float(x))
assert (results == sorted(results))