PyHive icon indicating copy to clipboard operation
PyHive copied to clipboard

Presto queries fail with semicolon added

Open bradmiro opened this issue 5 years ago • 1 comments

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 :)

bradmiro avatar Jun 26 '20 22:06 bradmiro

Nobody has provided a solution to this??

Rather frustrating to have to run my queries one-by-one...

chestergan-cartrack avatar Oct 27 '21 09:10 chestergan-cartrack