You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by zs...@apache.org on 2009/08/19 23:03:05 UTC

svn commit: r805973 [19/19] - in /hadoop/hive/trunk: ./ data/files/ eclipse-templates/ metastore/src/gen-javabean/org/apache/hadoop/hive/metastore/api/ metastore/src/gen-py/hive_metastore/ ql/ ql/if/ ql/src/gen-javabean/ ql/src/gen-javabean/org/ ql/src...

Modified: hadoop/hive/trunk/service/src/gen-php/ThriftHive.php
URL: http://svn.apache.org/viewvc/hadoop/hive/trunk/service/src/gen-php/ThriftHive.php?rev=805973&r1=805972&r2=805973&view=diff
==============================================================================
--- hadoop/hive/trunk/service/src/gen-php/ThriftHive.php (original)
+++ hadoop/hive/trunk/service/src/gen-php/ThriftHive.php Wed Aug 19 21:02:57 2009
@@ -17,6 +17,7 @@
   public function getSchema();
   public function getThriftSchema();
   public function getClusterStatus();
+  public function getQueryPlan();
 }
 
 class ThriftHiveClient extends ThriftHiveMetastoreClient implements ThriftHiveIf {
@@ -394,6 +395,59 @@
     throw new Exception("getClusterStatus failed: unknown result");
   }
 
+  public function getQueryPlan()
+  {
+    $this->send_getQueryPlan();
+    return $this->recv_getQueryPlan();
+  }
+
+  public function send_getQueryPlan()
+  {
+    $args = new ThriftHive_getQueryPlan_args();
+    $bin_accel = ($this->output_ instanceof TProtocol::$TBINARYPROTOCOLACCELERATED) && function_exists('thrift_protocol_write_binary');
+    if ($bin_accel)
+    {
+      thrift_protocol_write_binary($this->output_, 'getQueryPlan', TMessageType::CALL, $args, $this->seqid_, $this->output_->isStrictWrite());
+    }
+    else
+    {
+      $this->output_->writeMessageBegin('getQueryPlan', TMessageType::CALL, $this->seqid_);
+      $args->write($this->output_);
+      $this->output_->writeMessageEnd();
+      $this->output_->getTransport()->flush();
+    }
+  }
+
+  public function recv_getQueryPlan()
+  {
+    $bin_accel = ($this->input_ instanceof TProtocol::$TBINARYPROTOCOLACCELERATED) && function_exists('thrift_protocol_read_binary');
+    if ($bin_accel) $result = thrift_protocol_read_binary($this->input_, 'ThriftHive_getQueryPlan_result', $this->input_->isStrictRead());
+    else
+    {
+      $rseqid = 0;
+      $fname = null;
+      $mtype = 0;
+
+      $this->input_->readMessageBegin($fname, $mtype, $rseqid);
+      if ($mtype == TMessageType::EXCEPTION) {
+        $x = new TApplicationException();
+        $x->read($this->input_);
+        $this->input_->readMessageEnd();
+        throw $x;
+      }
+      $result = new ThriftHive_getQueryPlan_result();
+      $result->read($this->input_);
+      $this->input_->readMessageEnd();
+    }
+    if ($result->success !== null) {
+      return $result->success;
+    }
+    if ($result->ex !== null) {
+      throw $result->ex;
+    }
+    throw new Exception("getQueryPlan failed: unknown result");
+  }
+
 }
 
 // HELPER FUNCTIONS AND STRUCTURES
@@ -1497,4 +1551,153 @@
 
 }
 
