jedcunningham commented on code in PR #29058:
URL: https://github.com/apache/airflow/pull/29058#discussion_r1084418134


##########
airflow/utils/db_cleanup.py:
##########
@@ -159,6 +170,14 @@ def _do_delete(*, query, orm_model, skip_archive, session):
     logger.debug("delete statement:\n%s", delete.compile())
     session.execute(delete)
     session.commit()
+    if export_to_csv:
+        if not output_path.startswith(AIRFLOW_HOME):
+            output_path = os.path.join(AIRFLOW_HOME, output_path)

Review Comment:
   We shouldn't restrict this to AIRFLOW_HOME.



##########
airflow/utils/db_cleanup.py:
##########
@@ -333,6 +362,8 @@ def run_cleanup(
     :param verbose: If true, may provide more detailed output.
     :param confirm: Require user input to confirm before processing deletions.
     :param skip_archive: Set to True if you don't want the purged rows 
preservied in an archive table.
+    :param export_to_csv: Set to True if you want the purged rows exported to 
a CSV file.
+    :param output_path: Path to the directory where the CSV file will be 
written.

Review Comment:
   ```suggestion
       :param output_path: Path to the directory where the CSV files will be 
written.
   ```



##########
airflow/cli/cli_parser.py:
##########
@@ -468,7 +468,18 @@ def string_lower_type(val):
     help="Don't preserve purged records in an archive table.",
     action="store_true",
 )
-
+ARG_DB_EXPORT_TO_CSV = Arg(

Review Comment:
   I feel like we should merge this with `output-path`, which should be 
required.



##########
airflow/utils/db_cleanup.py:
##########
@@ -123,7 +126,15 @@ def _check_for_rows(*, query: Query, print_rows=False):
     return num_entities
 
 
-def _do_delete(*, query, orm_model, skip_archive, session):
+def _to_csv(*, target_table, file_path, session):
+    with open(file_path, "w") as f:

Review Comment:
   This will silently overwrite any existing file, probably should skip/fail 
instead?



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