Skip to content

Commit 220015a

Browse files
committed
Cleaning temp S3 files for Pandas.read_sql_athena(ctas_approach=True)
1 parent 55b1226 commit 220015a

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

awswrangler/pandas.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -582,13 +582,16 @@ def _read_sql_athena_ctas(self,
582582
self._session.glue.delete_table_if_exists(database=database, table=name)
583583
manifest_path: str = f"{s3_output}/tables/{query_id}-manifest.csv"
584584
paths: List[str] = self._session.athena.extract_manifest_paths(path=manifest_path)
585-
if not paths:
586-
return pd.DataFrame()
587585
logger.debug(f"paths: {paths}")
588-
return self.read_parquet(path=paths,
589-
procs_cpu_bound=procs_cpu_bound,
590-
wait_objects=True,
591-
wait_objects_timeout=15.0)
586+
if not paths:
587+
df: pd.DataFrame = pd.DataFrame()
588+
else:
589+
df = self.read_parquet(path=paths,
590+
procs_cpu_bound=procs_cpu_bound,
591+
wait_objects=True,
592+
wait_objects_timeout=15.0)
593+
self._session.s3.delete_listed_objects(objects_paths=[manifest_path] + paths)
594+
return df
592595

593596
def _read_sql_athena_regular(self,
594597
sql: str,

0 commit comments

Comments
 (0)