+class ThriftHive_getQueryPlan_args {
+  static $_TSPEC;
+
+
+  public function __construct() {
+    if (!isset(self::$_TSPEC)) {
+      self::$_TSPEC = array(
+        );
+    }
+  }
+
+  public function getName() {
+    return 'ThriftHive_getQueryPlan_args';
+  }
+
+  public function read($input)
+  {
+    $xfer = 0;
+    $fname = null;
+    $ftype = 0;
+    $fid = 0;
+    $xfer += $input->readStructBegin($fname);
+    while (true)
+    {
+      $xfer += $input->readFieldBegin($fname, $ftype, $fid);
+      if ($ftype == TType::STOP) {
+        break;
+      }
+      switch ($fid)
+      {
+        default:
+          $xfer += $input->skip($ftype);
+          break;
+      }
+      $xfer += $input->readFieldEnd();
+    }
+    $xfer += $input->readStructEnd();
+    return $xfer;
+  }
+
+  public function write($output) {
+    $xfer = 0;
+    $xfer += $output->writeStructBegin('ThriftHive_getQueryPlan_args');
+    $xfer += $output->writeFieldStop();
+    $xfer += $output->writeStructEnd();
+    return $xfer;
+  }
+
+}
+
+class ThriftHive_getQueryPlan_result {
+  static $_TSPEC;
+
+  public $success = null;
+  public $ex = null;
+
+  public function __construct($vals=null) {
+    if (!isset(self::$_TSPEC)) {
+      self::$_TSPEC = array(
+        0 => array(
+          'var' => 'success',
+          'type' => TType::STRUCT,
+          'class' => 'QueryPlan',
+          ),
+        1 => array(
+          'var' => 'ex',
+          'type' => TType::STRUCT,
+          'class' => 'HiveServerException',
+          ),
+        );
+    }
+    if (is_array($vals)) {
+      if (isset($vals['success'])) {
+        $this->success = $vals['success'];
+      }
+      if (isset($vals['ex'])) {
+        $this->ex = $vals['ex'];
+      }
+    }
+  }
+
+  public function getName() {
+    return 'ThriftHive_getQueryPlan_result';
+  }
+
+  public function read($input)
+  {
+    $xfer = 0;
+    $fname = null;
+    $ftype = 0;
+    $fid = 0;
+    $xfer += $input->readStructBegin($fname);
+    while (true)
+    {
+      $xfer += $input->readFieldBegin($fname, $ftype, $fid);
+      if ($ftype == TType::STOP) {
+        break;
+      }
+      switch ($fid)
+      {
+        case 0:
+          if ($ftype == TType::STRUCT) {
+            $this->success = new QueryPlan();
+            $xfer += $this->success->read($input);
+          } else {
+            $xfer += $input->skip($ftype);
+          }
+          break;
+        case 1:
+          if ($ftype == TType::STRUCT) {
+            $this->ex = new HiveServerException();
+            $xfer += $this->ex->read($input);
+          } else {
+            $xfer += $input->skip($ftype);
+          }
+          break;
+        default:
+          $xfer += $input->skip($ftype);
+          break;
+      }
+      $xfer += $input->readFieldEnd();
+    }
+    $xfer += $input->readStructEnd();
+    return $xfer;
+  }
+
+  public function write($output) {
+    $xfer = 0;
+    $xfer += $output->writeStructBegin('ThriftHive_getQueryPlan_result');
+    if ($this->success !== null) {
+      if (!is_object($this->success)) {
+        throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA);
+      }
+      $xfer += $output->writeFieldBegin('success', TType::STRUCT, 0);
+      $xfer += $this->success->write($output);
+      $xfer += $output->writeFieldEnd();
+    }
+    if ($this->ex !== null) {
+      $xfer += $output->writeFieldBegin('ex', TType::STRUCT, 1);
+      $xfer += $this->ex->write($output);
+      $xfer += $output->writeFieldEnd();
+    }
+    $xfer += $output->writeFieldStop();
+    $xfer += $output->writeStructEnd();
+    return $xfer;
+  }
+
+}
+
 ?>

Modified: hadoop/hive/trunk/service/src/gen-php/hive_service_types.php
URL: http://svn.apache.org/viewvc/hadoop/hive/trunk/service/src/gen-php/hive_service_types.php?rev=805973&r1=805972&r2=805973&view=diff
==============================================================================
--- hadoop/hive/trunk/service/src/gen-php/hive_service_types.php (original)
+++ hadoop/hive/trunk/service/src/gen-php/hive_service_types.php Wed Aug 19 21:02:57 2009
@@ -8,6 +8,7 @@
 
 include_once $GLOBALS['THRIFT_ROOT'].'/packages/fb303/fb303_types.php';
 include_once $GLOBALS['THRIFT_ROOT'].'/packages/hive_metastore/hive_metastore_types.php';
+include_once $GLOBALS['THRIFT_ROOT'].'/packages/queryplan/queryplan_types.php';
 
 $GLOBALS['E_JobTrackerState'] = array(
   'INITIALIZING' => 1,

Modified: hadoop/hive/trunk/service/src/gen-py/hive_service/ThriftHive-remote
URL: http://svn.apache.org/viewvc/hadoop/hive/trunk/service/src/gen-py/hive_service/ThriftHive-remote?rev=805973&r1=805972&r2=805973&view=diff
==============================================================================
--- hadoop/hive/trunk/service/src/gen-py/hive_service/ThriftHive-remote (original)
+++ hadoop/hive/trunk/service/src/gen-py/hive_service/ThriftHive-remote Wed Aug 19 21:02:57 2009
@@ -28,6 +28,7 @@
   print '  Schema getSchema()'
   print '  Schema getThriftSchema()'
   print '  HiveClusterStatus getClusterStatus()'
+  print '  QueryPlan getQueryPlan()'
   print ''
   sys.exit(0)
 
@@ -118,4 +119,10 @@
     sys.exit(1)
   pp.pprint(client.getClusterStatus())
 
+elif cmd == 'getQueryPlan':
+  if len(args) != 0:
+    print 'getQueryPlan requires 0 args'
+    sys.exit(1)
+  pp.pprint(client.getQueryPlan())
+
 transport.close()

Modified: hadoop/hive/trunk/service/src/gen-py/hive_service/ThriftHive.py
URL: http://svn.apache.org/viewvc/hadoop/hive/trunk/service/src/gen-py/hive_service/ThriftHive.py?rev=805973&r1=805972&r2=805973&view=diff
==============================================================================
--- hadoop/hive/trunk/service/src/gen-py/hive_service/ThriftHive.py (original)
+++ hadoop/hive/trunk/service/src/gen-py/hive_service/ThriftHive.py Wed Aug 19 21:02:57 2009
@@ -46,6 +46,9 @@
   def getClusterStatus(self, ):
     pass
 
+  def getQueryPlan(self, ):
+    pass
+
 
 class Client(hive_metastore.ThriftHiveMetastore.Client, Iface):
   def __init__(self, iprot, oprot=None):
@@ -248,6 +251,33 @@
       raise result.ex
     raise TApplicationException(TApplicationException.MISSING_RESULT, "getClusterStatus failed: unknown result");
 
+  def getQueryPlan(self, ):
+    self.send_getQueryPlan()
+    return self.recv_getQueryPlan()
+
+  def send_getQueryPlan(self, ):
+    self._oprot.writeMessageBegin('getQueryPlan', TMessageType.CALL, self._seqid)
+    args = getQueryPlan_args()
+    args.write(self._oprot)
+    self._oprot.writeMessageEnd()
+    self._oprot.trans.flush()
+
+  def recv_getQueryPlan(self, ):
+    (fname, mtype, rseqid) = self._iprot.readMessageBegin()
+    if mtype == TMessageType.EXCEPTION:
+      x = TApplicationException()
+      x.read(self._iprot)
+      self._iprot.readMessageEnd()
+      raise x
+    result = getQueryPlan_result()
+    result.read(self._iprot)
+    self._iprot.readMessageEnd()
+    if result.success != None:
+      return result.success
+    if result.ex != None:
+      raise result.ex
+    raise TApplicationException(TApplicationException.MISSING_RESULT, "getQueryPlan failed: unknown result");
+
 
 class Processor(hive_metastore.ThriftHiveMetastore.Processor, Iface, TProcessor):
   def __init__(self, handler):
@@ -259,6 +289,7 @@
     self._processMap["getSchema"] = Processor.process_getSchema
     self._processMap["getThriftSchema"] = Processor.process_getThriftSchema
     self._processMap["getClusterStatus"] = Processor.process_getClusterStatus
+    self._processMap["getQueryPlan"] = Processor.process_getQueryPlan
 
   def process(self, iprot, oprot):
     (name, type, seqid) = iprot.readMessageBegin()
@@ -373,6 +404,20 @@
     oprot.writeMessageEnd()
     oprot.trans.flush()
 
+  def process_getQueryPlan(self, seqid, iprot, oprot):
+    args = getQueryPlan_args()
+    args.read(iprot)
+    iprot.readMessageEnd()
+    result = getQueryPlan_result()
+    try:
+      result.success = self._handler.getQueryPlan()
+    except HiveServerException, ex:
+      result.ex = ex
+    oprot.writeMessageBegin("getQueryPlan", TMessageType.REPLY, seqid)
+    result.write(oprot)
+    oprot.writeMessageEnd()
+    oprot.trans.flush()
+
 
 # HELPER FUNCTIONS AND STRUCTURES
 
@@ -1162,4 +1207,111 @@
   def __ne__(self, other):
     return not (self == other)
 
+class getQueryPlan_args:
+
+  thrift_spec = (
+  )
+
+  def read(self, iprot):
+    if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None:
+      fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec))
+      return
+    iprot.readStructBegin()
+    while True:
+      (fname, ftype, fid) = iprot.readFieldBegin()
+      if ftype == TType.STOP:
+        break
+      else:
+        iprot.skip(ftype)
+      iprot.readFieldEnd()
+    iprot.readStructEnd()
+
+  def write(self, oprot):
+    if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None:
+      oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)))
+      return
+    oprot.writeStructBegin('getQueryPlan_args')
+    oprot.writeFieldStop()
+    oprot.writeStructEnd()
+
+  def __repr__(self):
+    L = ['%s=%r' % (key, value)
+      for key, value in self.__dict__.iteritems()]
+    return '%s(%s)' % (self.__class__.__name__, ', '.join(L))
+
+  def __eq__(self, other):
+    return isinstance(other, self.__class__) and self.__dict__ == other.__dict__
+
+  def __ne__(self, other):
+    return not (self == other)
+
+class getQueryPlan_result:
+  """
+  Attributes:
+   - success
+   - ex
+  """
+
+  thrift_spec = (
+    (0, TType.STRUCT, 'success', (queryplan.ttypes.QueryPlan, queryplan.ttypes.QueryPlan.thrift_spec), None, ), # 0
+    (1, TType.STRUCT, 'ex', (HiveServerException, HiveServerException.thrift_spec), None, ), # 1
+  )
+
+  def __init__(self, success=None, ex=None,):
+    self.success = success
+    self.ex = ex
+
+  def read(self, iprot):
+    if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None:
+      fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec))
+      return
+    iprot.readStructBegin()
+    while True:
+      (fname, ftype, fid) = iprot.readFieldBegin()
+      if ftype == TType.STOP:
+        break
+      if fid == 0:
+        if ftype == TType.STRUCT:
+          self.success = queryplan.ttypes.QueryPlan()
+          self.success.read(iprot)
+        else:
+          iprot.skip(ftype)
+      elif fid == 1:
+        if ftype == TType.STRUCT:
+          self.ex = HiveServerException()
+          self.ex.read(iprot)
+        else:
+          iprot.skip(ftype)
+      else:
+        iprot.skip(ftype)
+      iprot.readFieldEnd()
+    iprot.readStructEnd()
+
+  def write(self, oprot):
+    if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None:
+      oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)))
+      return
+    oprot.writeStructBegin('getQueryPlan_result')
+    if self.success != None:
+      oprot.writeFieldBegin('success', TType.STRUCT, 0)
+      self.success.write(oprot)
+      oprot.writeFieldEnd()
+    if self.ex != None:
+      oprot.writeFieldBegin('ex', TType.STRUCT, 1)
+      self.ex.write(oprot)
+      oprot.writeFieldEnd()
+    oprot.writeFieldStop()
+    oprot.writeStructEnd()
+
+  def __repr__(self):
+    L = ['%s=%r' % (key, value)
+      for key, value in self.__dict__.iteritems()]
+    return '%s(%s)' % (self.__class__.__name__, ', '.join(L))
+
+  def __eq__(self, other):
+    return isinstance(other, self.__class__) and self.__dict__ == other.__dict__
+
+  def __ne__(self, other):
+    return not (self == other)
+
 

