Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pyathena/arrow/result_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ def _read_csv(self) -> Table:
),
)
except Exception as e:
_logger.exception("Failed to read %s/%s.", bucket, key)
_logger.exception(f"Failed to read {bucket}/{key}.")
raise OperationalError(*e.args) from e

def _read_parquet(self) -> Table:
Expand All @@ -333,7 +333,7 @@ def _read_parquet(self) -> Table:
dataset = parquet.ParquetDataset(f"{bucket}/{key}", filesystem=self._fs)
return dataset.read(use_threads=True)
except Exception as e:
_logger.exception("Failed to read %s/%s.", bucket, key)
_logger.exception(f"Failed to read {bucket}/{key}.")
raise OperationalError(*e.args) from e

def _as_arrow(self) -> Table:
Expand Down
22 changes: 10 additions & 12 deletions pyathena/pandas/result_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -524,9 +524,8 @@ def _read_csv(self) -> TextFileReader | DataFrame:
effective_chunksize = self._auto_determine_chunksize(length)
if effective_chunksize:
_logger.debug(
"Auto-determined chunksize: %s for file size: %s bytes",
effective_chunksize,
length,
f"Auto-determined chunksize: {effective_chunksize} "
f"for file size: {length} bytes"
)

csv_engine = self._get_csv_engine(length, effective_chunksize)
Expand Down Expand Up @@ -565,17 +564,16 @@ def _read_csv(self) -> TextFileReader | DataFrame:
# Log performance information for large files
if length > self.LARGE_FILE_THRESHOLD_BYTES:
mode = "chunked" if effective_chunksize else "full"
msg = "Reading %s bytes from S3 in %s mode using %s engine"
args: tuple[object, ...] = (length, mode, csv_engine)
if effective_chunksize:
msg += " with chunksize=%s"
args = (*args, effective_chunksize)
_logger.info(msg, *args)
chunksize = f" with chunksize={effective_chunksize}" if effective_chunksize else ""
_logger.info(
f"Reading {length} bytes from S3 in {mode} mode "
f"using {csv_engine} engine{chunksize}"
)

return result

except Exception as e:
_logger.exception("Failed to read %s.", self.output_location)
_logger.exception(f"Failed to read {self.output_location}.")
raise OperationalError(*e.args) from e

def _read_parquet(self, engine) -> DataFrame:
Expand Down Expand Up @@ -609,7 +607,7 @@ def _read_parquet(self, engine) -> DataFrame:
**kwargs,
)
except Exception as e:
_logger.exception("Failed to read %s.", self.output_location)
_logger.exception(f"Failed to read {self.output_location}.")
raise OperationalError(*e.args) from e

def _read_parquet_schema(self, engine) -> tuple[dict[str, Any], ...]:
Expand All @@ -625,7 +623,7 @@ def _read_parquet_schema(self, engine) -> tuple[dict[str, Any], ...]:
dataset = parquet.ParquetDataset(f"{bucket}/{key}", filesystem=self._fs)
return to_column_info(dataset.schema)
except Exception as e:
_logger.exception("Failed to read schema %s/%s.", bucket, key)
_logger.exception(f"Failed to read schema {bucket}/{key}.")
raise OperationalError(*e.args) from e
else:
raise ProgrammingError("Engine must be `pyarrow`.")
Expand Down
2 changes: 1 addition & 1 deletion pyathena/pandas/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ def to_sql(
)
for future in concurrent.futures.as_completed(futures):
result = future.result()
_logger.info("to_parquet: %s", result)
_logger.info(f"to_parquet: {result}")

ddl = generate_ddl(
df=df,
Expand Down
10 changes: 5 additions & 5 deletions pyathena/polars/result_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ def _read_csv(self) -> pl.DataFrame:
df.columns = new_columns
return df
except Exception as e:
_logger.exception("Failed to read %s.", self.output_location)
_logger.exception(f"Failed to read {self.output_location}.")
raise OperationalError(*e.args) from e

def _read_parquet(self) -> pl.DataFrame:
Expand All @@ -499,7 +499,7 @@ def _read_parquet(self) -> pl.DataFrame:
**self._kwargs,
)
except Exception as e:
_logger.exception("Failed to read %s.", self._unload_location)
_logger.exception(f"Failed to read {self._unload_location}.")
raise OperationalError(*e.args) from e

def _read_parquet_schema(self) -> tuple[dict[str, Any], ...]:
Expand All @@ -518,7 +518,7 @@ def _read_parquet_schema(self) -> tuple[dict[str, Any], ...]:
schema = lazy_df.collect_schema()
return to_column_info(schema)
except Exception as e:
_logger.exception("Failed to read schema from %s.", self._unload_location)
_logger.exception(f"Failed to read schema from {self._unload_location}.")
raise OperationalError(*e.args) from e

def _as_polars(self) -> pl.DataFrame:
Expand Down Expand Up @@ -658,7 +658,7 @@ def _iter_csv_chunks(self) -> Iterator[pl.DataFrame]:
batch.columns = new_columns
yield batch
except Exception as e:
_logger.exception("Failed to read %s.", self.output_location)
_logger.exception(f"Failed to read {self.output_location}.")
raise OperationalError(*e.args) from e

def _iter_parquet_chunks(self) -> Iterator[pl.DataFrame]:
Expand Down Expand Up @@ -686,7 +686,7 @@ def _iter_parquet_chunks(self) -> Iterator[pl.DataFrame]:
)
yield from lazy_df.collect_batches(chunk_size=self._chunksize)
except Exception as e:
_logger.exception("Failed to read %s.", self._unload_location)
_logger.exception(f"Failed to read {self._unload_location}.")
raise OperationalError(*e.args) from e

def iter_chunks(self) -> PolarsDataFrameIterator:
Expand Down
2 changes: 1 addition & 1 deletion pyathena/result_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -663,7 +663,7 @@ def _read_data_manifest(self) -> list[str]:
Key=key,
)
except Exception as e:
_logger.exception("Failed to read %s/%s.", bucket, key)
_logger.exception(f"Failed to read {bucket}/{key}.")
raise OperationalError(*e.args) from e
else:
manifest: str = response["Body"].read().decode("utf-8").strip()
Expand Down
2 changes: 1 addition & 1 deletion pyathena/s3fs/result_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ def _init_csv_reader(self) -> None:
next(self._csv_reader)

except Exception as e:
_logger.exception("Failed to open %s.", path)
_logger.exception(f"Failed to open {path}.")
raise OperationalError(*e.args) from e

def _fetch(self) -> None:
Expand Down
2 changes: 1 addition & 1 deletion pyathena/spark/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ def _exists_session(self, session_id: str) -> bool:
isinstance(e, botocore.exceptions.ClientError)
and e.response["Error"]["Code"] == "InvalidRequestException"
):
_logger.exception("Session: %s not found.", session_id)
_logger.exception(f"Session: {session_id} not found.")
return False
raise OperationalError(*e.args) from e
else:
Expand Down