Compare query results with column permutation support
(self, result1: List[Tuple], result2: List[Tuple], order_matters: bool)
| 157 | return itertools.product(*perm_constraints) |
| 158 | |
| 159 | def result_eq(self, result1: List[Tuple], result2: List[Tuple], order_matters: bool) -> bool: |
| 160 | """Compare query results with column permutation support""" |
| 161 | if len(result1) == 0 and len(result2) == 0: |
| 162 | return True |
| 163 | |
| 164 | if len(result1) != len(result2): |
| 165 | return False |
| 166 | |
| 167 | num_cols = len(result1[0]) |
| 168 | if len(result2[0]) != num_cols: |
| 169 | return False |
| 170 | |
| 171 | # Initial quick comparison |
| 172 | if not self.quick_rej(result1, result2, order_matters): |
| 173 | return False |
| 174 | |
| 175 | if result1 == result2: |
| 176 | return True |
| 177 | |
| 178 | # Skip large result sets for performance |
| 179 | if len(result2) > 200 or len(result1) > 200: |
| 180 | return False |
| 181 | |
| 182 | tab1_sets_by_columns = [{row[i] for row in result1} for i in range(num_cols)] |
| 183 | |
| 184 | # Test different column orderings |
| 185 | for perm in self.get_constraint_permutation(tab1_sets_by_columns, result2): |
| 186 | if len(perm) != len(set(perm)): |
| 187 | continue |
| 188 | if num_cols == 1: |
| 189 | result2_perm = result2 |
| 190 | else: |
| 191 | result2_perm = [self.permute_tuple(element, perm) for element in result2] |
| 192 | |
| 193 | if order_matters: |
| 194 | if result1 == result2_perm: |
| 195 | return True |
| 196 | else: |
| 197 | if set(result1) == set(result2_perm) and self.multiset_eq(result1, result2_perm): |
| 198 | return True |
| 199 | return False |
| 200 | |
| 201 | # ==================== SQL Query Processing ==================== |
| 202 |
no test coverage detected