Modified: hadoop/hive/trunk/service/src/gen-py/hive_service/ttypes.py
URL: http://svn.apache.org/viewvc/hadoop/hive/trunk/service/src/gen-py/hive_service/ttypes.py?rev=805973&r1=805972&r2=805973&view=diff
==============================================================================
--- hadoop/hive/trunk/service/src/gen-py/hive_service/ttypes.py (original)
+++ hadoop/hive/trunk/service/src/gen-py/hive_service/ttypes.py Wed Aug 19 21:02:57 2009
@@ -7,6 +7,7 @@
 from thrift.Thrift import *
 import fb303.ttypes
 import hive_metastore.ttypes
+import queryplan.ttypes
 
 
 from thrift.transport import TTransport

Modified: hadoop/hive/trunk/service/src/java/org/apache/hadoop/hive/service/HiveServer.java
URL: http://svn.apache.org/viewvc/hadoop/hive/trunk/service/src/java/org/apache/hadoop/hive/service/HiveServer.java?rev=805973&r1=805972&r2=805973&view=diff
==============================================================================
--- hadoop/hive/trunk/service/src/java/org/apache/hadoop/hive/service/HiveServer.java (original)
+++ hadoop/hive/trunk/service/src/java/org/apache/hadoop/hive/service/HiveServer.java Wed Aug 19 21:02:57 2009
@@ -40,6 +40,8 @@
 import org.apache.thrift.transport.TTransport;
 import org.apache.thrift.transport.TTransportFactory;
 
+import org.apache.hadoop.hive.ql.plan.api.Query;
+import org.apache.hadoop.hive.ql.plan.api.QueryPlan;
 import org.apache.hadoop.hive.ql.processors.CommandProcessor;
 import org.apache.hadoop.hive.ql.processors.CommandProcessorFactory;
 import org.apache.hadoop.hive.ql.Driver;
@@ -279,6 +281,22 @@
     public String getVersion() {
       return VERSION;
     }
+
+    @Override
+    public QueryPlan getQueryPlan() throws HiveServerException, TException {
+      QueryPlan qp = new QueryPlan();
+      // TODO for now only return one query at a time
+      // going forward, all queries associated with a single statement
+      // will be returned in a single QueryPlan
+      try {
+        qp.addToQueries(driver.getQueryPlan());
+      }
+      catch (Exception e) {
+        throw new HiveServerException(e.toString());
+      }
+      return qp;
+    }
+    
   }
 	
   public static class ThriftHiveProcessorFactory extends TProcessorFactory {