gpt4 book ai didi

perl - 当我尝试使用 Thrift::API::HiveClient 执行语句时,为什么会出现错误 "Thrift::TException=HASH(0x122b9e0)"?

转载 作者:行者123 更新时间:2023-12-02 04:43:06 25 4
gpt4 key购买 nike

我正在尝试连接到 Apache Hive来自 Perl 脚本,但出现以下错误:

Thrift::TException=HASH(0x122b9e0)

我正在运行 Hadoop 2.7.0 版、Hive 1.1.0 版和 Thrift::API::HiveClient 0.003 版。这是我正在使用的脚本:

#!/usr/bin/perl

use English;
use Thrift::API::HiveClient;

connecttoHive();

sub connecttoHive {
my $client = Thrift::API::HiveClient->new( host => 'localhost', port => 10000 );

$client->connect() or die "Failed to connect";

$client -> execute('select count(1) from Koushik.emp2');
my $result = $client -> fetchAll();
}

这是版本问题还是其他原因?


我还尝试运行以下脚本,它随 Thrift-API-HiveClient-0.003 发行版一起提供:

#!/usr/bin/env perl
use lib 'lib';
use Data::Dumper;
use Try::Tiny;
use Thrift::API::HiveClient;
#use Moose;

my ($host, $port) = (localhost => 10000);

try sub {
my $client = Thrift::API::HiveClient->new( host => $host, port => $port );
$client->connect;
print "Connected\n";
$client->execute(
q{ create table if not exists t_foo (foo STRING, bar STRING) }
);
$client->execute('show tables');
print Dumper $client->fetchAll;
print Dumper $client->getClusterStatus;
print Dumper $client->get_fields( 'default', 't_foo');
},
catch sub {
print "ZOMG\n";
print Dumper($_);
exit 1;
};

我得到以下输出:

hduser@ubuntu:~/perl_script$ perl test-thrift.pl
Connected
ZOMG
$VAR1 = bless( {
'message' => 'Missing version identifier',
'code' => 0
}, 'Thrift::TException' );

通过修改 hive-site.xml 在我的 HiveServer2 上启用 NOSASL 身份验证后,我现在收到一个不同的错误:

hduser@ubuntu:~/perl_script$ perl test-thrift.pl
Connected
ZOMG
$VAR1 = bless( {
'message' => 'Invalid method name: \'execute\'',
'code' => 1
}, 'TApplicationException' );

它使用 Thrift::API::HiveClient2 工作

hduser@ubuntu:~/perl_script$ cat test-thrift-client2.pl
#!/usr/bin/env perl
use lib 'lib';
use Data::Dumper;
use Try::Tiny;
use Thrift::API::HiveClient2;
#use Moose;

my ($host, $port) = (localhost => 10000);

try sub {
my $client = Thrift::API::HiveClient2->new( host => $host, port => $port );
$client->connect;
print "Connected\n";
$client->execute(
q{ create table if not exists t_foo (foo STRING, bar STRING) }
);
$client->execute('show tables');
print Dumper $client->fetch;
# print Dumper $client->getClusterStatus;
# print Dumper $client->get_fields( 'default', 't_foo');
},
catch sub {
print "ZOMG\n";
print Dumper($_);
exit 1;
};

hduser@ubuntu:~/perl_script$ perl test-thrift-client2.pl
Connected
$VAR1 = [
[
'drv_cdr_mp'
],
[
'emp1'
],
[
'emp3'
],
[
'emp_1'
],
[
'emp_bucket'
],
[
'emp_incr_test'
],
[
'emp_rslt'
],
[
'log_detail'
],
[
't_foo'
],
[
'test1_emp1'
]
];
$VAR2 = '';

最佳答案

由于您使用的是 HiveServer2,请尝试使用 Thrift::API::HiveClient2。如果这不起作用,您可以将一些调试打印放入客户端以查看是否有任何与网络相关的事情发生,例如超时。

关于perl - 当我尝试使用 Thrift::API::HiveClient 执行语句时,为什么会出现错误 "Thrift::TException=HASH(0x122b9e0)"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35799885/

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