Skip to content

Commit

Permalink
Merge branch 'main' into update_readme_custom_tables
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-jvasquezrojas authored Nov 25, 2024
2 parents 684ede3 + 140fec8 commit 47be1c8
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 0 deletions.
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():
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

0 comments on commit 47be1c8

Please sign in to comment.