Override run to verify symbol column null count statistics.
(self)
| 395 | """) |
| 396 | |
| 397 | def run(self) -> bool: |
| 398 | """Override run to verify symbol column null count statistics.""" |
| 399 | test_name = self.__class__.__name__ |
| 400 | |
| 401 | try: |
| 402 | self.setup() |
| 403 | |
| 404 | result = execute_sql(self.host, self.port, f"SELECT count() FROM {self.table_name}") |
| 405 | actual_count = result['dataset'][0][0] |
| 406 | assert actual_count == self.expected_row_count, \ |
| 407 | f"Row count mismatch: expected {self.expected_row_count}, got {actual_count}" |
| 408 | |
| 409 | parquet_path = os.path.join(self.temp_dir, f"{self.table_name}.parquet") |
| 410 | export_parquet(self.host, self.port, f"SELECT * FROM {self.table_name}", parquet_path) |
| 411 | |
| 412 | total_rows, num_row_groups = read_parquet(parquet_path) |
| 413 | |
| 414 | assert total_rows == self.expected_row_count, \ |
| 415 | f"Parquet row count mismatch: expected {self.expected_row_count}, got {total_rows}" |
| 416 | if num_row_groups is not None: |
| 417 | assert num_row_groups >= self.expected_min_row_groups, \ |
| 418 | f"Expected at least {self.expected_min_row_groups} row groups, got {num_row_groups}" |
| 419 | |
| 420 | if READER == "pyarrow": |
| 421 | parquet_file = pq.ParquetFile(parquet_path) |
| 422 | metadata = parquet_file.metadata |
| 423 | schema = parquet_file.schema_arrow |
| 424 | |
| 425 | sym_idx = None |
| 426 | for i, name in enumerate(schema.names): |
| 427 | if name == "sym": |
| 428 | sym_idx = i |
| 429 | break |
| 430 | |
| 431 | assert sym_idx is not None, "sym column not found in schema" |
| 432 | |
| 433 | total_null_count = 0 |
| 434 | for rg_idx in range(metadata.num_row_groups): |
| 435 | col_meta = metadata.row_group(rg_idx).column(sym_idx) |
| 436 | if col_meta.statistics and col_meta.statistics.null_count is not None: |
| 437 | total_null_count += col_meta.statistics.null_count |
| 438 | |
| 439 | assert total_null_count == self.expected_null_count, \ |
| 440 | f"Symbol null count mismatch: expected {self.expected_null_count}, got {total_null_count}" |
| 441 | |
| 442 | print(f"Test '{test_name}' passed.") |
| 443 | return True |
| 444 | |
| 445 | except Exception as e: |
| 446 | print(f"Test '{test_name}' failed: {e}") |
| 447 | return False |
| 448 | |
| 449 | finally: |
| 450 | try: |
| 451 | self.teardown() |
| 452 | except Exception: |
| 453 | pass |
| 454 |
nothing calls this directly
no test coverage detected