This is an automated email from the ASF dual-hosted git repository.

joemcdonnell pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/impala.git

commit 49126532952f9cee1fab460e94d4c9db6e856073
Author: Joe McDonnell <joemcdonn...@cloudera.com>
AuthorDate: Wed Feb 14 18:01:30 2024 -0800

    IMPALA-12814: Allow use of row_regex for VERIFY_IS_NOT_IN
    
    This adds support for using "row_regex:" entries in the
    VERIFY_IS_NOT_IN sections. There are existing tests that
    already use this formula, but it doesn't actually match
    using the regex. This fixes test_result_verifier.py's
    verify_query_result_is_not_in() to detect the regexes and
    use regex logic for the check.
    
    Testing:
     - Hand tested by adding a "row_regex:.*" to a VERIFY_IS_NOT_IN
       section and verifying it produces an error.
     - Hand tested by adding a "row_regex:match_nothing.*" to
       make sure nothing matched it.
    
    Change-Id: Id856ae7de9727adeaec9487c7bd0c2b81c8e8b37
    Reviewed-on: http://gerrit.cloudera.org:8080/21036
    Tested-by: Impala Public Jenkins <impala-public-jenk...@cloudera.com>
    Reviewed-by: Michael Smith <michael.sm...@cloudera.com>
---
 tests/common/test_result_verifier.py | 24 ++++++++++++++++++++----
 1 file changed, 20 insertions(+), 4 deletions(-)

diff --git a/tests/common/test_result_verifier.py 
b/tests/common/test_result_verifier.py
index 84e324744..ab3680ce6 100644
--- a/tests/common/test_result_verifier.py
+++ b/tests/common/test_result_verifier.py
@@ -295,11 +295,27 @@ def verify_query_result_is_equal(expected_results, 
actual_results):
   assert_args_not_none(expected_results, actual_results)
   assert expected_results == actual_results
 
-def verify_query_result_is_not_in(expected_results, actual_results):
-  assert_args_not_none(expected_results, actual_results)
-  expected_set = set(map(unicode, expected_results.rows))
+
+def verify_query_result_is_not_in(banned_results, actual_results):
+  assert_args_not_none(banned_results, actual_results)
+  banned_literals, banned_non_literals = banned_results.separate_rows()
+
+  # Part 1: No intersection with the banned literals
+  banned_literals_set = set([unicode(row) for row in banned_literals])
   actual_set = set(map(unicode, actual_results.rows))
-  assert expected_set.isdisjoint(actual_set)
+  assert banned_literals_set.isdisjoint(actual_set)
+
+  # Part 2: Walk through each banned non-literal / regex and make sure that no 
row
+  # in the actual output matches.
+  for banned_row in banned_non_literals:
+    matched = False
+    for actual_row in actual_results.rows:
+      # Equals is overloaded, so this is doing a regex check
+      if actual_row == banned_row:
+        matched = True
+        break
+    assert not matched, u"Found banned row {0} in actual rows:\n{1}".format(
+      unicode(banned_row), unicode(actual_results))
 
 # Global dictionary that maps the verification type to appropriate verifier.
 # The RESULTS section of a .test file is tagged with the verifier type. We may

Reply via email to