0

I have a sql like

select * from log where concat_ws('-',year,month,day) between 2017-09-13 and 2017-09-19

which is wrong because of not having 2017-09-13 and 2017-09-19 surrounded by ''.

In beeline, it will result the error msg like

Error: Error while compiling statement: FAILED: ParseException line 2:0 missing EOF at 'select' near ']' (state=42000,code=40000)

but in PyHive, it goes normal with the empty result []. By the way, I am using it through sqlalchemy.

I've tried to use echo=True in the create_engine() function and logging, but both can not output the error msg.

from sqlalchemy.engine import create_engine
from pyhive import hive
import logging

logging.basicConfig()
logging.getLogger('sqlalchemy.engine').setLevel(logging.DEBUG)

sql = "select * from log where concat_ws('-',year,month,day) between 2017-09-13 and 2017-09-19"

db = create_engine(
    'hive://user:pass@ip:port/test',
    connect_args={
        'auth': 'LDAP', 
        'configuration': {
            'mapreduce.job.queuename': 'queue'
        }
    },
    echo=True
)
resultProxy=db.execute(sql)
data = resultProxy.fetchall()

2017-09-20 12:17:22,904 INFO sqlalchemy.engine.base.Engine select * from log where concat_ws('-',year,month,day) between 2017-09-13 and 2017-09-19

INFO:sqlalchemy.engine.base.Engine:select * from log where concat_ws('-',year,month,day) between 2017-09-13 and 2017-09-19

2017-09-20 12:17:22,905 INFO sqlalchemy.engine.base.Engine {}

INFO:sqlalchemy.engine.base.Engine:{}

So I wonder if there is a way to get the server side error, it will be convenient to debug.

1 Answers1

0

I got this, 2017-09-13 is valid Hive syntax. It just means integer subtraction. The error in beeline is about something else.