Skip to content

Commit 666843d

Browse files
Release 1.2.4 (#195)
Co-authored-by: ankit-bhatnagar167 <[email protected]>
1 parent 7c7444a commit 666843d

File tree

8 files changed

+45
-16
lines changed

8 files changed

+45
-16
lines changed

DESCRIPTION.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ https://github.com/snowflakedb/snowflake-sqlalchemy
1010
Release Notes
1111
-------------------------------------------------------------------------------
1212

13+
- v1.2.4 (October 05,2020)
14+
15+
- Fixed an issue where inspector would not properly switch to table wide column retrieving when schema wide column retrieving was taking too long to respond.
16+
1317
- v1.2.3 (March 30, 2020)
1418

1519
- Update tox.ini

__init__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
)
1919
from .util import _url as URL
2020
from .version import VERSION
21-
from snowflake.connector.compat import TO_UNICODE
2221
from sqlalchemy.types import (
2322
BIGINT,
2423
BINARY,
@@ -55,7 +54,7 @@
5554
VARIANT,
5655
)
5756

58-
SNOWFLAKE_CONNECTOR_VERSION = '.'.join(TO_UNICODE(v) for v in VERSION[0:3])
57+
SNOWFLAKE_CONNECTOR_VERSION = '.'.join(str(v) for v in VERSION[0:3])
5958

6059
base.dialect = dialect = snowdialect.dialect
6160

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@
8383
],
8484
extras_require={
8585
'development': [
86-
'pytest',
86+
'pytest<6.1.0',
8787
'pytest-cov',
8888
'pytest-rerunfailures',
8989
'pytest-timeout',

snowdialect.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -324,8 +324,8 @@ def _get_schema_columns(self, connection, schema, **kw):
324324
ans = {}
325325
current_database, _ = self._current_database_schema(connection, **kw)
326326
full_schema_name = self._denormalize_quote_join(current_database, schema)
327-
schema_primary_keys = self._get_schema_primary_keys(connection, full_schema_name, **kw)
328327
try:
328+
schema_primary_keys = self._get_schema_primary_keys(connection, full_schema_name, **kw)
329329
result = connection.execute("""
330330
SELECT /* sqlalchemy:_get_schema_columns */
331331
ic.table_name,
@@ -341,8 +341,8 @@ def _get_schema_columns(self, connection, schema, **kw):
341341
FROM information_schema.columns ic
342342
WHERE ic.table_schema=%(table_schema)s
343343
ORDER BY ic.ordinal_position""", {"table_schema": self.denormalize_name(schema)})
344-
except ProgrammingError as pe:
345-
if pe.errno == 90030:
344+
except sa_exc.ProgrammingError as pe:
345+
if pe.orig.errno == 90030:
346346
# This means that there are too many tables in the schema, we need to go more granular
347347
return None # None triggers _get_table_columns while staying cacheable
348348
raise

test/conftest.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@
1313
import pytest
1414
import snowflake.connector
1515
from parameters import CONNECTION_PARAMETERS
16-
from snowflake.connector.compat import IS_WINDOWS, TO_UNICODE
16+
from snowflake.connector.compat import IS_WINDOWS
1717
from snowflake.sqlalchemy import URL, dialect
1818
from sqlalchemy import create_engine
1919

2020
if os.getenv('TRAVIS') == 'true':
2121
TEST_SCHEMA = 'TRAVIS_JOB_{0}'.format(os.getenv('TRAVIS_JOB_ID'))
2222
else:
2323
TEST_SCHEMA = (
24-
'sqlalchemy_tests_' + TO_UNICODE(uuid.uuid4()).replace('-', '_'))
24+
'sqlalchemy_tests_' + str(uuid.uuid4()).replace('-', '_'))
2525

2626

2727
@pytest.fixture(scope='session')
@@ -95,7 +95,7 @@ def get_db_parameters():
9595
# a unique table name
9696
ret['name'] = (
9797
'sqlalchemy_tests_' +
98-
TO_UNICODE(uuid.uuid4())).replace('-', '_')
98+
str(uuid.uuid4())).replace('-', '_')
9999
ret['schema'] = TEST_SCHEMA
100100

