Skip to content

Commit 9265b58

Browse files
authored
Fix CI errors reported (#312)
* Fix CI errors reported Travis is currently reporting some errors: 1) sqlalchemy 1.3 seems to have introduced a new positional arg called resolve_fks for reflect, that causes CI to fail when sqlalchemy installed by pypi is greater than 1.2.8. It seems out of scope to migrate PyHive to sqlalchemy 1.3.0, so I just added some safeguards in setup.py and travis config to avoid the new version. 2) urllib.util.parse_url seems to refuse to parse http://localhost:99999, raising an exception that is not the one expected in the test. Fixed the port with 9999. 3) WAITING_FOR_RESOURCES, QUEUED can be states of a Presto query, add them to the test. Issue #288 * Bump sqlalchemy dependencies to 1.3.0 Calls to the reflecttable() method are complaining about the absence of resolve_fks when sqlalchemy>=1.3.0 is used. 'Binary' is deprecated. Replacing it with 'LargeBinary' to incorporate changes in pull request #293. issue #288
1 parent 437eefa commit 9265b58

File tree

5 files changed

+17
-13
lines changed

5 files changed

+17
-13
lines changed

.travis.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ matrix:
66
# https://docs.python.org/devguide/#status-of-python-branches
77
# One build pulls latest versions dynamically
88
- python: 3.6
9-
env: CDH=cdh5 CDH_VERSION=5 PRESTO=RELEASE SQLALCHEMY=sqlalchemy
9+
env: CDH=cdh5 CDH_VERSION=5 PRESTO=RELEASE SQLALCHEMY=sqlalchemy>=1.3.0
1010
- python: 3.6
11-
env: CDH=cdh5 CDH_VERSION=5.10.1 PRESTO=0.147 SQLALCHEMY=sqlalchemy==1.2.8
11+
env: CDH=cdh5 CDH_VERSION=5.10.1 PRESTO=0.147 SQLALCHEMY=sqlalchemy>=1.3.0
1212
- python: 3.5
13-
env: CDH=cdh5 CDH_VERSION=5.10.1 PRESTO=0.147 SQLALCHEMY=sqlalchemy==1.2.8
13+
env: CDH=cdh5 CDH_VERSION=5.10.1 PRESTO=0.147 SQLALCHEMY=sqlalchemy>=1.3.0
1414
- python: 3.4
15-
env: CDH=cdh5 CDH_VERSION=5.10.1 PRESTO=0.147 SQLALCHEMY=sqlalchemy==1.2.8
15+
env: CDH=cdh5 CDH_VERSION=5.10.1 PRESTO=0.147 SQLALCHEMY=sqlalchemy>=1.3.0
1616
- python: 2.7
17-
env: CDH=cdh5 CDH_VERSION=5.10.1 PRESTO=0.147 SQLALCHEMY=sqlalchemy==1.2.8
17+
env: CDH=cdh5 CDH_VERSION=5.10.1 PRESTO=0.147 SQLALCHEMY=sqlalchemy>=1.3.0
1818
install:
1919
- ./scripts/travis-install.sh
2020
- pip install codecov

pyhive/tests/sqlalchemy_test_case.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ def test_reflect_include_columns(self, engine, connection):
6464
"""When passed include_columns, reflecttable should filter out other columns"""
6565
one_row_complex = Table('one_row_complex', MetaData(bind=engine))
6666
engine.dialect.reflecttable(
67-
connection, one_row_complex, include_columns=['int'], exclude_columns=[])
67+
connection, one_row_complex, include_columns=['int'],
68+
exclude_columns=[], resolve_fks=True)
6869
self.assertEqual(len(one_row_complex.c), 1)
6970
self.assertIsNotNone(one_row_complex.c.int)
7071
self.assertRaises(AttributeError, lambda: one_row_complex.c.tinyint)
@@ -86,14 +87,16 @@ def test_reflect_partitions(self, engine, connection):
8687

8788
many_rows = Table('many_rows', MetaData(bind=engine))
8889
engine.dialect.reflecttable(
89-
connection, many_rows, include_columns=['a'], exclude_columns=[])
90+
connection, many_rows, include_columns=['a'],
91+
exclude_columns=[], resolve_fks=True)
9092
self.assertEqual(len(many_rows.c), 1)
9193
self.assertFalse(many_rows.c.a.index)
9294
self.assertFalse(many_rows.indexes)
9395

9496
many_rows = Table('many_rows', MetaData(bind=engine))
9597
engine.dialect.reflecttable(
96-
connection, many_rows, include_columns=['b'], exclude_columns=[])
98+
connection, many_rows, include_columns=['b'],
99+
exclude_columns=[], resolve_fks=True)
97100
self.assertEqual(len(many_rows.c), 1)
98101
self.assertEqual(repr(many_rows.indexes), repr({Index('partition', many_rows.c.b)}))
99102

pyhive/tests/test_presto.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,8 @@ def test_cancel(self, cursor):
9696
"FROM many_rows a "
9797
"CROSS JOIN many_rows b "
9898
)
99-
self.assertIn(cursor.poll()['stats']['state'], ('STARTING', 'PLANNING', 'RUNNING'))
99+
self.assertIn(cursor.poll()['stats']['state'], (
100+
'STARTING', 'PLANNING', 'RUNNING', 'WAITING_FOR_RESOURCES', 'QUEUED'))
100101
cursor.cancel()
101102
self.assertIsNone(cursor.poll())
102103

@@ -202,7 +203,7 @@ def test_invalid_kwargs(self):
202203
def test_requests_kwargs(self):
203204
connection = presto.connect(
204205
host=_HOST, port=_PORT, source=self.id(),
205-
requests_kwargs={'proxies': {'http': 'localhost:99999'}},
206+
requests_kwargs={'proxies': {'http': 'localhost:9999'}},
206207
)
207208
cursor = connection.cursor()
208209
self.assertRaises(requests.exceptions.ProxyError,

pyhive/tests/test_sqlalchemy_hive.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ def test_lots_of_types(self, engine, connection):
151151
'NUMERIC', 'DECIMAL', 'TIMESTAMP', 'DATETIME', 'CLOB', 'BLOB',
152152
'BOOLEAN', 'SMALLINT', 'DATE', 'TIME',
153153
'String', 'Integer', 'SmallInteger',
154-
'Numeric', 'Float', 'DateTime', 'Date', 'Time', 'Binary',
154+
'Numeric', 'Float', 'DateTime', 'Date', 'Time', 'LargeBinary',
155155
'Boolean', 'Unicode', 'UnicodeText',
156156
]
157157
cols = []

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def run_tests(self):
4545
extras_require={
4646
'presto': ['requests>=1.0.0'],
4747
'hive': ['sasl>=0.2.1', 'thrift>=0.10.0', 'thrift_sasl>=0.1.0'],
48-
'sqlalchemy': ['sqlalchemy>=0.8.7'],
48+
'sqlalchemy': ['sqlalchemy>=1.3.0'],
4949
'kerberos': ['requests_kerberos>=0.12.0'],
5050
},
5151
tests_require=[
@@ -55,7 +55,7 @@ def run_tests(self):
5555
'requests>=1.0.0',
5656
'requests_kerberos>=0.12.0',
5757
'sasl>=0.2.1',
58-
'sqlalchemy>=0.12.0',
58+
'sqlalchemy>=1.3.0',
5959
'thrift>=0.10.0',
6060
],
6161
cmdclass={'test': PyTest},

0 commit comments

Comments
 (0)