Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Add missing SnowflakeDialect mapping for BINARY data type #959

Merged
merged 2 commits into from
Aug 29, 2023
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
2 changes: 1 addition & 1 deletion noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ def integration_hive(session):
@nox.session(python=PYTHON_VERSIONS, venv_backend="venv")
def integration_snowflake(session):
"""Run Snowflake integration tests.
Ensure Hive validation is running as expected.
Ensure Snowflake validation is running as expected.
"""
_setup_session_requirements(
session, extra_packages=["snowflake-sqlalchemy", "snowflake-connector-python"]
Expand Down
26 changes: 26 additions & 0 deletions tests/system/data_sources/test_snowflake.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,32 @@ def test_schema_validation_core_types():
assert len(df) == 0


@mock.patch(
"data_validation.state_manager.StateManager.get_connection_config",
new=mock_get_connection_config,
)
def test_schema_validation_specific_types():
"""Snowflake to Snowflake test_specific_data_types schema validation"""
parser = cli_tools.configure_arg_parser()
args = parser.parse_args(
[
"validate",
"schema",
"-sc=mock-conn",
"-tc=mock-conn",
"-tbls=PSO_DATA_VALIDATOR.PUBLIC.TEST_SPECIFIC_DATA_TYPES",
"--filter-status=fail",
]
)
config_managers = main.build_config_managers_from_args(args)
assert len(config_managers) == 1
config_manager = config_managers[0]
validator = data_validation.DataValidation(config_manager.config, verbose=False)
df = validator.execute()
# With filter on failures the data frame should be empty
assert len(df) == 0


@mock.patch(
"data_validation.state_manager.StateManager.get_connection_config",
new=mock_get_connection_config,
Expand Down
6 changes: 5 additions & 1 deletion third_party/ibis/ibis_snowflake/datatypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from ibis.backends.snowflake import Backend as SnowflakeBackend
from ibis.backends.snowflake.datatypes import parse
from snowflake.connector.constants import FIELD_ID_TO_NAME
from snowflake.sqlalchemy import NUMBER
from snowflake.sqlalchemy import NUMBER, BINARY
from snowflake.sqlalchemy.snowdialect import SnowflakeDialect


Expand All @@ -30,6 +30,10 @@ def sa_sf_numeric(_, satype, nullable=True):
nullable=nullable,
)

@dt.dtype.register(SnowflakeDialect, BINARY)
helensilva14 marked this conversation as resolved.
Show resolved Hide resolved
def sa_sf_binary(_, satype, nullable=True):
return dt.Binary(nullable=nullable)


def _metadata(self, query: str) -> Iterable[Tuple[str, dt.DataType]]:
with self.begin() as con, con.connection.cursor() as cur:
Expand Down