101101
# This reduces a chance to exposing password in test output.

test/test_core.py

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,10 @@
1212
import pytest
1313
from conftest import get_engine
1414
from mock import patch
15+
from sqlalchemy.exc import DBAPIError
16+
1517
from parameters import CONNECTION_PARAMETERS
16-
from snowflake.connector import ProgrammingError, connect
18+
from snowflake.connector import ProgrammingError, connect, Error
1719
from snowflake.sqlalchemy import URL, MergeInto, dialect
1820
from sqlalchemy import (
1921
REAL,
@@ -35,6 +37,8 @@
3537
)
3638
from sqlalchemy.sql import and_, not_, or_, select
3739

40+
from snowflake.sqlalchemy.snowdialect import SnowflakeDialect
41+
3842
try:
3943
from parameters import (CONNECTION_PARAMETERS2)
4044
except ImportError:
@@ -1233,8 +1237,32 @@ def test_too_many_columns_detection(engine_testaccount, db_parameters):
12331237

12341238
def mock_helper(command, *args, **kwargs):
12351239
if '_get_schema_columns' in command:
1236-
raise ProgrammingError("Information schema query returned too much data. Please repeat query with more "
1237-
"selective predicates.", 90030)
1240+
# Creating exception exactly how SQLAlchemy does
1241+
raise DBAPIError.instance(
1242+
'''
1243+
SELECT /* sqlalchemy:_get_schema_columns */
1244+
ic.table_name,
1245+
ic.column_name,
1246+
ic.data_type,
1247+
ic.character_maximum_length,
1248+
ic.numeric_precision,
1249+
ic.numeric_scale,
1250+
ic.is_nullable,
1251+
ic.column_default,
1252+
ic.is_identity,
1253+
ic.comment
1254+
FROM information_schema.columns ic
1255+
WHERE ic.table_schema='schema_name'
1256+
ORDER BY ic.ordinal_position''',
1257+
{'table_schema': 'TESTSCHEMA'},
1258+
ProgrammingError("Information schema query returned too much data. Please repeat query with more "
1259+
"selective predicates.", 90030),
1260+
Error,
1261+
hide_parameters=False,
1262+
connection_invalidated=False,
1263+
dialect=SnowflakeDialect(),
1264+
ismulti=None
1265+
)
12381266
else:
12391267
return original_execute(command, *args, **kwargs)
12401268

test/test_unit_cte.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
# Copyright (c) 2012-2019 Snowflake Computing Inc. All right reserved.
55
#
66

7-
from snowflake.connector.compat import TO_UNICODE
8-
97

108
def test_cte():
119
from snowflake.sqlalchemy import snowdialect
@@ -21,7 +19,7 @@ def test_cte():
2119
with_bar = select([literal(product_id), literal(day), literal(count)]).cte('bar')
2220
sel = select([with_bar])
2321
ins = visitors.insert().from_select([visitors.c.product_id, visitors.c.date1, visitors.c.count], sel)
24-
assert TO_UNICODE(ins.compile(dialect=snowdialect.dialect())) == (
22+
assert str(ins.compile(dialect=snowdialect.dialect())) == (
2523
"INSERT INTO visitors (product_id, date1, count) WITH bar AS \n"
2624
"(SELECT %(param_1)s AS anon_1, %(param_2)s AS anon_2, %(param_3)s AS anon_3)\n"
2725
" SELECT bar.anon_1, bar.anon_2, bar.anon_3 \n"

version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# Update this for the versions
22
# Don't change the forth version number from None
3-
VERSION = (1, 2, 3, None)
3+
VERSION = (1, 2, 4, None)

0 commit comments

Comments
 (0)