Skip to content
This repository was archived by the owner on May 22, 2025. It is now read-only.

Commit 279c7d1

Browse files
authored
Improve logging for load_file (#1312)
# Description ## What is the current behavior? Currently, we don't have any logging for native nor pandas _load_file_. This makes it harder for users to follow the operations. related: #1263 ## What is the new behavior? We now have log statements for native, pandas as well as fallback indication. ## Does this introduce a breaking change? No. ### Checklist - [ ] Created tests which fail without the change (if possible) - [ ] Extended the README / documentation, if necessary
1 parent 8f5d54f commit 279c7d1

File tree

1 file changed

+6
-5
lines changed
  • python-sdk/src/astro/databases

1 file changed

+6
-5
lines changed

python-sdk/src/astro/databases/base.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ class BaseDatabase(ABC):
5959
illegal_column_name_chars: list[str] = []
6060
illegal_column_name_chars_replacement: list[str] = []
6161
NATIVE_PATHS: dict[Any, Any] = {}
62-
NATIVE_LOAD_EXCEPTIONS: Any = DatabaseCustomError
6362
DEFAULT_SCHEMA = SCHEMA
6463
NATIVE_AUTODETECT_SCHEMA_CONFIG: Mapping[FileLocation, Mapping[str, list[FileType] | Callable]] = {}
6564
FILE_PATTERN_BASED_AUTODETECT_SCHEMA_SUPPORTED: set[FileLocation] = set()
@@ -475,6 +474,7 @@ def load_file_to_table_using_pandas(
475474
if_exists: LoadExistStrategy = "replace",
476475
chunk_size: int = DEFAULT_CHUNK_SIZE,
477476
):
477+
logging.info("Loading file(s) with Pandas...")
478478
input_files = resolve_file_path_pattern(
479479
input_file.path,
480480
input_file.conn_id,
@@ -514,20 +514,21 @@ def load_file_to_table_natively_with_fallback(
514514
"""
515515

516516
try:
517+
logging.info("Loading file(s) with Native Support...")
517518
self.load_file_to_table_natively(
518519
source_file=source_file,
519520
target_table=target_table,
520521
if_exists=if_exists,
521522
native_support_kwargs=native_support_kwargs,
522523
**kwargs,
523524
)
524-
# Catching NATIVE_LOAD_EXCEPTIONS for fallback
525-
except self.NATIVE_LOAD_EXCEPTIONS as load_exception: # skipcq: PYL-W0703
525+
except DatabaseCustomError:
526526
logging.warning(
527-
"Loading files failed with Native Support. Falling back to Pandas-based load",
527+
"Loading file(s) failed with Native Support.",
528528
exc_info=True,
529529
)
530530
if enable_native_fallback:
531+
logging.warning("Falling back to Pandas-based load...")
531532
self.load_file_to_table_using_pandas(
532533
input_file=source_file,
533534
output_table=target_table,
@@ -536,7 +537,7 @@ def load_file_to_table_natively_with_fallback(
536537
chunk_size=chunk_size,
537538
)
538539
else:
539-
raise load_exception
540+
raise
540541

541542
def load_pandas_dataframe_to_table(
542543
self,

0 commit comments

Comments
 (0)