uranusjr commented on code in PR #28246:
URL: https://github.com/apache/airflow/pull/28246#discussion_r1047949602
##########
airflow/utils/db_cleanup.py:
##########
@@ -337,8 +337,14 @@ def run_cleanup(
:param session: Session representing connection to the metadata database.
"""
clean_before_timestamp = timezone.coerce_datetime(clean_before_timestamp)
- effective_table_names = table_names if table_names else
list(config_dict.keys())
- effective_config_dict = {k: v for k, v in config_dict.items() if k in
effective_table_names}
+ desired_table_names = set(table_names if table_names else
config_dict.keys())
+ effective_config_dict = {k: v for k, v in config_dict.items() if k in
desired_table_names}
+ effective_table_names = set(effective_config_dict.keys())
+ if desired_table_names != effective_table_names:
+ outliers = desired_table_names - effective_table_names
+ logger.warning("The following table(s) are not valid choices and will
be skipped: %s", outliers)
Review Comment:
```suggestion
logger.warning("The following table(s) are not valid choices and
will be skipped: %s", sorted(outliers))
```
##########
airflow/utils/db_cleanup.py:
##########
@@ -347,7 +353,7 @@ def run_cleanup(
)
_print_config(configs=effective_config_dict)
if not dry_run and confirm:
- _confirm_delete(date=clean_before_timestamp,
tables=list(effective_config_dict.keys()))
+ _confirm_delete(date=clean_before_timestamp,
tables=effective_table_names)
Review Comment:
```suggestion
_confirm_delete(date=clean_before_timestamp,
tables=sorted(effective_table_names))
```
##########
airflow/utils/db_cleanup.py:
##########
@@ -337,8 +337,14 @@ def run_cleanup(
:param session: Session representing connection to the metadata database.
"""
clean_before_timestamp = timezone.coerce_datetime(clean_before_timestamp)
- effective_table_names = table_names if table_names else
list(config_dict.keys())
- effective_config_dict = {k: v for k, v in config_dict.items() if k in
effective_table_names}
+ desired_table_names = set(table_names if table_names else
config_dict.keys())
+ effective_config_dict = {k: v for k, v in config_dict.items() if k in
desired_table_names}
+ effective_table_names = set(effective_config_dict.keys())
Review Comment:
```suggestion
effective_table_names = set(effective_config_dict)
```
##########
airflow/utils/db_cleanup.py:
##########
@@ -337,8 +337,14 @@ def run_cleanup(
:param session: Session representing connection to the metadata database.
"""
clean_before_timestamp = timezone.coerce_datetime(clean_before_timestamp)
- effective_table_names = table_names if table_names else
list(config_dict.keys())
- effective_config_dict = {k: v for k, v in config_dict.items() if k in
effective_table_names}
+ desired_table_names = set(table_names if table_names else
config_dict.keys())
Review Comment:
```suggestion
desired_table_names = set(table_names or config_dict)
```
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]