Skip to content

Commit 7214a97

Browse files
smtakedaankit-bhatnagar167
authored andcommittedFeb 22, 2019
SNOW-66729: Separated base.py file into smaller files and fixed import statements
1 parent d2eb4ff commit 7214a97

19 files changed

+1058
-1007
lines changed
 

‎LICENSE.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@
187187
same "printed page" as the copyright notice for easier
188188
identification within third-party archives.
189189

190-
Copyright (c) 2012-2018 Snowflake Computing, Inc.
190+
Copyright (c) 2012-2019 Snowflake Computing, Inc.
191191

192192
Licensed under the Apache License, Version 2.0 (the "License");
193193
you may not use this file except in compliance with the License.

‎__init__.py

+29-9
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,39 @@
11
#!/usr/bin/env python
22
# -*- coding: utf-8 -*-
33
#
4-
# Copyright (c) 2012-2018 Snowflake Computing Inc. All right reserved.
4+
# Copyright (c) 2012-2019 Snowflake Computing Inc. All right reserved.
55
#
66

7-
from snowflake.sqlalchemy.base import (
8-
VARIANT, ARRAY, OBJECT, TIMESTAMP_LTZ, TIMESTAMP_TZ, TIMESTAMP_NTZ, MergeInto, CSVFormatter, JSONFormatter,
9-
PARQUETFormatter, CopyIntoStorage, AWSBucket, AzureContainer, SnowflakeDialect)
10-
from snowflake.sqlalchemy.util import _url as URL
11-
from snowflake.sqlalchemy.version import VERSION
12-
from snowflake.connector.compat import (TO_UNICODE)
7+
from . import base
8+
from . import snowdialect
9+
from .custom_commands import (
10+
MergeInto, CSVFormatter, JSONFormatter, PARQUETFormatter, CopyIntoStorage, AWSBucket, AzureContainer
11+
)
12+
from .util import _url as URL
13+
from .version import VERSION
14+
from snowflake.connector.compat import TO_UNICODE
15+
from .custom_types import VARIANT, ARRAY, OBJECT, TIMESTAMP_LTZ, TIMESTAMP_TZ, TIMESTAMP_NTZ
1316

14-
__all__ = ('VARIANT', 'ARRAY', 'OBJECT', 'TIMESTAMP_LTZ', 'TIMESTAMP_TZ', 'TIMESTAMP_NTZ', 'MergeInto',
15-
'CSVFormatter', 'JSONFormatter', 'PARQUETFormatter', 'CopyIntoStorage', 'AWSBucket', 'AzureContainer')
1617

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

20+
21+
base.dialect = dialect = snowdialect.dialect
22+
1923
__version__ = SNOWFLAKE_CONNECTOR_VERSION
24+
25+
__all__ = (
26+
'VARIANT',
27+
'ARRAY',
28+
'OBJECT',
29+
'TIMESTAMP_LTZ',
30+
'TIMESTAMP_TZ',
31+
'TIMESTAMP_NTZ',
32+
'MergeInto',
33+
'CSVFormatter',
34+
'JSONFormatter',
35+
'PARQUETFormatter',
36+
'CopyIntoStorage',
37+
'AWSBucket',
38+
'AzureContainer'
39+
)

‎base.py

+12-973
Large diffs are not rendered by default.

‎custom_commands.py

+401
Large diffs are not rendered by default.

‎custom_types.py

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
#
4+
# Copyright (c) 2012-2019 Snowflake Computing Inc. All right reserved.
5+
#
6+
7+
import sqlalchemy.types as sqltypes
8+
9+
10+
class VARIANT(sqltypes.TypeEngine):
11+
__visit_name__ = 'VARIANT'
12+
13+
14+
class OBJECT(sqltypes.TypeEngine):
15+
__visit_name__ = 'OBJECT'
16+
17+
18+
class ARRAY(sqltypes.TypeEngine):
19+
__visit_name__ = 'ARRAY'
20+
21+
22+
class TIMESTAMP_TZ(sqltypes.TIMESTAMP):
23+
__visit_name__ = 'TIMESTAMP_TZ'
24+
25+
26+
class TIMESTAMP_LTZ(sqltypes.TIMESTAMP):
27+
__visit_name__ = 'TIMESTAMP_LTZ'
28+
29+
30+
class TIMESTAMP_NTZ(sqltypes.TIMESTAMP):
31+
__visit_name__ = 'TIMESTAMP_NTZ'
32+

