cloudera / impyla

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

Can't Get the Scheme #407

Open neverloaf198911 opened 4 years ago

neverloaf198911 commented 4 years ago

Hi, I write a Sql like this : select* from ( select XXXX from ( select XXXX from dw_subssnapshot_day where day_id = "%s" and operator_account_id like "%%WLW%%" ) cards left join (YYYY) smz_2b on cards.vid = smz_2b.vid left join td_sim_state state on cards.source = state.source and cards.sim_state = state.sim_state_id left join (ZZZZ) smz_2c on substring(cards.iccid,1,19) = smz_2c.iccid_lunh left join p_mid_model_security_cards_tmp1 acct_base on cards.vid = acct_base.vid left join td_ct_province prov on prov.city_code = acct_base.city_id left join td_partition_scene pl on pl.partition_scene_id = acct_base.product_line_id left join td_partition_product p on p.partition_product_id = acct_base.product_id left join p_mid_model_security_cards_tmp22 delivery_time on cards.iccid = delivery_time.iccid union select XXXXXXXXXXfrom ( YYYY) cards left join (ZZZZZ) smz_2b on cards.vid = smz_2b.vid left join td_sim_state state on cards.source = state.source and cards.sim_state = state.sim_state_id left join (QQQQ) smz_2c on substring(cards.iccid,1,19) = smz_2c.iccid_lunh left join p_mid_model_security_cards_tmp1 acct_base on cards.vid = acct_base.vid left join td_ct_province prov on prov.city_code = acct_base.city_id left join td_partition_scene pl on pl.partition_scene_id = acct_base.product_line_id left join td_partition_product p on p.partition_product_id = acct_base.product_id left join p_mid_model_security_cards_tmp22 delivery_time on cards.iccid = delivery_time.iccid ) all_cards where substring(all_cards.iccid,1,19) in (%s) or all_cards.msisdn in (%s) '''

And I got a mistake like this: Traceback (most recent call last): File "C:/Users/neverloaf/PycharmProjects/smz_decode/sm4-tool.py", line 155, in print(cursor.description) File "C:\Users\neverloaf\PycharmProjects\smz_decode\venv\lib\site-packages\impala\hiveserver2.py", line 187, in description schema = self._last_operation.get_result_schema() File "C:\Users\neverloaf\PycharmProjects\smz_decode\venv\lib\site-packages\impala\hiveserver2.py", line 1271, in get_result_schema entry = column.typeDesc.types[0].primitiveEntry AttributeError: 'NoneType' object has no attribute 'types'

It seems the code cant get the schema, then cant get the type, ...

if the SQL just like select * from tableA,the code runs well

So, pls help me,really really thanks!!

neverloaf198911 commented 4 years ago

Get the mistake when fetchall(),or description()

timarmstrong commented 4 years ago

What are you connecting to (Hive or Impala) and what server version are you using?

What python version?

neverloaf198911 commented 4 years ago

What are you connecting to (Hive or Impala) and what server version are you using?

What python version?

thanks ,connecting to hive,python version 3.7 . and the hive server version is centos7. and now the client programe is on windows10

neverloaf198911 commented 4 years ago

Hi, New situation!! It seems that if i use the exact field name,it works。but if the num of fields >=20,then the error happened.

worked SQL: select all_cards.iccid, all_cards.iccid19, all_cards.msisdn, all_cards.imsi, all_cards.vid, all_cards.prov_name, all_cards.city_name, all_cards.partition_scene_name, all_cards.partition_product_name, all_cards.belong_vid_type, all_cards.delivery_time, all_cards.sim_state, all_cards.res_person_id, all_cards.res_person_name, all_cards.res_cert_code, all_cards.res_cert_address, all_cards.res_cert_mobile, all_cards.nature_person_id, all_cards.nature_person_name from ......

error SQL: select all_cards.iccid, all_cards.iccid19, all_cards.msisdn, all_cards.imsi, all_cards.vid, all_cards.prov_name, all_cards.city_name, all_cards.partition_scene_name, all_cards.partition_product_name, all_cards.belong_vid_type, all_cards.delivery_time, all_cards.sim_state, all_cards.res_person_id, all_cards.res_person_name, all_cards.res_cert_code, all_cards.res_cert_address, all_cards.res_cert_mobile, all_cards.nature_person_id, all_cards.nature_person_name, all_cards.nature_person_name from ......

jojochuang commented 3 years ago

Client: Mac OS Catalina, Python 3.7, Impyla latest version (0.16.3), thirftpy2 0.4.12 Server side: CDH 5.16.2

Reproducible for me with a few wide tables. It seems that selecting * on wide tables with more than 256 columns, the impyla returns null TTableSchema.

DEBUG:impala.hiveserver2:GetResultSetMetadata: resp=TGetResultSetMetadataResp(status=TStatus(statusCode=0, infoMessages=None, sqlState=None, errorCode=None, errorMessage=None), schema=TTableSchema(columns=[TColumnDesc(columnName=None, typeDesc=None, position=None, comment=None)]))
nehaverma1142 commented 3 years ago

@neverloaf198911 : Hi, did you got any resolution to above problem. I am facing exactly similar issue.

nehaverma1142 commented 3 years ago

@jojochuang : Hi, did you got any resolution to above problem. I am facing exactly similar issue.

jojochuang commented 3 years ago

No unfortunately. I eventually partially worked around it by explicitly listing all columns of interest.