Lee-W commented on code in PR #35250:
URL: https://github.com/apache/airflow/pull/35250#discussion_r1376017092


##########
airflow/cli/commands/dag_command.py:
##########
@@ -351,8 +351,16 @@ def print_execution_interval(interval: DataInterval | 
None):
 @cli_utils.action_cli
 @suppress_logs_and_warning
 @providers_configuration_loaded
-def dag_list_dags(args) -> None:
+@provide_session
+def dag_list_dags(args, session=NEW_SESSION) -> None:
     """Display dags with or without stats at the command line."""
+    cols = args.columns if args.columns else []
+    not_valid_cols = [c for c in cols if c not in dag_schema.fields.keys()]
+    if not_valid_cols:

Review Comment:
   What about ignoring the invalid col but raise a warning to the users? I 
think it might be user-friendly



##########
tests/cli/commands/test_dag_command.py:
##########
@@ -520,15 +520,36 @@ def test_cli_get_dag_details(self):
 
     @conf_vars({("core", "load_examples"): "true"})
     def test_cli_list_dags(self):
-        args = self.parser.parse_args(["dags", "list", "--output", "yaml"])
+        args = self.parser.parse_args(["dags", "list", "--output", "json"])
         with contextlib.redirect_stdout(StringIO()) as temp_stdout:
             dag_command.dag_list_dags(args)
             out = temp_stdout.getvalue()
-        assert "owner" in out
-        assert "airflow" in out
-        assert "paused" in out
-        assert "airflow/example_dags/example_complex.py" in out
-        assert "- dag_id:" in out
+            dag_list = json.loads(out)
+        assert "dag_id" in dag_list[0]
+        assert "fileloc" in dag_list[0]
+        assert "owners" in dag_list[0]
+        assert "is_paused" in dag_list[0]

Review Comment:
   nitpick
   ```suggestion
           for key in ["dag_id", "fileloc", "owners", "is_paused"]:
               assert key in dag_list[0]
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@airflow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to