Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions diffly/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# SPDX-License-Identifier: BSD-3-Clause

import datetime as dt
import warnings
from pathlib import Path
from typing import Annotated

Expand Down Expand Up @@ -121,7 +122,7 @@ def main(
),
),
] = False,
hidden_columns: Annotated[
hidden_column: Annotated[
list[str],
typer.Option(
help=(
Expand All @@ -130,6 +131,10 @@ def main(
)
),
] = [],
hidden_columns: Annotated[
list[str],
typer.Option(hidden=True),
] = [],
metric: Annotated[
list[str],
typer.Option(
Expand All @@ -141,6 +146,13 @@ def main(
] = [],
) -> None:
"""Compare two `parquet` files and print the comparison result."""
if hidden_columns:
warnings.warn(
"`--hidden-columns` is deprecated, use `--hidden-column` instead.",
FutureWarning,
)
hidden_column = [*hidden_column, *hidden_columns]

for name in metric:
if name not in DEFAULT_METRICS:
raise typer.BadParameter(
Expand All @@ -164,7 +176,7 @@ def main(
left_name=left_name,
right_name=right_name,
slim=slim,
hidden_columns=hidden_columns,
hidden_columns=hidden_column,
metrics=metrics,
)
if output_json:
Expand Down
22 changes: 22 additions & 0 deletions tests/cli/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,28 @@ def test_cli_smoke(tmp_path: Path, output_json: bool) -> None:
assert result.output == comparison.summary().format(pretty=True) + "\n"


def test_cli_hidden_columns_alias_warns(tmp_path: Path) -> None:
df = pl.DataFrame({"id": [1, 2], "secret": ["a", "b"]})
df.write_parquet(tmp_path / "left.parquet")
df.write_parquet(tmp_path / "right.parquet")

with pytest.warns(FutureWarning, match="--hidden-columns.*deprecated"):
result = runner.invoke(
app,
[
str(tmp_path / "left.parquet"),
str(tmp_path / "right.parquet"),
"--primary-key",
"id",
"--hidden-columns",
"secret",
],
catch_exceptions=False,
)

assert result.exit_code == 0


def test_cli_unknown_metric(tmp_path: Path) -> None:
left = pl.DataFrame({"id": [1, 2], "x": [1.0, 2.0]})
right = pl.DataFrame({"id": [1, 2], "x": [1.0, 3.0]})
Expand Down
Loading