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 BOOLEAN not found in snowdialect #551

Merged
merged 4 commits into from
Nov 25, 2024
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
1 change: 1 addition & 0 deletions DESCRIPTION.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Source code is also available at:

- (Unreleased)
- Add support for partition by to copy into <location>
- Fix BOOLEAN type not found in snowdialect

- v1.7.0(November 22, 2024)

Expand Down
2 changes: 2 additions & 0 deletions src/snowflake/sqlalchemy/snowdialect.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
_CUSTOM_Float,
_CUSTOM_Time,
)
from .parser.custom_type_parser import * # noqa
from .parser.custom_type_parser import _CUSTOM_DECIMAL # noqa
from .parser.custom_type_parser import ischema_names, parse_type
from .sql.custom_schema.custom_table_prefix import CustomTablePrefix
from .util import (
Expand Down
64 changes: 64 additions & 0 deletions tests/test_imports.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#
# Copyright (c) 2012-2023 Snowflake Computing Inc. All rights reserved.
#

import importlib
import inspect

import pytest


def get_classes_from_module(module_name):
"""Returns a set of class names from a given module."""
try:
module = importlib.import_module(module_name)
members = inspect.getmembers(module)
return {name for name, obj in members if inspect.isclass(obj)}

except ImportError:
print(f"Module '{module_name}' could not be imported.")
return set()


def test_types_in_snowdialect():
sfc-gh-jvasquezrojas marked this conversation as resolved.
Show resolved Hide resolved
classes_a = get_classes_from_module(
"snowflake.sqlalchemy.parser.custom_type_parser"
)
classes_b = get_classes_from_module("snowflake.sqlalchemy.snowdialect")
assert classes_a.issubset(classes_b), str(classes_a - classes_b)


@pytest.mark.parametrize(
"type_class_name",
[
"BIGINT",
"BINARY",
"BOOLEAN",
"CHAR",
"DATE",
"DATETIME",
"DECIMAL",
"FLOAT",
"INTEGER",
"REAL",
"SMALLINT",
"TIME",
"TIMESTAMP",
"VARCHAR",
"NullType",
"_CUSTOM_DECIMAL",
"ARRAY",
"DOUBLE",
"GEOGRAPHY",
"GEOMETRY",
"MAP",
"OBJECT",
"TIMESTAMP_LTZ",
"TIMESTAMP_NTZ",
"TIMESTAMP_TZ",
"VARIANT",
],
)
def test_snowflake_data_types_instance(type_class_name):
classes_b = get_classes_from_module("snowflake.sqlalchemy.snowdialect")
assert type_class_name in classes_b, type_class_name
Loading