Skip to content

Commit

Permalink
Release 1.2.4 (#195)
Browse files Browse the repository at this point in the history
Co-authored-by: ankit-bhatnagar167 <[email protected]>
  • Loading branch information
sfc-gh-mkeller and sfc-gh-abhatnagar authored Oct 5, 2020
1 parent 7c7444a commit 666843d
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 16 deletions.
4 changes: 4 additions & 0 deletions DESCRIPTION.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ https://github.com/snowflakedb/snowflake-sqlalchemy
Release Notes
-------------------------------------------------------------------------------

- v1.2.4 (October 05,2020)

- 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.

- v1.2.3 (March 30, 2020)

- Update tox.ini
Expand Down
3 changes: 1 addition & 2 deletions __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
)
from .util import _url as URL
from .version import VERSION
from snowflake.connector.compat import TO_UNICODE
from sqlalchemy.types import (
BIGINT,
BINARY,
Expand Down Expand Up @@ -55,7 +54,7 @@
VARIANT,
)

SNOWFLAKE_CONNECTOR_VERSION = '.'.join(TO_UNICODE(v) for v in VERSION[0:3])
SNOWFLAKE_CONNECTOR_VERSION = '.'.join(str(v) for v in VERSION[0:3])

base.dialect = dialect = snowdialect.dialect

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
],
extras_require={
'development': [
'pytest',
'pytest<6.1.0',
'pytest-cov',
'pytest-rerunfailures',
'pytest-timeout',
Expand Down
6 changes: 3 additions & 3 deletions snowdialect.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,8 +324,8 @@ def _get_schema_columns(self, connection, schema, **kw):
ans = {}
current_database, _ = self._current_database_schema(connection, **kw)
full_schema_name = self._denormalize_quote_join(current_database, schema)
schema_primary_keys = self._get_schema_primary_keys(connection, full_schema_name, **kw)
try:
schema_primary_keys = self._get_schema_primary_keys(connection, full_schema_name, **kw)
result = connection.execute("""
SELECT /* sqlalchemy:_get_schema_columns */
ic.table_name,
Expand All @@ -341,8 +341,8 @@ def _get_schema_columns(self, connection, schema, **kw):
FROM information_schema.columns ic
WHERE ic.table_schema=%(table_schema)s
ORDER BY ic.ordinal_position""", {"table_schema": self.denormalize_name(schema)})
except ProgrammingError as pe:
if pe.errno == 90030:
except sa_exc.ProgrammingError as pe:
if pe.orig.errno == 90030:
# This means that there are too many tables in the schema, we need to go more granular
return None # None triggers _get_table_columns while staying cacheable
raise
Expand Down
6 changes: 3 additions & 3 deletions test/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@
import pytest
import snowflake.connector
from parameters import CONNECTION_PARAMETERS
from snowflake.connector.compat import IS_WINDOWS, TO_UNICODE
from snowflake.connector.compat import IS_WINDOWS
from snowflake.sqlalchemy import URL, dialect
from sqlalchemy import create_engine

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


@pytest.fixture(scope='session')
Expand Down Expand Up @@ -95,7 +95,7 @@ def get_db_parameters():
# a unique table name
ret['name'] = (
'sqlalchemy_tests_' +
TO_UNICODE(uuid.uuid4())).replace('-', '_')
str(uuid.uuid4())).replace('-', '_')
ret['schema'] = TEST_SCHEMA

# This reduces a chance to exposing password in test output.
Expand Down
34 changes: 31 additions & 3 deletions test/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@
import pytest
from conftest import get_engine
from mock import patch
from sqlalchemy.exc import DBAPIError

from parameters import CONNECTION_PARAMETERS
from snowflake.connector import ProgrammingError, connect
from snowflake.connector import ProgrammingError, connect, Error
from snowflake.sqlalchemy import URL, MergeInto, dialect
from sqlalchemy import (
REAL,
Expand All @@ -35,6 +37,8 @@
)
from sqlalchemy.sql import and_, not_, or_, select

from snowflake.sqlalchemy.snowdialect import SnowflakeDialect

try:
from parameters import (CONNECTION_PARAMETERS2)
except ImportError:
Expand Down Expand Up @@ -1233,8 +1237,32 @@ def test_too_many_columns_detection(engine_testaccount, db_parameters):

def mock_helper(command, *args, **kwargs):
if '_get_schema_columns' in command:
raise ProgrammingError("Information schema query returned too much data. Please repeat query with more "
"selective predicates.", 90030)
# Creating exception exactly how SQLAlchemy does
raise DBAPIError.instance(
'''
SELECT /* sqlalchemy:_get_schema_columns */
ic.table_name,
ic.column_name,
ic.data_type,
ic.character_maximum_length,
ic.numeric_precision,
ic.numeric_scale,
ic.is_nullable,
ic.column_default,
ic.is_identity,
ic.comment
FROM information_schema.columns ic
WHERE ic.table_schema='schema_name'
ORDER BY ic.ordinal_position''',
{'table_schema': 'TESTSCHEMA'},
ProgrammingError("Information schema query returned too much data. Please repeat query with more "
"selective predicates.", 90030),
Error,
hide_parameters=False,
connection_invalidated=False,
dialect=SnowflakeDialect(),
ismulti=None
)
else:
return original_execute(command, *args, **kwargs)

Expand Down
4 changes: 1 addition & 3 deletions test/test_unit_cte.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
# Copyright (c) 2012-2019 Snowflake Computing Inc. All right reserved.
#

from snowflake.connector.compat import TO_UNICODE


def test_cte():
from snowflake.sqlalchemy import snowdialect
Expand All @@ -21,7 +19,7 @@ def test_cte():
with_bar = select([literal(product_id), literal(day), literal(count)]).cte('bar')
sel = select([with_bar])
ins = visitors.insert().from_select([visitors.c.product_id, visitors.c.date1, visitors.c.count], sel)
assert TO_UNICODE(ins.compile(dialect=snowdialect.dialect())) == (
assert str(ins.compile(dialect=snowdialect.dialect())) == (
"INSERT INTO visitors (product_id, date1, count) WITH bar AS \n"
"(SELECT %(param_1)s AS anon_1, %(param_2)s AS anon_2, %(param_3)s AS anon_3)\n"
" SELECT bar.anon_1, bar.anon_2, bar.anon_3 \n"
Expand Down
2 changes: 1 addition & 1 deletion version.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Update this for the versions
# Don't change the forth version number from None
VERSION = (1, 2, 3, None)
VERSION = (1, 2, 4, None)

0 comments on commit 666843d

Please sign in to comment.