MCPcopy Index your code
hub / github.com/pathwaycom/pathway / assert_schemas_the_same

Function assert_schemas_the_same

python/pathway/tests/utils.py:561–590  ·  view source on GitHub ↗
(table: Table, expected: Table)

Source from the content-addressed store, hash-verified

559
560def run_graph_and_validate_result(verifier: Callable, assert_schemas=True):
561 def assert_schemas_the_same(table: Table, expected: Table):
562 table_schema_dict = table.schema.typehints()
563 expected_schema_dict = expected.schema.typehints()
564 columns_schema_dict = schema_from_columns(
565 table._columns, table._id_column
566 ).typehints()
567 if assert_schemas:
568 if columns_schema_dict != table_schema_dict:
569 raise RuntimeError(
570 f"Output schema validation error, columns {columns_schema_dict} vs table {table_schema_dict}" # noqa
571 )
572
573 if not (
574 is_subschema(table.schema, expected.schema)
575 and is_subschema(expected.schema, table.schema)
576 ):
577 raise RuntimeError(
578 f"Output schema validation error, table {table_schema_dict} vs expected {expected_schema_dict}" # noqa
579 )
580 # assert table.schema._id_dtype == expected.schema._id_dtype
581 else:
582 assert columns_schema_dict != table_schema_dict or not (
583 is_subschema(table.schema, expected.schema)
584 and is_subschema(expected.schema, table.schema)
585 ), "wo_types is not needed"
586
587 if list(table.column_names()) != list(expected.column_names()):
588 raise RuntimeError(
589 f"Mismatched column names, {list(table.column_names())} vs {list(expected.column_names())}"
590 )
591
592 def inner(
593 table: Table | tuple[Table, ...], expected: Table | tuple[Table, ...], **kwargs

Callers 1

innerFunction · 0.85

Calls 4

schema_from_columnsFunction · 0.90
is_subschemaFunction · 0.90
typehintsMethod · 0.45
column_namesMethod · 0.45

Tested by

no test coverage detected