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


##########
airflow/cli/commands/dag_command.py:
##########
@@ -351,8 +351,20 @@ 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()]

Review Comment:
   ```suggestion
       invalid_cols = [c for c in cols if c not in dag_schema.fields]
   ```



##########
airflow/cli/commands/dag_command.py:
##########
@@ -351,8 +351,20 @@ 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()]
+    valid_cols = [c for c in cols if c in dag_schema.fields.keys()]

Review Comment:
   ```suggestion
       valid_cols = [c for c in cols if c in dag_schema.fields]
   ```
   
   I think we might not need to call `keys()`, it seems to be the default 
behavior of a `dict`



##########
airflow/cli/commands/dag_command.py:
##########
@@ -351,8 +351,20 @@ 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()]
+    valid_cols = [c for c in cols if c in dag_schema.fields.keys()]
+    if not_valid_cols:
+        from rich import print as rich_print
+
+        rich_print(
+            f"[red][bold]Error:[/bold] Ignoring the following invalid columns: 
{not_valid_cols}.  "

Review Comment:
   ```suggestion
               f"[red][bold]Error:[/bold] Ignoring the following invalid 
columns: {invalid_cols}.  "
   ```



##########
airflow/cli/commands/dag_command.py:
##########
@@ -351,8 +351,20 @@ 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()]
+    valid_cols = [c for c in cols if c in dag_schema.fields.keys()]
+    if not_valid_cols:

Review Comment:
   ```suggestion
       if invalid_cols:
   ```



-- 
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