From 2c087267473676ce393fd71da662a8c62f253c00 Mon Sep 17 00:00:00 2001 From: Lui Pillmann Date: Tue, 21 Apr 2026 15:50:24 +0200 Subject: [PATCH 1/2] fix: replace SyntaxWarning flood in snowflaky() with logger.debug MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Airbyte staging tables (e.g. AIRBYTE_SFTP_raw__stream_2025-03-23.csv) have periods in their names, causing warnings.warn to fire once per unique identifier. Switch to logger.debug so the messages are only visible at DEBUG log level. Behaviour is unchanged — the function still returns a value for these identifiers. --- src/permifrost/snowflake_connector.py | 6 +++--- tests/permifrost/test_snowflake_connector.py | 5 ++++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/permifrost/snowflake_connector.py b/src/permifrost/snowflake_connector.py index 77d446b9..5e7a7a3c 100644 --- a/src/permifrost/snowflake_connector.py +++ b/src/permifrost/snowflake_connector.py @@ -380,9 +380,9 @@ def snowflaky(name: str) -> str: # We do not currently support identifiers that include periods (i.e. db_1.schema_1."table.with.period") if len(name_parts) > 3: - warnings.warn( - f"Unsupported object identifier: {name} contains additional periods within identifier.", - SyntaxWarning, + logger.debug( + "Unsupported object identifier: %s contains additional periods within identifier.", + name, ) if len(name_parts) == 0: diff --git a/tests/permifrost/test_snowflake_connector.py b/tests/permifrost/test_snowflake_connector.py index 3c5a95af..63e843bc 100644 --- a/tests/permifrost/test_snowflake_connector.py +++ b/tests/permifrost/test_snowflake_connector.py @@ -1,4 +1,5 @@ import os +import warnings import pytest import sqlalchemy @@ -91,7 +92,9 @@ def test_snowflaky(self): == 'database_1."1_LEADING_DIGIT".' ) - with pytest.warns(SyntaxWarning): + with warnings.catch_warnings(): + warnings.simplefilter("error") + # These identifiers have periods in them but should not raise SyntaxWarning anymore SnowflakeConnector.snowflaky(db16) SnowflakeConnector.snowflaky(db17) From 0cb6881303f9513d4fcce7f055249b3a50777a0e Mon Sep 17 00:00:00 2001 From: Lui Pillmann Date: Tue, 21 Apr 2026 16:05:33 +0200 Subject: [PATCH 2/2] test: assert debug log fires for period-containing identifiers in snowflaky() Regression guard: verifies the logger.debug branch is actually reached when an identifier has >3 dot-separated parts (e.g. Airbyte staging tables). Without this, a future change back to warnings.warn would go undetected. Co-Authored-By: Claude Sonnet 4.6 (1M context) --- tests/permifrost/test_snowflake_connector.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tests/permifrost/test_snowflake_connector.py b/tests/permifrost/test_snowflake_connector.py index 63e843bc..a83db692 100644 --- a/tests/permifrost/test_snowflake_connector.py +++ b/tests/permifrost/test_snowflake_connector.py @@ -1,3 +1,4 @@ +import logging import os import warnings @@ -104,6 +105,17 @@ def test_snowflaky(self): assert SnowflakeConnector.snowflaky(db19) == "" + def test_snowflaky_logs_debug_for_period_in_identifier(self, caplog): + with caplog.at_level(logging.DEBUG, logger="permifrost.logger"): + SnowflakeConnector.snowflaky( + 'RAW_RESTRICTED.airbyte_internal."AIRBYTE_SFTP_raw__stream_2025-03-23.csv"' + ) + assert any( + "contains additional periods" in r.message + for r in caplog.records + if r.levelno == logging.DEBUG + ) + def test_uses_oauth_if_available(self, mocker, snowflake_connector_env): mocker.patch("sqlalchemy.create_engine") os.environ["PERMISSION_BOT_OAUTH_TOKEN"] = "TEST"