diff --git a/duckdb/query_graph/__main__.py b/duckdb/query_graph/__main__.py index dd4ff9591..19601b750 100644 --- a/duckdb/query_graph/__main__.py +++ b/duckdb/query_graph/__main__.py @@ -640,7 +640,7 @@ def main() -> None: # noqa: D103 description="""Given a json profile output, generate a html file showing the query graph and timings of operators""", ) - parser.add_argument("--profile_input", help="profile input in json") + parser.add_argument("--profile_input", required=True, help="profile input in json") parser.add_argument("--out", required=False, default=False) parser.add_argument("--open", required=False, action="store_true", default=True) args = parser.parse_args() diff --git a/tests/fast/test_query_graph_cli_arguments.py b/tests/fast/test_query_graph_cli_arguments.py new file mode 100644 index 000000000..3fbfc5b32 --- /dev/null +++ b/tests/fast/test_query_graph_cli_arguments.py @@ -0,0 +1,16 @@ +import sys + +import pytest + +from duckdb.query_graph import __main__ as query_graph + + +@pytest.mark.parametrize("options", [[], ["--out", "report.html"]]) +def test_query_graph_requires_profile_input(monkeypatch, capsys, options): + monkeypatch.setattr(sys, "argv", ["query_graph", *options]) + + with pytest.raises(SystemExit) as error: + query_graph.main() + + assert error.value.code == 2 + assert "the following arguments are required: --profile_input" in capsys.readouterr().err