(self, vector)
| 48 | self.__run_tablesample(vector) |
| 49 | |
| 50 | def __run_tablesample(self, vector): |
| 51 | repeatable = vector.get_value('repeatable') |
| 52 | filtered = vector.get_value('filtered') |
| 53 | db_name = ImpalaTestSuite.get_db_name_from_format(vector.get_table_format()) |
| 54 | |
| 55 | where_clause = "" |
| 56 | if filtered: |
| 57 | where_clause = "where month between 1 and 6" |
| 58 | |
| 59 | result = self.client.execute("select count(*) from {}.alltypes {}".format( |
| 60 | db_name, where_clause)) |
| 61 | baseline_count = int(result.data[0]) |
| 62 | prev_count = None |
| 63 | for perc in [5, 20, 50, 100]: |
| 64 | rep_sql = "" |
| 65 | if repeatable: rep_sql = " repeatable(1)" |
| 66 | sql_stmt = "select count(*) from {}.alltypes tablesample system({}){} {}".format( |
| 67 | db_name, perc, rep_sql, where_clause) |
| 68 | handle = self.client.execute_async(sql_stmt) |
| 69 | # IMPALA-6352: flaky test, possibly due to a hung thread. Wait for 500 sec before |
| 70 | # failing and logging the backtraces of all impalads. |
| 71 | is_finished = self.client.wait_for_finished_timeout(handle, 500) |
| 72 | assert is_finished, 'Query Timed out. Dumping backtrace of all threads in ' \ |
| 73 | 'impalads:\nthreads in the impalad1: %s \nthreads in the ' \ |
| 74 | 'impalad2: %s \nthreads in the impalad3: %s' % \ |
| 75 | (subprocess.check_output( |
| 76 | "gdb -ex \"set pagination 0\" -ex \"thread apply all bt\" " |
| 77 | "--batch -p $(pgrep impalad | sed -n 1p)", shell=True), |
| 78 | subprocess.check_output( |
| 79 | "gdb -ex \"set pagination 0\" -ex \"thread apply all bt\" " |
| 80 | "--batch -p $(pgrep impalad | sed -n 2p)", shell=True), |
| 81 | subprocess.check_output( |
| 82 | "gdb -ex \"set pagination 0\" -ex \"thread apply all bt\" " |
| 83 | "--batch -p $(pgrep impalad | sed -n 3p)", shell=True)) |
| 84 | result = self.client.fetch(sql_stmt, handle) |
| 85 | self.client.close_query(handle) |
| 86 | count = int(result.data[0]) |
| 87 | if perc < 100: |
| 88 | assert count < baseline_count |
| 89 | else: |
| 90 | assert count == baseline_count |
| 91 | if prev_count and repeatable: |
| 92 | # May not necessarily be true for non-repeatable samples |
| 93 | assert count > prev_count |
| 94 | prev_count = count |
no test coverage detected