cloudera / impyla

Python DB API 2.0 client for Impala and Hive (HiveServer2 protocol)
Apache License 2.0
725 stars 247 forks source link

TypeError: bytes expected, not NoneType when fetching queries #443

Open jsertel opened 3 years ago

jsertel commented 3 years ago

I am trying to query impala through python using impyla. I am able to connect and execute certain things like select version() and describe tables. However fetching any query results gives an error of TypeError: bytes expected, not NoneType, or sometimes Invalid query handle. (Stack traces below)

An output of select version, and describe:

cur.execute('select version()') [('impalad version 3.2.0-cdh6.2.1 RELEASE (build 525e372410dd2ce206e2ad0f21f57cae7380c0cb)\nBuilt on Wed Sep 11 01:30:44 PDT 2019',)] cur.execute("describe mytable") [('position_status_code', 'string', ''), ('position_num', 'string', ''), ('position_design_status', 'string', ''), ('position_effective_date', 'timestamp', ''), ('position_design_end_date', 'timestamp', ''), ('job_function_code', 'string', ''), ('job_function_desc', 'string', ''), ('job_subfunction_code', 'string', ''), ('job_subfunction_desc', 'string', ''), ('full_parttime_code', 'string', ''), ('full_parttime_desc', 'string', ''), ('officer_code', 'string', ''), ('employee_reg_temp', 'string', ''), ('position_filled_vacant', 'string', ''), ('employee_id', 'string', ''), ('employee_name', 'string', ''), ('employee_entergy_userid', 'string', ''), ('employee_status_desc', 'string', ''), ('company_code', 'string', ''), ('paygroup', 'string', ''), ('job_family_code', 'string', ''), ('job_family_desc', 'string', ''), ('jobcode', 'string', ''), ('jobtitle', 'string', ''), ('union_code', 'string', ''), ('union_desc', 'string', ''), ('flsa_code', 'string', ''), ('flsa_desc', 'string', ''), ('ast_code', 'string', ''), ('ast_desc', 'string', ''), ('eeo5_desc', 'string', ''), ('employee_type_desc', 'string', ''), ('mail_drop', 'string', ''), ('location_group_desc', 'string', ''), ('location_desc', 'string', ''), ('department_id', 'string', ''), ('department_effective_date', 'timestamp', ''), ('manager_level', 'string', ''), ('l01_employee_name', 'string', ''), ('l02_employee_name', 'string', ''), ('l03_employee_name', 'string', ''), ('l04_employee_name', 'string', ''), ('l05_employee_name', 'string', ''), ('l06_employee_name', 'string', ''), ('l07_employee_name', 'string', ''), ('l08_employee_name', 'string', ''), ('l09_employee_name', 'string', ''), ('l10_employee_name', 'string', ''), ('l01_position_num', 'string', ''), ('l02_position_num', 'string', ''), ('l03_position_num', 'string', ''), ('l04_position_num', 'string', ''), ('l05_position_num', 'string', ''), ('l06_position_num', 'string', ''), ('l07_position_num', 'string', ''), ('l08_position_num', 'string', ''), ('l09_position_num', 'string', ''), ('l10_position_num', 'string', ''), ('supervisor_name', 'string', ''), ('supervisor_employee_id', 'string', ''), ('supervisor_position_num', 'string', ''), ('supervisor_job_title', 'string', ''), ('position_function', 'string', ''), ('per_org_code', 'string', ''), ('per_org_desc', 'string', ''), ('edl_load_date', 'timestamp', '')]

Attempting to fetch results from any query sometimes returns this error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/u01/airflow/venv/lib/python3.6/site-packages/impala/hiveserver2.py", line 536, in fetchall
    return list(self)
  File "/u01/airflow/venv/lib/python3.6/site-packages/impala/hiveserver2.py", line 584, in __next__
    convert_types=self.convert_types)
  File "/u01/airflow/venv/lib/python3.6/site-packages/impala/hiveserver2.py", line 1268, in fetch
    convert_types=convert_types)
  File "/u01/airflow/venv/lib/python3.6/site-packages/impala/hiveserver2.py", line 1273, in _wrap_results
    return CBatch(results, expect_more_rows, schema, convert_types=convert_types)
  File "/u01/airflow/venv/lib/python3.6/site-packages/impala/hiveserver2.py", line 924, in __init__
    is_null.frombytes(nulls)
TypeError: bytes expected, not NoneType

Other times it returns this error:

Traceback (most recent call last): File "", line 1, in File "/u01/airflow/venv/lib/python3.6/site-packages/impala/hiveserver2.py", line 536, in fetchall return list(self) File "/u01/airflow/venv/lib/python3.6/site-packages/impala/hiveserver2.py", line 584, in next convert_types=self.convert_types) File "/u01/airflow/venv/lib/python3.6/site-packages/impala/hiveserver2.py", line 1266, in fetch resp = self._rpc('FetchResults', req) File "/u01/airflow/venv/lib/python3.6/site-packages/impala/hiveserver2.py", line 995, in _rpc err_if_rpc_not_ok(response) File "/u01/airflow/venv/lib/python3.6/site-packages/impala/hiveserver2.py", line 749, in err_if_rpc_not_ok raise HiveServer2Error(resp.status.errorMessage) impala.error.HiveServer2Error: Invalid query handle: 8f42487f58a216eb:28c608b300000000

attilajeges commented 3 years ago

Hi, could you please try to reproduce the issue with the latest impyla release: https://pypi.org/project/impyla/0.17.0/ ?