Skip to content
Draft
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
1 change: 1 addition & 0 deletions DESCRIPTION.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Source code is also available at: https://github.com/snowflakedb/snowflake-conne
# Release Notes
- v3.18.0(TBD)
- Added the `workload_identity_impersonation_path` parameter to support service account impersonation for Workload Identity Federation on GCP workloads only
- Print user related pandas warnings only once

- v3.17.3(September 02,2025)
- Enhanced configuration file permission warning messages.
Expand Down
19 changes: 17 additions & 2 deletions src/snowflake/connector/pandas_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,21 @@
logger = getLogger(__name__)


class PandasUserOnceWarnings(UserWarning):
"""
User warnings related to pandas operations
that only the user has control over. These
are configured to be printed once and only
once using a warning filter.
"""

pass


# Configure user-pandas warnings to print only once
warnings.simplefilter("once", PandasUserOnceWarnings)


def chunk_helper(
lst: pandas.DataFrame, n: int
) -> Iterator[tuple[int, pandas.DataFrame]]:
Expand Down Expand Up @@ -397,7 +412,7 @@ def write_pandas(
f"Pandas Dataframe has non-standard index of type {str(type(df.index))} which will not be written."
f" Consider changing the index to pd.RangeIndex(start=0,...,step=1) or "
f"call reset_index() to keep index as column(s)",
UserWarning,
PandasUserOnceWarnings,
stacklevel=2,
)

Expand All @@ -411,7 +426,7 @@ def write_pandas(
f"'{use_logical_type=}'. This can result in dateimes "
"being incorrectly written to Snowflake. Consider setting "
"'use_logical_type = True'",
UserWarning,
PandasUserOnceWarnings,
stacklevel=2,
)

Expand Down