-
Notifications
You must be signed in to change notification settings - Fork 152
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into update_readme_custom_tables
- Loading branch information
Showing
3 changed files
with
67 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |