title: Why do I get the error "Thrift::TException=HASH(0x122b9e0)" when I try to execute a statement with Thrift::API::HiveClient?
body: <p>I am trying to connect to <a href="https://hive.apache.org/" rel="nofollow">Apache Hive</a> from a Perl script but I'm getting the following error:</p>
  
  <pre class="lang-none prettyprint-override"><code>Thrift::TException=HASH(0x122b9e0)
  </code></pre>
  
  <p>I am running with Hadoop version 2.7.0, Hive version 1.1.0, and Thrift::API::HiveClient version 0.003. Here is the script I am using:</p>
  
  <pre><code>#!/usr/bin/perl
  
  use English;
  use Thrift::API::HiveClient;
  
  connecttoHive();
  
  sub connecttoHive {
      my $client = Thrift::API::HiveClient-&gt;new( host =&gt; 'localhost', port =&gt; 10000 );
  
      $client-&gt;connect() or die "Failed to connect";
  
      $client -&gt; execute('select count(1) from Koushik.emp2');
      my $result = $client -&gt; fetchAll();
  }
  </code></pre>
  
  <p>Could this be caused by a version issue or is it something else?</p>
  
  <hr>
  
  <p>I also tried running the following script, which comes with the <code>Thrift-API-HiveClient-0.003</code> distribution:</p>
  
  <pre><code>#!/usr/bin/env perl
  use lib 'lib';
  use Data::Dumper;
  use Try::Tiny;
  use Thrift::API::HiveClient;
  #use Moose;
  
  my ($host, $port) = (localhost =&gt; 10000);
  
  try sub {
    my $client = Thrift::API::HiveClient-&gt;new( host =&gt; $host, port =&gt; $port );
    $client-&gt;connect;
    print "Connected\n";
    $client-&gt;execute(
      q{ create table if not exists t_foo (foo STRING, bar STRING) }
    );
    $client-&gt;execute('show tables');
    print Dumper $client-&gt;fetchAll;
    print Dumper $client-&gt;getClusterStatus;
    print Dumper $client-&gt;get_fields( 'default', 't_foo');
  },
  catch sub {
    print "ZOMG\n";
    print Dumper($_);
    exit 1;
  };
  </code></pre>
  
  <p>I get the following output:</p>
  
  <pre><code>hduser@ubuntu:~/perl_script$ perl test-thrift.pl
  Connected
  ZOMG
  $VAR1 = bless( {
                   'message' =&gt; 'Missing version identifier',
                   'code' =&gt; 0
                 }, 'Thrift::TException' );
  </code></pre>
  
  <p>After enabling NOSASL authentication on my HiveServer2 by modifying the hive-site.xml, I am now getting a different error:</p>
  
  <pre><code>hduser@ubuntu:~/perl_script$ perl test-thrift.pl
  Connected
  ZOMG
  $VAR1 = bless( {
                   'message' =&gt; 'Invalid method name: \'execute\'',
                   'code' =&gt; 1
                 }, 'TApplicationException' );
  </code></pre>
  
  <p>It worked using <code>Thrift::API::HiveClient2</code></p>
  
  <pre><code>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 =&gt; 10000);
  
  try sub {
    my $client = Thrift::API::HiveClient2-&gt;new( host =&gt; $host, port =&gt; $port );
    $client-&gt;connect;
    print "Connected\n";
    $client-&gt;execute(
      q{ create table if not exists t_foo (foo STRING, bar STRING) }
    );
    $client-&gt;execute('show tables');
    print Dumper $client-&gt;fetch;
  # print Dumper $client-&gt;getClusterStatus;
  # print Dumper $client-&gt;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 = '';
  </code></pre>