python3.6使用impyla(0.6.3)连接HiveServer2,查询数据,报错:HiveServer2Error('Invalid OperationHandle: OperationHandle [opType=EXECUTE_STATEMENT, getHandleIdentifier()=a367ecbb-7d60-4306-8ab7-b3af603730c7]',):
代码如下
try:
conn = connect(host=hive_host, port=hive_port, database=hive_database, user=hive_user,
password=hive_password, auth_mechanism=‘PLAIN’, timeout=60)
print('=====>获取数据-1')
cursor = conn.cursor()
print('=====>获取数据-2')
cursor.execute('select guid from large_data.wjc_test_ques limit 2000')
#cursor.execute('select longitude from large_data.zatest limit 0,2000')
print('=====>获取数据-3')
data_original = cursor.fetchall()
print("data_original length:", len(data_original))
except Exception as e:
print('======>error')
print(repr(e))
运行结果及报错内容
======>error
HiveServer2Error('Invalid OperationHandle: OperationHandle [opType=EXECUTE_STATEMENT, getHandleIdentifier()=a367ecbb-7d60-4306-8ab7-b3af603730c7]',)
我的解答思路和尝试过的方法
1.更换java代码实现正常,limit 多少都可以查询出数据。
2.怀疑表中的数据或类型有问题,重新建表,只有一个字段,类型为varchar(36),数据为989580条,前十条数据内容如下。
hive> select * from wjc_test_ques limit 10;
OK
69FB3F26-875B-4153-B14D-E31EB7E1B69B
BC4ECF24-92B9-4B4F-9FB6-84E0CB65CF53
31947B91-B133-4ED8-919A-08FA0E249F15
DF245662-8DAB-4525-BADB-F604D72178BC
D829AA04-FFB8-41F7-8E85-C3208B12B663
5C6982B1-2655-417F-B273-2EF80C9E5573
FEA251C2-E8F9-40CE-BD1B-F12029CD839C
1C7DFA73-A7AA-4E56-8AD2-BEF7C1578128
6D66066A-16FA-4682-B49B-63C24732C12E
1F407B30-8032-43C0-9471-DE5744F5C88B
Time taken: 0.284 seconds, Fetched: 10 row(s)
执行sql:select guid from large_data.wjc_test_ques limit 200 不报错
执行sql:select guid from large_data.wjc_test_ques limit 2000 报错
hive中的日志信息如下:
2022-03-24 06:23:17,299 WARN org.apache.hive.service.cli.thrift.ThriftCLIService: [HiveServer2-Handler-Pool: Thread-1512]: Error fetching results:
org.apache.hive.service.cli.HiveSQLException: Invalid OperationHandle: OperationHandle [opType=EXECUTE_STATEMENT, getHandleIdentifier()=3c2f4ebf-3bbe-4707-8901-087dcdb00b22]
at org.apache.hive.service.cli.operation.OperationManager.getOperation(OperationManager.java:177) ~[hive-service-2.1.1-cdh6.1.0.jar:2.1.1-cdh6.1.0]
at org.apache.hive.service.cli.CLIService.fetchResults(CLIService.java:506) ~[hive-service-2.1.1-cdh6.1.0.jar:2.1.1-cdh6.1.0]
at org.apache.hive.service.cli.thrift.ThriftCLIService.FetchResults(ThriftCLIService.java:708) [hive-service-2.1.1-cdh6.1.0.jar:2.1.1-cdh6.1.0]
at org.apache.hive.service.rpc.thrift.TCLIService$Processor$FetchResults.getResult(TCLIService.java:1717) [hive-exec-2.1.1-cdh6.1.0.jar:2.1.1-cdh6.1.0]
at org.apache.hive.service.rpc.thrift.TCLIService$Processor$FetchResults.getResult(TCLIService.java:1702) [hive-exec-2.1.1-cdh6.1.0.jar:2.1.1-cdh6.1.0]
at org.apache.thrift.ProcessFunction.process(ProcessFunction.java:39) [hive-exec-2.1.1-cdh6.1.0.jar:2.1.1-cdh6.1.0]
at org.apache.thrift.TBaseProcessor.process(TBaseProcessor.java:39) [hive-exec-2.1.1-cdh6.1.0.jar:2.1.1-cdh6.1.0]
at org.apache.hive.service.auth.TSetIpAddressProcessor.process(TSetIpAddressProcessor.java:56) [hive-service-2.1.1-cdh6.1.0.jar:2.1.1-cdh6.1.0]
at org.apache.thrift.server.TThreadPoolServer$WorkerProcess.run(TThreadPoolServer.java:286) [hive-exec-2.1.1-cdh6.1.0.jar:2.1.1-cdh6.1.0]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_141]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_141]
at java.lang.Thread.run(Thread.java:748) [?:1.8.0_141]
2022-03-24 06:23:17,324 INFO org.apache.hive.service.cli.session.HiveSessionImpl: [172467b8-d40d-4335-bbe2-c21982b78047 HiveServer2-Handler-Pool: Thread-1501]: Operation log session directory is deleted: /var/log/hive/operation_logs/172467b8-d40d-4335-bbe2-c21982b78047