Skip to content

Commit

Permalink
Move assert_data_tables_equal.
Browse files Browse the repository at this point in the history
  • Loading branch information
plypaul committed May 31, 2024
1 parent 96b7b6f commit fdcd0bf
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 35 deletions.
30 changes: 0 additions & 30 deletions tests_metricflow/compare_df.py

This file was deleted.

2 changes: 1 addition & 1 deletion tests_metricflow/execution/test_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from metricflow.execution.executor import SequentialPlanExecutor
from metricflow.protocols.sql_client import SqlClient, SqlEngine
from metricflow.sql.sql_table import SqlTable
from tests_metricflow.compare_df import assert_data_tables_equal
from tests_metricflow.sql.compare_data_table import assert_data_tables_equal


def test_read_sql_task(sql_client: SqlClient) -> None: # noqa: D103
Expand Down
2 changes: 1 addition & 1 deletion tests_metricflow/integration/test_configured_cases.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@
SqlStringExpression,
SqlSubtractTimeIntervalExpression,
)
from tests_metricflow.compare_df import assert_data_tables_equal
from tests_metricflow.integration.configured_test_case import (
CONFIGURED_INTEGRATION_TESTS_REPOSITORY,
IntegrationTestModel,
RequiredDwEngineFeature,
)
from tests_metricflow.sql.compare_data_table import assert_data_tables_equal

logger = logging.getLogger(__name__)

Expand Down
22 changes: 22 additions & 0 deletions tests_metricflow/sql/compare_data_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,3 +157,25 @@ def check_data_tables_are_equal(
)

return


def assert_data_tables_equal(
actual: MetricFlowDataTable,
expected: MetricFlowDataTable,
sort_columns: bool = True,
allow_empty: bool = False,
compare_names_using_lowercase: bool = False,
) -> None:
"""Check that contents of DataTables are the same.
If sort_columns is set to false, value and column order needs to be the same.
If compare_names_using_lowercase is set to True, we copy the data_tables and lower-case their names.
This is useful for Snowflake query output comparisons.
"""
check_data_tables_are_equal(
expected_table=expected,
actual_table=actual,
ignore_order=sort_columns,
allow_empty=allow_empty,
compare_column_names_using_lowercase=compare_names_using_lowercase,
)
2 changes: 1 addition & 1 deletion tests_metricflow/sql_clients/test_sql_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
from metricflow.data_table.mf_table import MetricFlowDataTable
from metricflow.protocols.sql_client import SqlClient, SqlEngine
from metricflow.sql.sql_table import SqlTable
from tests_metricflow.compare_df import assert_data_tables_equal
from tests_metricflow.fixtures.sql_clients.ddl_sql_client import SqlClientWithDDLMethods
from tests_metricflow.sql.compare_data_table import assert_data_tables_equal

logger = logging.getLogger(__name__)

Expand Down
2 changes: 1 addition & 1 deletion tests_metricflow/table_snapshot/test_source_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@

from metricflow.protocols.sql_client import SqlClient, SqlEngine
from metricflow.sql.sql_table import SqlTable
from tests_metricflow.compare_df import assert_data_tables_equal
from tests_metricflow.fixtures.table_fixtures import CONFIGURED_SOURCE_TABLE_SNAPSHOT_REPOSITORY
from tests_metricflow.source_schema_tools import get_populate_source_schema_shell_command
from tests_metricflow.sql.compare_data_table import assert_data_tables_equal
from tests_metricflow.table_snapshot.table_snapshots import (
SqlTableSnapshotRepository,
TableSnapshotException,
Expand Down
2 changes: 1 addition & 1 deletion tests_metricflow/table_snapshot/test_table_snapshots.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@

from metricflow.data_table.mf_table import MetricFlowDataTable
from metricflow.protocols.sql_client import SqlEngine
from tests_metricflow.compare_df import assert_data_tables_equal
from tests_metricflow.fixtures.sql_clients.ddl_sql_client import SqlClientWithDDLMethods
from tests_metricflow.sql.compare_data_table import assert_data_tables_equal
from tests_metricflow.table_snapshot.table_snapshots import (
SqlTableColumnDefinition,
SqlTableColumnType,
Expand Down

0 comments on commit fdcd0bf

Please sign in to comment.