‎setup.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env python
22
# -*- coding: utf-8 -*-
33
#
4-
# Copyright (c) 2012-2018 Snowflake Computing Inc. All right reserved.
4+
# Copyright (c) 2012-2019 Snowflake Computing Inc. All right reserved.
55
#
66

77
from os import path, getenv
@@ -50,7 +50,7 @@
5050
},
5151
entry_points={
5252
'sqlalchemy.dialects': [
53-
'snowflake=snowflake.sqlalchemy.base:SnowflakeDialect',
53+
'snowflake=snowflake.sqlalchemy:dialect',
5454
]
5555
},
5656
classifiers = [

‎snowdialect.py

+558
Large diffs are not rendered by default.

‎test/conftest.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env python
22
# -*- coding: utf-8 -*-
33
#
4-
# Copyright (c) 2012-2018 Snowflake Computing Inc. All right reserved.
4+
# Copyright (c) 2012-2019 Snowflake Computing Inc. All right reserved.
55
#
66

77
import os
@@ -16,7 +16,7 @@
1616

1717
import snowflake.connector
1818
from snowflake.connector.compat import TO_UNICODE
19-
from snowflake.sqlalchemy import URL, SnowflakeDialect
19+
from snowflake.sqlalchemy import URL, dialect
2020

2121
if os.getenv('TRAVIS') == 'true':
2222
TEST_SCHEMA = 'TRAVIS_JOB_{0}'.format(os.getenv('TRAVIS_JOB_ID'))
@@ -157,6 +157,6 @@ def fin():
157157

158158
@pytest.fixture(scope='session')
159159
def sql_compiler():
160-
return lambda sql_command: str(sql_command.compile(dialect=SnowflakeDialect(),
160+
return lambda sql_command: str(sql_command.compile(dialect=dialect(),
161161
compile_kwargs={'literal_binds': True,
162162
'deterministic': True})).replace('\n', '')

‎test/test_core.py

+8-7
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,24 @@
11
#!/usr/bin/env python
22
# -*- coding: utf-8 -*-
33
#
4-
# Copyright (c) 2012-2018 Snowflake Computing Inc. All right reserved.
4+
# Copyright (c) 2012-2019 Snowflake Computing Inc. All right reserved.
55
#
66
import os
77
import re
88

99
import pytest
10-
from parameters import (CONNECTION_PARAMETERS)
11-
from sqlalchemy import (Table, Column, Integer, Numeric, String, MetaData,
12-
Sequence, ForeignKey, LargeBinary, REAL, Boolean)
10+
from parameters import CONNECTION_PARAMETERS
11+
from sqlalchemy import Table, Column, Integer, Numeric, String, MetaData, Sequence, ForeignKey, LargeBinary, REAL, Boolean
1312
from sqlalchemy import inspect
1413
from sqlalchemy import text
1514
from sqlalchemy import dialects
1615
from sqlalchemy.sql import and_, or_, not_
1716
from sqlalchemy.sql import select
1817

19-
from snowflake.sqlalchemy import (URL, CopyIntoStorage, CSVFormatter, JSONFormatter, MergeInto,
20-
PARQUETFormatter, AWSBucket, AzureContainer, SnowflakeDialect)
18+
from snowflake.sqlalchemy import (
19+
URL, CopyIntoStorage, CSVFormatter, JSONFormatter, MergeInto, PARQUETFormatter, AWSBucket, AzureContainer,
20+
dialect
21+
)
2122

2223
try:
2324
from parameters import (CONNECTION_PARAMETERS2)
@@ -802,7 +803,7 @@ def test_load_dialect():
802803
"""
803804
Test loading Snowflake SQLAlchemy dialect class
804805
"""
805-
assert isinstance(dialects.registry.load('snowflake')(), SnowflakeDialect)
806+
assert isinstance(dialects.registry.load('snowflake')(), dialect)
806807

807808

808809
@pytest.mark.parametrize('conditional_flag', [True, False])

‎test/test_multivalues_insert.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env python
22
# -*- coding: utf-8 -*-
33
#
4-
# Copyright (c) 2012-2018 Snowflake Computing Inc. All right reserved.
4+
# Copyright (c) 2012-2019 Snowflake Computing Inc. All right reserved.
55
#
66

77
from sqlalchemy import (Integer, String, Sequence)

‎test/test_orm.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env python
22
# -*- coding: utf-8 -*-
33
#
4-
# Copyright (c) 2012-2018 Snowflake Computing Inc. All right reserved.
4+
# Copyright (c) 2012-2019 Snowflake Computing Inc. All right reserved.
55
#
66

77
import pytest

‎test/test_pandas.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env python
22
# -*- coding: utf-8 -*-
33
#
4-
# Copyright (c) 2012-2018 Snowflake Computing Inc. All right reserved.
4+
# Copyright (c) 2012-2019 Snowflake Computing Inc. All right reserved.
55
#
66

77
import pytest

‎test/test_qmark.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env python
22
# -*- coding: utf-8 -*-
33
#
4-
# Copyright (c) 2012-2018 Snowflake Computing Inc. All right reserved.
4+
# Copyright (c) 2012-2019 Snowflake Computing Inc. All right reserved.
55
#
66
import os
77

‎test/test_quote.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env python
22
# -*- coding: utf-8 -*-
33
#
4-
# Copyright (c) 2012-2018 Snowflake Computing Inc. All right reserved.
4+
# Copyright (c) 2012-2019 Snowflake Computing Inc. All right reserved.
55
#
66

77
from sqlalchemy import (Table, Column, Integer, String, MetaData, Sequence)

‎test/test_semi_structured_datatypes.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env python
22
# -*- coding: utf-8 -*-
33
#
4-
# Copyright (c) 2012-2018 Snowflake Computing Inc. All right reserved.
4+
# Copyright (c) 2012-2019 Snowflake Computing Inc. All right reserved.
55
#
66

77
import json

‎test/test_timestamp.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env python
22
# -*- coding: utf-8 -*-
33
#
4-
# Copyright (c) 2012-2018 Snowflake Computing Inc. All right reserved.
4+
# Copyright (c) 2012-2019 Snowflake Computing Inc. All right reserved.
55
#
66

77
from parameters import (CONNECTION_PARAMETERS)

‎test/test_unit_core.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env python
22
# -*- coding: utf-8 -*-
33
#
4-
# Copyright (c) 2012-2018 Snowflake Computing Inc. All right reserved.
4+
# Copyright (c) 2012-2019 Snowflake Computing Inc. All right reserved.
55
#
66

77
from sqlalchemy.engine.url import URL
@@ -10,7 +10,7 @@
1010

1111

1212
def test_create_connect_args():
13-
sfdialect = base.SnowflakeDialect()
13+
sfdialect = base.dialect()
1414

1515
test_data = [
1616
(
@@ -86,7 +86,7 @@ def test_create_connect_args():
8686

8787

8888
def test_denormalize_quote_join():
89-
sfdialect = base.SnowflakeDialect()
89+
sfdialect = base.dialect()
9090

9191
test_data = [
9292
(['abc', 'cde'], 'abc.cde'),

‎test/test_unit_url.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env python
22
# -*- coding: utf-8 -*-
33
#
4-
# Copyright (c) 2012-2018 Snowflake Computing Inc. All right reserved.
4+
# Copyright (c) 2012-2019 Snowflake Computing Inc. All right reserved.
55
#
66

77
from snowflake.sqlalchemy import URL

‎util.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env python
22
# -*- coding: utf-8 -*-
33
#
4-
# Copyright (c) 2012-2018 Snowflake Computing Inc. All right reserved.
4+
# Copyright (c) 2012-2019 Snowflake Computing Inc. All right reserved.
55
#
66

77
from sqlalchemy import exc

0 commit comments

Comments
 (0)
Please sign in to comment.