question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Druid + Hive query "22" error

See original GitHub issue

To reproduce this issue you will need to create external table stored by druid in hive and try to query it from superset.

In sql lab you will see smth like this:

latest-screenshot

The real error is here:

Traceback (most recent call last):
  File "/home/tvorogme/projects/incubator-superset/superset/sql_lab.py", line 196, in execute_sql_statement
    data = db_engine_spec.fetch_data(cursor, query.limit)
  File "/home/tvorogme/projects/incubator-superset/superset/db_engine_specs.py", line 1400, in fetch_data
    return super(HiveEngineSpec, cls).fetch_data(cursor, limit)
  File "/home/tvorogme/projects/incubator-superset/superset/db_engine_specs.py", line 160, in fetch_data
    return cursor.fetchall()
  File "/usr/lib/python3.7/site-packages/pyhive/common.py", line 136, in fetchall
    return list(iter(self.fetchone, None))
  File "/usr/lib/python3.7/site-packages/pyhive/common.py", line 105, in fetchone
    self._fetch_while(lambda: not self._data and self._state != self._STATE_FINISHED)
  File "/usr/lib/python3.7/site-packages/pyhive/common.py", line 45, in _fetch_while
    self._fetch_more()
  File "/usr/lib/python3.7/site-packages/pyhive/hive.py", line 389, in _fetch_more
    schema = self.description
  File "/usr/lib/python3.7/site-packages/pyhive/hive.py", line 320, in description
    type_code = ttypes.TTypeId._VALUES_TO_NAMES[type_id]
KeyError: 22

The problem is in connector.

Lets see what is ttypes.TTypeId._VALUES_TO_NAMES:

{0: 'BOOLEAN_TYPE', 1: 'TINYINT_TYPE', 2: 'SMALLINT_TYPE', 3: 'INT_TYPE', 4: 'BIGINT_TYPE', 5: 'FLOAT_TYPE', 6: 'DOUBLE_TYPE', 7: 'STRING_TYPE', 8: 'TIMESTAMP_TYPE', 9: 'BINARY_TYPE', 10: 'ARRAY_TYPE', 11: 'MAP_TYPE', 12: 'STRUCT_TYPE', 13: 'UNION_TYPE', 14: 'USER_DEFINED_TYPE', 15: 'DECIMAL_TYPE', 16: 'NULL_TYPE', 17: 'DATE_TYPE', 18: 'VARCHAR_TYPE', 19: 'CHAR_TYPE', 20: 'INTERVAL_YEAR_MONTH_TYPE', 21: 'INTERVAL_DAY_TIME_TYPE'}

Ok. Now we need to know where type_id coming from:

primary_type_entry = col.typeDesc.types[0]
type_id = primary_type_entry.primitiveEntry.type

And now if you want to see column - it will be __time

So i have created issue in PyHive.

The easy solution for now replace 313 line in pyhive/hive.py

from

type_code = ttypes.TTypeId._VALUES_TO_NAMES[type_id] to type_code = ttypes.TTypeId._VALUES_TO_NAMES[type_id if type_id != 22 else 18]

18 is datetime so all will be cool:

latest-screenshot

P.S. I know that is not superset problem, but i guess many superset users use pyhive, so I just wanted to share my solution.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
mistercrunchcommented, Jul 16, 2019

Mmmh looks like out-of-sync Thrift stuff, like the server is returning error codes that the client doesn’t know about yet because it’s too old. Seems like you need a newer Hive thrift client.

0reactions
stale[bot]commented, Sep 16, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. For admin, please label this issue .pinned to prevent stale bot from closing the issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Druid + Hive query "22" error · Issue #7520 · apache/superset
To reproduce this issue you will need to create external table stored by druid in hive and try to query it from superset....
Read more >
Solved: Hive & Druid Integration Deserialize Error
But I got a deserialization error when running query Q4.2. Has anyone seen this before? I am using HDP2.6.1. INFO : We are...
Read more >
Not able run hive query, getting following error ( Error while ...
I have created one dummy table in hive and then created druid table but now when I am running select query or show...
Read more >
Latest Google Groups topics - Apache Druid® Forum (by Imply)
Error when running Druid SQL queries in tutorial. 4 ; Is it possible to Select a dimension which got added in "dimensionExclusions"? 7...
Read more >
Newest 'druid' Questions - Stack Overflow
Druid query in Power BI shows errors. I've got a problem connecting my report with a Druid database, based on a query that...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found