qq_25213363 2022-03-24 19:22 采纳率: 33.3%
浏览 450
已结题

HiveServer2Error('Invalid OperationHandle: OperationHandle [opType=EXECUTE_STATEMENT

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

请帮我解决掉报错,可以正常查出数据。
  • 写回答

1条回答 默认 最新

  • DarkAthena ORACLE应用及数据库设计方案咨询师 2022-03-24 20:24
    关注

    加一行代码,把 arraysize 设置成 1

    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()
        cursor.arraysize = 1
        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))
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

问题事件

  • 系统已结题 4月2日
  • 已采纳回答 3月25日
  • 创建了问题 3月24日

悬赏问题

  • ¥15 VFP如何使用阿里TTS实现文字转语音?
  • ¥100 需要跳转番茄畅听app的adb命令
  • ¥50 寻找一位有逆向游戏盾sdk 应用程序经验的技术
  • ¥15 请问有用MZmine处理 “Waters SYNAPT G2-Si QTOF质谱仪在MSE模式下采集的非靶向数据” 的分析教程吗
  • ¥50 opencv4nodejs 如何安装
  • ¥15 adb push异常 adb: error: 1409-byte write failed: Invalid argument
  • ¥15 nginx反向代理获取ip,java获取真实ip
  • ¥15 eda:门禁系统设计
  • ¥50 如何使用js去调用vscode-js-debugger的方法去调试网页
  • ¥15 376.1电表主站通信协议下发指令全被否认问题