PyHive
PyHive copied to clipboard
Presto queries fail with semicolon added
Presto SQL commands typically require a semicolon in multiline queries to mark completion (and is also good practice for single-line queries):
SHOW
CATALOGS;
However, this does not currently work with PyHive:
from pyhive import presto
cursor = presto.connect('my-presto-instance').cursor()
cursor.execute('''SHOW
CATALOGS;
''')
print(cursor.fetchall())
Error:
DatabaseError: {'message': "line 2:24: mismatched input ';'. Expecting: 'LIKE', <EOF>", 'errorCode': 1, 'errorName': 'SYNTAX_ERROR', 'errorType': 'USER_ERROR', 'errorLocation': {'lineNumber': 2, 'columnNumber': 24}, 'failureInfo': {'type': 'io.prestosql.sql.parser.ParsingException', 'message': "line 2:24: mismatched input ';'.
The semicolon must be stripped from the query to work properly:
from pyhive import presto
cursor = presto.connect('my-presto-instance').cursor()
cursor.execute('''SHOW
CATALOGS
''')
print(cursor.fetchall())
This might be a lower-level problem than PyHive but I figured I would start here to see if there's any suggestions :)
Nobody has provided a solution to this??
Rather frustrating to have to run my queries one-by-one...