MCPcopy
hub / github.com/questdb/questdb / run

Method run

compat/src/test/python/runner_parquet.py:505–562  ·  view source on GitHub ↗

Override run to verify symbol column null count statistics.

(self)

Source from the content-addressed store, hash-verified

503 """)
504
505 def run(self) -> bool:
506 """Override run to verify symbol column null count statistics."""
507 test_name = self.__class__.__name__
508
509 try:
510 self.setup()
511
512 result = execute_sql(self.host, self.port, f"SELECT count() FROM {self.table_name}")
513 actual_count = result['dataset'][0][0]
514 assert actual_count == self.expected_row_count, \
515 f"Row count mismatch: expected {self.expected_row_count}, got {actual_count}"
516
517 parquet_path = os.path.join(self.temp_dir, f"{self.table_name}.parquet")
518 export_parquet(self.host, self.port, f"SELECT * FROM {self.table_name}", parquet_path)
519
520 total_rows, num_row_groups = read_parquet(parquet_path)
521
522 assert total_rows == self.expected_row_count, \
523 f"Parquet row count mismatch: expected {self.expected_row_count}, got {total_rows}"
524 if num_row_groups is not None:
525 assert num_row_groups >= self.expected_min_row_groups, \
526 f"Expected at least {self.expected_min_row_groups} row groups, got {num_row_groups}"
527
528 # Verify symbol column null count in statistics (pyarrow only)
529 if READER == "pyarrow":
530 parquet_file = pq.ParquetFile(parquet_path)
531 metadata = parquet_file.metadata
532 schema = parquet_file.schema_arrow
533
534 sym_idx = None
535 for i, name in enumerate(schema.names):
536 if name == "sym":
537 sym_idx = i
538 break
539
540 assert sym_idx is not None, "sym column not found in schema"
541
542 total_null_count = 0
543 for rg_idx in range(metadata.num_row_groups):
544 col_meta = metadata.row_group(rg_idx).column(sym_idx)
545 if col_meta.statistics and col_meta.statistics.null_count is not None:
546 total_null_count += col_meta.statistics.null_count
547
548 assert total_null_count == self.expected_null_count, \
549 f"Symbol null count mismatch: expected {self.expected_null_count}, got {total_null_count}"
550
551 print(f"Test '{test_name}' passed.")
552 return True
553
554 except Exception as e:
555 print(f"Test '{test_name}' failed: {e}")
556 return False
557
558 finally:
559 try:
560 self.teardown()
561 except Exception:
562 pass

Callers

nothing calls this directly

Calls 7

setupMethod · 0.95
teardownMethod · 0.95
execute_sqlFunction · 0.85
export_parquetFunction · 0.85
read_parquetFunction · 0.85
columnMethod · 0.80
joinMethod · 0.65

Tested by

no test coverage detected