druid-io / pydruid

A Python connector for Druid
Other
506 stars 194 forks source link

JSONDecodeError: Expecting value: line 1 column 1 (char 0) #123

Open pals966 opened 6 years ago

pals966 commented 6 years ago

I am trying to read druid data base using python 3.5 and DB API of pydruid; however whenever I run the execute statement I get the error:

Code I am running: from pydruid.db import connect conn = connect(host='XXXXXXX', port=8082, path='/druid/v2', scheme='http') curs = conn.cursor() curs.execute("""SELECT * FROM wikipedia LIMIT 10""")

Error: _--------------------------------------------------------------------------- JSONDecodeError Traceback (most recent call last)

in () ----> 1 curs.execute("""SELECT * FROM wikipedia LIMIT 10""") /apps/cmor/anaconda3/lib/python3.5/site-packages/pydruid-0.3.1-py3.5.egg/pydruid/db/api.py in g(self, *args, **kwargs) 39 raise exceptions.Error( 40 '{klass} already closed'.format(klass=self.__class__.__name__)) ---> 41 return f(self, *args, **kwargs) 42 return g 43 /apps/cmor/anaconda3/lib/python3.5/site-packages/pydruid-0.3.1-py3.5.egg/pydruid/db/api.py in execute(self, operation, parameters) 187 # let's consume it and insert it back. 188 results = self._stream_query(query) --> 189 first_row = next(results) 190 self._results = itertools.chain([first_row], results) 191 /apps/cmor/anaconda3/lib/python3.5/site-packages/pydruid-0.3.1-py3.5.egg/pydruid/db/api.py in _stream_query(self, query) 267 # raise any error messages 268 if r.status_code != 200: --> 269 payload = r.json() 270 msg = ( 271 '{error} ({errorClass}): {errorMessage}'.format(**payload) /apps/cmor/anaconda3/lib/python3.5/site-packages/requests/models.py in json(self, **kwargs) 892 # used. 893 pass --> 894 return complexjson.loads(self.text, **kwargs) 895 896 @property /apps/cmor/anaconda3/lib/python3.5/json/__init__.py in loads(s, encoding, cls, object_hook, parse_float, parse_int, parse_constant, object_pairs_hook, **kw) 317 parse_int is None and parse_float is None and 318 parse_constant is None and object_pairs_hook is None and not kw): --> 319 return _default_decoder.decode(s) 320 if cls is None: 321 cls = JSONDecoder /apps/cmor/anaconda3/lib/python3.5/json/decoder.py in decode(self, s, _w) 337 338 """ --> 339 obj, end = self.raw_decode(s, idx=_w(s, 0).end()) 340 end = _w(s, end).end() 341 if end != len(s): /apps/cmor/anaconda3/lib/python3.5/json/decoder.py in raw_decode(self, s, idx) 355 obj, end = self.scan_once(s, idx) 356 except StopIteration as err: --> 357 raise JSONDecodeError("Expecting value", s, err.value) from None 358 return obj, end **JSONDecodeError: Expecting value: line 1 column 1 (char 0)**_
gianm commented 6 years ago

I think this means you are getting some error page as HTML; it should be reported cleaner after #121.

gianm commented 6 years ago

I would suggest either upgrading to a pydruid that has #121 (sorry I am not sure which one that would be!) or checking your Druid server logs for more details (they usually log errors like this).

mistercrunch commented 6 years ago

121 is not in any releases yet. The only way to get the changelog per version at the moment is to pull the git tag and looking at the git log.

Would be nice to fix the issue at the source eventually, I feel like we shouldn't have heterogenous endpoints, all errors should be json-parseable.

Dubrzr commented 6 years ago

I have the same issue, but this is probably due to kerberos. Is kerberos supported in pydruid?

RafaelReia commented 5 years ago

I had the same error

Expecting value: line 1 column 1 (char 0)_

and I fixed it by enabling SQL in Druid: http://druid.io/docs/latest/querying/sql.html

To enable Druid SQL, make sure you have set druid.sql.enable = true either in your common.runtime.properties or your broker's runtime.properties.