Skip to content
This repository was archived by the owner on May 5, 2022. It is now read-only.

Commit d343c46

Browse files
authored
Merge pull request #6 from cccs-tom/master
Handle the Trino node_version being non-numeric
2 parents 5af0cc9 + 2863e34 commit d343c46

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

sqlalchemy_trino/dialect.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from sqlalchemy.engine.default import DefaultDialect, DefaultExecutionContext
77
from sqlalchemy.engine.url import URL
88
from trino.auth import BasicAuthentication
9+
import re
910

1011
from . import compiler
1112
from . import datatype
@@ -58,6 +59,9 @@ class TrinoDialect(DefaultDialect):
5859
supports_empty_insert = False
5960
supports_multivalues_insert = True
6061

62+
# Version parser
63+
__version_pattern = re.compile('(\d+).*')
64+
6165
@classmethod
6266
def dbapi(cls):
6367
"""
@@ -264,7 +268,8 @@ def _get_server_version_info(self, connection: Connection) -> Tuple[int, ...]:
264268
WHERE coordinator = true AND state = 'active'
265269
''').strip()
266270
res = connection.execute(sql.text(query)).first()
267-
version = int(res.node_version)
271+
parsed_version = self.__version_pattern.match(res.node_version)
272+
version = int(parsed_version.group(1)) if parsed_version else 0
268273
return tuple([version])
269274

270275
def _get_default_schema_name(self, connection: Connection) -> Optional[str]:

0 commit comments

Comments
 (0)