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

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日

悬赏问题

  • ¥20 电脑鼠标键盘不好使了
  • ¥15 求糕手!用matlab求解目标规划模型🙏
  • ¥15 画出的分类图不对,求解答一下
  • ¥20 springboot和springcloud版本问题
  • ¥15 ps2手柄控制树莓派小车
  • ¥30 C#:vsto powerpoint的外接程序
  • ¥30 stata将do文件代码转化为ado文件
  • ¥15 两个同维数组相比,不同位置、出现重复比无意义,而不同位置、不出现重复比,则有意义。把有意义的两个数组放入新的集合MK中。
  • ¥15 可以远程电脑安装nvm
  • ¥15 写一个可直接调用的函数,将32位有符号数转成另一个无符号的数