gpt4 book ai didi

python - 使用 `PyHive`使用表格名称开头的数字访问Hive表格会出现错误

转载 作者:行者123 更新时间:2023-12-02 21:29:02 27 4
gpt4 key购买 nike

我正在使用PyHive访问我的Hive服务器:

# Connection parameters
hive_host = "server.redecorp.com"
hive_port = 10000
hive_options = {'job.queue.name': 'myqueue'}

connection = hive.Connection(host=hive_host, port=hive_port, configuration=hive_options)
cursor = connection.cursor()

它的工作原理是:
cursor.execute('show databases')
cursor.fetchall()

----
my_database
default
----

如果我尝试使用表开头的数字访问表或数据库,则会收到错误消息:
cursor.execute('select * from my_database.2016_my_table')

给我
OperationalError  Traceback (most recent call last)
<ipython-input-16-1e42ea2af711> in <module>()


OperationalError: TExecuteStatementResp(status=TStatus(errorCode=1, errorMessage='Error while processing statement: FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.tez.TezTask', sqlState='08S01', infoMessages=['*org.apache.hive.service.cli.HiveSQLException:Error while processing statement: FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.tez.TezTask:29:28', 'org.apache.hive.service.cli.operation.Operation:toSQLException:Operation.java:314', 'org.apache.hive.service.cli.operation.SQLOperation:runQuery:SQLOperation.java:146', 'org.apache.hive.service.cli.operation.SQLOperation:runInternal:SQLOperation.java:173', 'org.apache.hive.service.cli.operation.Operation:run:Operation.java:256', 'org.apache.hive.service.cli.session.HiveSessionImpl:executeStatementInternal:HiveSessionImpl.java:376', 'org.apache.hive.service.cli.session.HiveSessionImpl:executeStatement:HiveSessionImpl.java:357', 'sun.reflect.GeneratedMethodAccessor184:invoke::-1', 'sun.reflect.DelegatingMethodAccessorImpl:invoke:DelegatingMethodAccessorImpl.java:43', 'java.lang.reflect.Method:invoke:Method.java:606', 'org.apache.hive.service.cli.session.HiveSessionProxy:invoke:HiveSessionProxy.java:79', 'org.apache.hive.service.cli.session.HiveSessionProxy:access$000:HiveSessionProxy.java:37', 'org.apache.hive.service.cli.session.HiveSessionProxy$1:run:HiveSessionProxy.java:64', 'java.security.AccessController:doPrivileged:AccessController.java:-2', 'javax.security.auth.Subject:doAs:Subject.java:415', 'org.apache.hadoop.security.UserGroupInformation:doAs:UserGroupInformation.java:1628', 'org.apache.hadoop.hive.shims.HadoopShimsSecure:doAs:HadoopShimsSecure.java:536', 'org.apache.hive.service.cli.session.HiveSessionProxy:invoke:HiveSessionProxy.java:60', 'com.sun.proxy.$Proxy23:executeStatement::-1', 'org.apache.hive.service.cli.CLIService:executeStatement:CLIService.java:234', 'org.apache.hive.service.cli.thrift.ThriftCLIService:ExecuteStatement:ThriftCLIService.java:401', 'org.apache.hive.service.cli.thrift.TCLIService$Processor$ExecuteStatement:getResult:TCLIService.java:1313', 'org.apache.hive.service.cli.thrift.TCLIService$Processor$ExecuteStatement:getResult:TCLIService.java:1298', 'org.apache.thrift.ProcessFunction:process:ProcessFunction.java:39', 'org.apache.thrift.TBaseProcessor:process:TBaseProcessor.java:39', 'org.apache.hive.service.auth.TSetIpAddressProcessor:process:TSetIpAddressProcessor.java:56', 'org.apache.thrift.server.TThreadPoolServer$WorkerProcess:run:TThreadPoolServer.java:206', 'java.util.concurrent.ThreadPoolExecutor:runWorker:ThreadPoolExecutor.java:1145', 'java.util.concurrent.ThreadPoolExecutor$Worker:run:ThreadPoolExecutor.java:615', 'java.lang.Thread:run:Thread.java:745'], statusCode=3), operationHandle=None)

有谁知道解决方法或解决方案?我不能更改表的名称。

最佳答案

问题不在于表名,问题在于您使用的是select * from database.2016_my_table,但是数据库名为default,因此它应该是select * from default.2016_my_table

关于python - 使用 `PyHive`使用表格名称开头的数字访问Hive表格会出现错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34932750/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com