Skip to content

Commit

Permalink
test: Test with singer-sdk @ main
Browse files Browse the repository at this point in the history
  • Loading branch information
edgarrmondragon committed Nov 26, 2024
1 parent 804d28e commit 4181685
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 24 deletions.
30 changes: 17 additions & 13 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ snowflake-connector-python = { version = "<4.0.0", extras = ["secure-local-stora
sqlalchemy = "~=2.0.31"

[tool.poetry.dependencies.singer-sdk]
version = "~=0.42.0b1"
git = "https://github.com/meltano/sdk.git"

[tool.poetry.group.dev.dependencies]
coverage = ">=7.2.7"
pytest = ">=7.4.3"
pytest-xdist = ">=3.3.1"

[tool.poetry.group.dev.dependencies.singer-sdk]
version="~=0.42.0b1"
git = "https://github.com/meltano/sdk.git"
extras = ["testing"]

[tool.ruff]
Expand Down
11 changes: 2 additions & 9 deletions target_snowflake/connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ class SnowflakeConnector(SQLConnector):
allow_merge_upsert: bool = False # Whether MERGE UPSERT is supported.
allow_temp_tables: bool = True # Whether temp tables are supported.

max_varchar_length = SNOWFLAKE_MAX_STRING_LENGTH

def __init__(self, *args: Any, **kwargs: Any) -> None:
self.table_cache: dict = {}
self.schema_cache: dict = {}
Expand Down Expand Up @@ -309,14 +311,6 @@ def get_column_alter_ddl(
},
)

@staticmethod
def _conform_max_length(jsonschema_type): # noqa: ANN205, ANN001
"""Alter jsonschema representations to limit max length to Snowflake's VARCHAR length."""
max_length = jsonschema_type.get("maxLength")
if max_length and max_length > SNOWFLAKE_MAX_STRING_LENGTH:
jsonschema_type["maxLength"] = SNOWFLAKE_MAX_STRING_LENGTH
return jsonschema_type

def to_sql_type(self, jsonschema_type: dict) -> sqlalchemy.types.TypeEngine:
"""Return a JSON Schema representation of the provided type.
Expand All @@ -329,7 +323,6 @@ def to_sql_type(self, jsonschema_type: dict) -> sqlalchemy.types.TypeEngine:
The SQLAlchemy type representation of the data type.
"""
# start with default implementation
jsonschema_type = SnowflakeConnector._conform_max_length(jsonschema_type)
target_type = super().to_sql_type(jsonschema_type)
# snowflake max and default varchar length
# https://docs.snowflake.com/en/sql-reference/intro-summary-data-types.html
Expand Down

0 comments on commit 4181685

Please sign in to comment.