You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by gu...@apache.org on 2014/02/14 11:53:39 UTC

svn commit: r1568236 [10/25] - in /hive/branches/tez: ./ bin/ cli/src/java/org/apache/hadoop/hive/cli/ cli/src/test/org/apache/hadoop/hive/cli/ common/src/java/org/apache/hadoop/hive/common/type/ common/src/java/org/apache/hadoop/hive/conf/ conf/ data/...

Modified: hive/branches/tez/metastore/src/gen/thrift/gen-py/hive_metastore/ttypes.py
URL: http://svn.apache.org/viewvc/hive/branches/tez/metastore/src/gen/thrift/gen-py/hive_metastore/ttypes.py?rev=1568236&r1=1568235&r2=1568236&view=diff
==============================================================================
--- hive/branches/tez/metastore/src/gen/thrift/gen-py/hive_metastore/ttypes.py (original)
+++ hive/branches/tez/metastore/src/gen/thrift/gen-py/hive_metastore/ttypes.py Fri Feb 14 10:53:31 2014
@@ -869,6 +869,11 @@ class Role:
    - roleName
    - createTime
    - ownerName
+   - principalName
+   - principalType
+   - grantOption
+   - grantTime
+   - grantor
   """
 
   thrift_spec = (
@@ -876,12 +881,22 @@ class Role:
     (1, TType.STRING, 'roleName', None, None, ), # 1
     (2, TType.I32, 'createTime', None, None, ), # 2
     (3, TType.STRING, 'ownerName', None, None, ), # 3
+    (4, TType.STRING, 'principalName', None, None, ), # 4
+    (5, TType.STRING, 'principalType', None, None, ), # 5
+    (6, TType.BOOL, 'grantOption', None, None, ), # 6
+    (7, TType.I32, 'grantTime', None, None, ), # 7
+    (8, TType.STRING, 'grantor', None, None, ), # 8
   )
 
-  def __init__(self, roleName=None, createTime=None, ownerName=None,):
+  def __init__(self, roleName=None, createTime=None, ownerName=None, principalName=None, principalType=None, grantOption=None, grantTime=None, grantor=None,):
     self.roleName = roleName
     self.createTime = createTime
     self.ownerName = ownerName
+    self.principalName = principalName
+    self.principalType = principalType
+    self.grantOption = grantOption
+    self.grantTime = grantTime
+    self.grantor = grantor
 
   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:
@@ -907,6 +922,31 @@ class Role:
           self.ownerName = iprot.readString();
         else:
           iprot.skip(ftype)
+      elif fid == 4:
+        if ftype == TType.STRING:
+          self.principalName = iprot.readString();
+        else:
+          iprot.skip(ftype)
+      elif fid == 5:
+        if ftype == TType.STRING:
+          self.principalType = iprot.readString();
+        else:
+          iprot.skip(ftype)
+      elif fid == 6:
+        if ftype == TType.BOOL:
+          self.grantOption = iprot.readBool();
+        else:
+          iprot.skip(ftype)
+      elif fid == 7:
+        if ftype == TType.I32:
+          self.grantTime = iprot.readI32();
+        else:
+          iprot.skip(ftype)
+      elif fid == 8:
+        if ftype == TType.STRING:
+          self.grantor = iprot.readString();
+        else:
+          iprot.skip(ftype)
       else:
         iprot.skip(ftype)
       iprot.readFieldEnd()
@@ -929,6 +969,26 @@ class Role:
       oprot.writeFieldBegin('ownerName', TType.STRING, 3)
       oprot.writeString(self.ownerName)
       oprot.writeFieldEnd()
+    if self.principalName is not None:
+      oprot.writeFieldBegin('principalName', TType.STRING, 4)
+      oprot.writeString(self.principalName)
+      oprot.writeFieldEnd()
+    if self.principalType is not None:
+      oprot.writeFieldBegin('principalType', TType.STRING, 5)
+      oprot.writeString(self.principalType)
+      oprot.writeFieldEnd()
+    if self.grantOption is not None:
+      oprot.writeFieldBegin('grantOption', TType.BOOL, 6)
+      oprot.writeBool(self.grantOption)
+      oprot.writeFieldEnd()
+    if self.grantTime is not None:
+      oprot.writeFieldBegin('grantTime', TType.I32, 7)
+      oprot.writeI32(self.grantTime)
+      oprot.writeFieldEnd()
+    if self.grantor is not None:
+      oprot.writeFieldBegin('grantor', TType.STRING, 8)
+      oprot.writeString(self.grantor)
+      oprot.writeFieldEnd()
     oprot.writeFieldStop()
     oprot.writeStructEnd()
 
@@ -3976,6 +4036,390 @@ class AddPartitionsRequest:
   def __ne__(self, other):
     return not (self == other)
 
+class DropPartitionsResult:
+  """
+  Attributes:
+   - partitions
+  """
+
+  thrift_spec = (
+    None, # 0
+    (1, TType.LIST, 'partitions', (TType.STRUCT,(Partition, Partition.thrift_spec)), None, ), # 1
+  )
+
+  def __init__(self, partitions=None,):
+    self.partitions = partitions
+
+  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 == 1:
+        if ftype == TType.LIST:
+          self.partitions = []
+          (_etype295, _size292) = iprot.readListBegin()
+          for _i296 in xrange(_size292):
+            _elem297 = Partition()
+            _elem297.read(iprot)
+            self.partitions.append(_elem297)
+          iprot.readListEnd()
+        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('DropPartitionsResult')
+    if self.partitions is not None:
+      oprot.writeFieldBegin('partitions', TType.LIST, 1)
+      oprot.writeListBegin(TType.STRUCT, len(self.partitions))
+      for iter298 in self.partitions:
+        iter298.write(oprot)
+      oprot.writeListEnd()
+      oprot.writeFieldEnd()
+    oprot.writeFieldStop()
+    oprot.writeStructEnd()
+
+  def validate(self):
+    return
+
+
+  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 DropPartitionsExpr:
+  """
+  Attributes:
+   - expr
+   - partArchiveLevel
+  """
+
+  thrift_spec = (
+    None, # 0
+    (1, TType.STRING, 'expr', None, None, ), # 1
+    (2, TType.I32, 'partArchiveLevel', None, None, ), # 2
+  )
+
+  def __init__(self, expr=None, partArchiveLevel=None,):
+    self.expr = expr
+    self.partArchiveLevel = partArchiveLevel
+
+  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 == 1:
+        if ftype == TType.STRING:
+          self.expr = iprot.readString();
+        else:
+          iprot.skip(ftype)
+      elif fid == 2:
+        if ftype == TType.I32:
+          self.partArchiveLevel = iprot.readI32();
+        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('DropPartitionsExpr')
+    if self.expr is not None:
+      oprot.writeFieldBegin('expr', TType.STRING, 1)
+      oprot.writeString(self.expr)
+      oprot.writeFieldEnd()
+    if self.partArchiveLevel is not None:
+      oprot.writeFieldBegin('partArchiveLevel', TType.I32, 2)
+      oprot.writeI32(self.partArchiveLevel)
+      oprot.writeFieldEnd()
+    oprot.writeFieldStop()
+    oprot.writeStructEnd()
+
+  def validate(self):
+    if self.expr is None:
+      raise TProtocol.TProtocolException(message='Required field expr is unset!')
+    return
+
+
+  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 RequestPartsSpec:
+  """
+  Attributes:
+   - names
+   - exprs
+  """
+
+  thrift_spec = (
+    None, # 0
+    (1, TType.LIST, 'names', (TType.STRING,None), None, ), # 1
+    (2, TType.LIST, 'exprs', (TType.STRUCT,(DropPartitionsExpr, DropPartitionsExpr.thrift_spec)), None, ), # 2
+  )
+
+  def __init__(self, names=None, exprs=None,):
+    self.names = names
+    self.exprs = exprs
+
+  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 == 1:
+        if ftype == TType.LIST:
+          self.names = []
+          (_etype302, _size299) = iprot.readListBegin()
+          for _i303 in xrange(_size299):
+            _elem304 = iprot.readString();
+            self.names.append(_elem304)
+          iprot.readListEnd()
+        else:
+          iprot.skip(ftype)
+      elif fid == 2:
+        if ftype == TType.LIST:
+          self.exprs = []
+          (_etype308, _size305) = iprot.readListBegin()
+          for _i309 in xrange(_size305):
+            _elem310 = DropPartitionsExpr()
+            _elem310.read(iprot)
+            self.exprs.append(_elem310)
+          iprot.readListEnd()
+        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('RequestPartsSpec')
+    if self.names is not None:
+      oprot.writeFieldBegin('names', TType.LIST, 1)
+      oprot.writeListBegin(TType.STRING, len(self.names))
+      for iter311 in self.names:
+        oprot.writeString(iter311)
+      oprot.writeListEnd()
+      oprot.writeFieldEnd()
+    if self.exprs is not None:
+      oprot.writeFieldBegin('exprs', TType.LIST, 2)
+      oprot.writeListBegin(TType.STRUCT, len(self.exprs))
+      for iter312 in self.exprs:
+        iter312.write(oprot)
+      oprot.writeListEnd()
+      oprot.writeFieldEnd()
+    oprot.writeFieldStop()
+    oprot.writeStructEnd()
+
+  def validate(self):
+    return
+
+
+  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 DropPartitionsRequest:
+  """
+  Attributes:
+   - dbName
+   - tblName
+   - parts
+   - deleteData
+   - ifExists
+   - ignoreProtection
+   - environmentContext
+   - needResult
+  """
+
+  thrift_spec = (
+    None, # 0
+    (1, TType.STRING, 'dbName', None, None, ), # 1
+    (2, TType.STRING, 'tblName', None, None, ), # 2
+    (3, TType.STRUCT, 'parts', (RequestPartsSpec, RequestPartsSpec.thrift_spec), None, ), # 3
+    (4, TType.BOOL, 'deleteData', None, None, ), # 4
+    (5, TType.BOOL, 'ifExists', None, True, ), # 5
+    (6, TType.BOOL, 'ignoreProtection', None, None, ), # 6
+    (7, TType.STRUCT, 'environmentContext', (EnvironmentContext, EnvironmentContext.thrift_spec), None, ), # 7
+    (8, TType.BOOL, 'needResult', None, True, ), # 8
+  )
+
+  def __init__(self, dbName=None, tblName=None, parts=None, deleteData=None, ifExists=thrift_spec[5][4], ignoreProtection=None, environmentContext=None, needResult=thrift_spec[8][4],):
+    self.dbName = dbName
+    self.tblName = tblName
+    self.parts = parts
+    self.deleteData = deleteData
+    self.ifExists = ifExists
+    self.ignoreProtection = ignoreProtection
+    self.environmentContext = environmentContext
+    self.needResult = needResult
+
+  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 == 1:
+        if ftype == TType.STRING:
+          self.dbName = iprot.readString();
+        else:
+          iprot.skip(ftype)
+      elif fid == 2:
+        if ftype == TType.STRING:
+          self.tblName = iprot.readString();
+        else:
+          iprot.skip(ftype)
+      elif fid == 3:
+        if ftype == TType.STRUCT:
+          self.parts = RequestPartsSpec()
+          self.parts.read(iprot)
+        else:
+          iprot.skip(ftype)
+      elif fid == 4:
+        if ftype == TType.BOOL:
+          self.deleteData = iprot.readBool();
+        else:
+          iprot.skip(ftype)
+      elif fid == 5:
+        if ftype == TType.BOOL:
+          self.ifExists = iprot.readBool();
+        else:
+          iprot.skip(ftype)
+      elif fid == 6:
+        if ftype == TType.BOOL:
+          self.ignoreProtection = iprot.readBool();
+        else:
+          iprot.skip(ftype)
+      elif fid == 7:
+        if ftype == TType.STRUCT:
+          self.environmentContext = EnvironmentContext()
+          self.environmentContext.read(iprot)
+        else:
+          iprot.skip(ftype)
+      elif fid == 8:
+        if ftype == TType.BOOL:
+          self.needResult = iprot.readBool();
+        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('DropPartitionsRequest')
+    if self.dbName is not None:
+      oprot.writeFieldBegin('dbName', TType.STRING, 1)
+      oprot.writeString(self.dbName)
+      oprot.writeFieldEnd()
+    if self.tblName is not None:
+      oprot.writeFieldBegin('tblName', TType.STRING, 2)
+      oprot.writeString(self.tblName)
+      oprot.writeFieldEnd()
+    if self.parts is not None:
+      oprot.writeFieldBegin('parts', TType.STRUCT, 3)
+      self.parts.write(oprot)
+      oprot.writeFieldEnd()
+    if self.deleteData is not None:
+      oprot.writeFieldBegin('deleteData', TType.BOOL, 4)
+      oprot.writeBool(self.deleteData)
+      oprot.writeFieldEnd()
+    if self.ifExists is not None:
+      oprot.writeFieldBegin('ifExists', TType.BOOL, 5)
+      oprot.writeBool(self.ifExists)
+      oprot.writeFieldEnd()
+    if self.ignoreProtection is not None:
+      oprot.writeFieldBegin('ignoreProtection', TType.BOOL, 6)
+      oprot.writeBool(self.ignoreProtection)
+      oprot.writeFieldEnd()
+    if self.environmentContext is not None:
+      oprot.writeFieldBegin('environmentContext', TType.STRUCT, 7)
+      self.environmentContext.write(oprot)
+      oprot.writeFieldEnd()
+    if self.needResult is not None:
+      oprot.writeFieldBegin('needResult', TType.BOOL, 8)
+      oprot.writeBool(self.needResult)
+      oprot.writeFieldEnd()
+    oprot.writeFieldStop()
+    oprot.writeStructEnd()
+
+  def validate(self):
+    if self.dbName is None:
+      raise TProtocol.TProtocolException(message='Required field dbName is unset!')
+    if self.tblName is None:
+      raise TProtocol.TProtocolException(message='Required field tblName is unset!')
+    if self.parts is None:
+      raise TProtocol.TProtocolException(message='Required field parts is unset!')
+    return
+
+
+  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 MetaException(TException):
   """
   Attributes:

Modified: hive/branches/tez/metastore/src/gen/thrift/gen-rb/hive_metastore_types.rb
URL: http://svn.apache.org/viewvc/hive/branches/tez/metastore/src/gen/thrift/gen-rb/hive_metastore_types.rb?rev=1568236&r1=1568235&r2=1568236&view=diff
==============================================================================
--- hive/branches/tez/metastore/src/gen/thrift/gen-rb/hive_metastore_types.rb (original)
+++ hive/branches/tez/metastore/src/gen/thrift/gen-rb/hive_metastore_types.rb Fri Feb 14 10:53:31 2014
@@ -212,11 +212,21 @@ class Role
   ROLENAME = 1
   CREATETIME = 2
   OWNERNAME = 3
+  PRINCIPALNAME = 4
+  PRINCIPALTYPE = 5
+  GRANTOPTION = 6
+  GRANTTIME = 7
+  GRANTOR = 8
 
   FIELDS = {
     ROLENAME => {:type => ::Thrift::Types::STRING, :name => 'roleName'},
     CREATETIME => {:type => ::Thrift::Types::I32, :name => 'createTime'},
-    OWNERNAME => {:type => ::Thrift::Types::STRING, :name => 'ownerName'}
+    OWNERNAME => {:type => ::Thrift::Types::STRING, :name => 'ownerName'},
+    PRINCIPALNAME => {:type => ::Thrift::Types::STRING, :name => 'principalName', :optional => true},
+    PRINCIPALTYPE => {:type => ::Thrift::Types::STRING, :name => 'principalType', :optional => true},
+    GRANTOPTION => {:type => ::Thrift::Types::BOOL, :name => 'grantOption', :optional => true},
+    GRANTTIME => {:type => ::Thrift::Types::I32, :name => 'grantTime', :optional => true},
+    GRANTOR => {:type => ::Thrift::Types::STRING, :name => 'grantor', :optional => true}
   }
 
   def struct_fields; FIELDS; end
@@ -900,6 +910,103 @@ class AddPartitionsRequest
   ::Thrift::Struct.generate_accessors self
 end
 
+class DropPartitionsResult
+  include ::Thrift::Struct, ::Thrift::Struct_Union
+  PARTITIONS = 1
+
+  FIELDS = {
+    PARTITIONS => {:type => ::Thrift::Types::LIST, :name => 'partitions', :element => {:type => ::Thrift::Types::STRUCT, :class => ::Partition}, :optional => true}
+  }
+
+  def struct_fields; FIELDS; end
+
+  def validate
+  end
+
+  ::Thrift::Struct.generate_accessors self
+end
+
+class DropPartitionsExpr
+  include ::Thrift::Struct, ::Thrift::Struct_Union
+  EXPR = 1
+  PARTARCHIVELEVEL = 2
+
+  FIELDS = {
+    EXPR => {:type => ::Thrift::Types::STRING, :name => 'expr', :binary => true},
+    PARTARCHIVELEVEL => {:type => ::Thrift::Types::I32, :name => 'partArchiveLevel', :optional => true}
+  }
+
+  def struct_fields; FIELDS; end
+
+  def validate
+    raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field expr is unset!') unless @expr
+  end
+
+  ::Thrift::Struct.generate_accessors self
+end
+
+class RequestPartsSpec < ::Thrift::Union
+  include ::Thrift::Struct_Union
+  class << self
+    def names(val)
+      RequestPartsSpec.new(:names, val)
+    end
+
+    def exprs(val)
+      RequestPartsSpec.new(:exprs, val)
+    end
+  end
+
+  NAMES = 1
+  EXPRS = 2
+
+  FIELDS = {
+    NAMES => {:type => ::Thrift::Types::LIST, :name => 'names', :element => {:type => ::Thrift::Types::STRING}},
+    EXPRS => {:type => ::Thrift::Types::LIST, :name => 'exprs', :element => {:type => ::Thrift::Types::STRUCT, :class => ::DropPartitionsExpr}}
+  }
+
+  def struct_fields; FIELDS; end
+
+  def validate
+    raise(StandardError, 'Union fields are not set.') if get_set_field.nil? || get_value.nil?
+  end
+
+  ::Thrift::Union.generate_accessors self
+end
+
+class DropPartitionsRequest
+  include ::Thrift::Struct, ::Thrift::Struct_Union
+  DBNAME = 1
+  TBLNAME = 2
+  PARTS = 3
+  DELETEDATA = 4
+  IFEXISTS = 5
+  IGNOREPROTECTION = 6
+  ENVIRONMENTCONTEXT = 7
+  NEEDRESULT = 8
+
+  FIELDS = {
+    DBNAME => {:type => ::Thrift::Types::STRING, :name => 'dbName'},
+    TBLNAME => {:type => ::Thrift::Types::STRING, :name => 'tblName'},
+    PARTS => {:type => ::Thrift::Types::STRUCT, :name => 'parts', :class => ::RequestPartsSpec},
+    DELETEDATA => {:type => ::Thrift::Types::BOOL, :name => 'deleteData', :optional => true},
+    IFEXISTS => {:type => ::Thrift::Types::BOOL, :name => 'ifExists', :default => true, :optional => true},
+    IGNOREPROTECTION => {:type => ::Thrift::Types::BOOL, :name => 'ignoreProtection', :optional => true},
+    ENVIRONMENTCONTEXT => {:type => ::Thrift::Types::STRUCT, :name => 'environmentContext', :class => ::EnvironmentContext, :optional => true},
+    NEEDRESULT => {:type => ::Thrift::Types::BOOL, :name => 'needResult', :default => true, :optional => true}
+  }
+
+  def struct_fields; FIELDS; end
+
+  def validate
+    raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field dbName is unset!') unless @dbName
+    raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field tblName is unset!') unless @tblName
+    raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field parts is unset!') unless @parts
+  end
+
+  ::Thrift::Struct.generate_accessors self
+end
+
 class MetaException < ::Thrift::Exception
   include ::Thrift::Struct, ::Thrift::Struct_Union
   def initialize(message=nil)

Modified: hive/branches/tez/metastore/src/gen/thrift/gen-rb/thrift_hive_metastore.rb
URL: http://svn.apache.org/viewvc/hive/branches/tez/metastore/src/gen/thrift/gen-rb/thrift_hive_metastore.rb?rev=1568236&r1=1568235&r2=1568236&view=diff
==============================================================================
--- hive/branches/tez/metastore/src/gen/thrift/gen-rb/thrift_hive_metastore.rb (original)
+++ hive/branches/tez/metastore/src/gen/thrift/gen-rb/thrift_hive_metastore.rb Fri Feb 14 10:53:31 2014
@@ -612,6 +612,23 @@ module ThriftHiveMetastore
       raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'drop_partition_by_name_with_environment_context failed: unknown result')
     end
 
+    def drop_partitions_req(req)
+      send_drop_partitions_req(req)
+      return recv_drop_partitions_req()
+    end
+
+    def send_drop_partitions_req(req)
+      send_message('drop_partitions_req', Drop_partitions_req_args, :req => req)
+    end
+
+    def recv_drop_partitions_req()
+      result = receive_message(Drop_partitions_req_result)
+      return result.success unless result.success.nil?
+      raise result.o1 unless result.o1.nil?
+      raise result.o2 unless result.o2.nil?
+      raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'drop_partitions_req failed: unknown result')
+    end
+
     def get_partition(db_name, tbl_name, part_vals)
       send_get_partition(db_name, tbl_name, part_vals)
       return recv_get_partition()
@@ -1963,6 +1980,19 @@ module ThriftHiveMetastore
       write_result(result, oprot, 'drop_partition_by_name_with_environment_context', seqid)
     end
 
+    def process_drop_partitions_req(seqid, iprot, oprot)
+      args = read_args(iprot, Drop_partitions_req_args)
+      result = Drop_partitions_req_result.new()
+      begin
+        result.success = @handler.drop_partitions_req(args.req)
+      rescue ::NoSuchObjectException => o1
+        result.o1 = o1
+      rescue ::MetaException => o2
+        result.o2 = o2
+      end
+      write_result(result, oprot, 'drop_partitions_req', seqid)
+    end
+
     def process_get_partition(seqid, iprot, oprot)
       args = read_args(iprot, Get_partition_args)
       result = Get_partition_result.new()
@@ -3997,6 +4027,42 @@ module ThriftHiveMetastore
     ::Thrift::Struct.generate_accessors self
   end
 
+  class Drop_partitions_req_args
+    include ::Thrift::Struct, ::Thrift::Struct_Union
+    REQ = 1
+
+    FIELDS = {
+      REQ => {:type => ::Thrift::Types::STRUCT, :name => 'req', :class => ::DropPartitionsRequest}
+    }
+
+    def struct_fields; FIELDS; end
+
+    def validate
+    end
+
+    ::Thrift::Struct.generate_accessors self
+  end
+
+  class Drop_partitions_req_result
+    include ::Thrift::Struct, ::Thrift::Struct_Union
+    SUCCESS = 0
+    O1 = 1
+    O2 = 2
+
+    FIELDS = {
+      SUCCESS => {:type => ::Thrift::Types::STRUCT, :name => 'success', :class => ::DropPartitionsResult},
+      O1 => {:type => ::Thrift::Types::STRUCT, :name => 'o1', :class => ::NoSuchObjectException},
+      O2 => {:type => ::Thrift::Types::STRUCT, :name => 'o2', :class => ::MetaException}
+    }
+
+    def struct_fields; FIELDS; end
+
+    def validate
+    end
+
+    ::Thrift::Struct.generate_accessors self
+  end
+
   class Get_partition_args
     include ::Thrift::Struct, ::Thrift::Struct_Union
     DB_NAME = 1

Modified: hive/branches/tez/metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java
URL: http://svn.apache.org/viewvc/hive/branches/tez/metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java?rev=1568236&r1=1568235&r2=1568236&view=diff
==============================================================================
--- hive/branches/tez/metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java (original)
+++ hive/branches/tez/metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java Fri Feb 14 10:53:31 2014
@@ -50,6 +50,7 @@ import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.hive.common.FileUtils;
 import org.apache.hadoop.hive.common.LogUtils;
 import org.apache.hadoop.hive.common.LogUtils.LogInitializationException;
 import org.apache.hadoop.hive.common.classification.InterfaceAudience;
@@ -66,6 +67,9 @@ import org.apache.hadoop.hive.metastore.
 import org.apache.hadoop.hive.metastore.api.ColumnStatisticsObj;
 import org.apache.hadoop.hive.metastore.api.ConfigValSecurityException;
 import org.apache.hadoop.hive.metastore.api.Database;
+import org.apache.hadoop.hive.metastore.api.DropPartitionsExpr;
+import org.apache.hadoop.hive.metastore.api.DropPartitionsRequest;
+import org.apache.hadoop.hive.metastore.api.DropPartitionsResult;
 import org.apache.hadoop.hive.metastore.api.EnvironmentContext;
 import org.apache.hadoop.hive.metastore.api.FieldSchema;
 import org.apache.hadoop.hive.metastore.api.HiveObjectPrivilege;
@@ -89,6 +93,7 @@ import org.apache.hadoop.hive.metastore.
 import org.apache.hadoop.hive.metastore.api.PrincipalType;
 import org.apache.hadoop.hive.metastore.api.PrivilegeBag;
 import org.apache.hadoop.hive.metastore.api.PrivilegeGrantInfo;
+import org.apache.hadoop.hive.metastore.api.RequestPartsSpec;
 import org.apache.hadoop.hive.metastore.api.Role;
 import org.apache.hadoop.hive.metastore.api.SkewedInfo;
 import org.apache.hadoop.hive.metastore.api.Table;
@@ -404,7 +409,7 @@ public class HiveMetaStore extends Thrif
       }
     }
 
-    private Configuration getConf() {
+    public Configuration getConf() {
       Configuration conf = threadLocalConf.get();
       if (conf == null) {
         conf = new Configuration(hiveConf);
@@ -441,7 +446,7 @@ public class HiveMetaStore extends Thrif
           + rawStoreClassName));
       Configuration conf = getConf();
 
-      return RetryingRawStore.getProxy(hiveConf, conf, rawStoreClassName, threadLocalId.get());
+      return RawStoreProxy.getProxy(hiveConf, conf, rawStoreClassName, threadLocalId.get());
     }
 
     private void createDefaultDB_core(RawStore ms) throws MetaException, InvalidObjectException {
@@ -1398,6 +1403,7 @@ public class HiveMetaStore extends Thrif
         tableDnsPath = wh.getDnsPath(tablePath);
       }
       List<Path> partPaths = new ArrayList<Path>();
+      Table tbl = ms.getTable(dbName, tableName);
 
       // call dropPartition on each of the table's partitions to follow the
       // procedure for cleanly dropping partitions.
@@ -1406,6 +1412,7 @@ public class HiveMetaStore extends Thrif
         if (partsToDelete == null || partsToDelete.isEmpty()) {
           break;
         }
+        List<String> partNames = new ArrayList<String>();
         for (Partition part : partsToDelete) {
           if (checkLocation && part.getSd() != null &&
               part.getSd().getLocation() != null) {
@@ -1422,8 +1429,9 @@ public class HiveMetaStore extends Thrif
               partPaths.add(partPath);
             }
           }
-          ms.dropPartition(dbName, tableName, part.getValues());
+          partNames.add(Warehouse.makePartName(tbl.getPartitionKeys(), part.getValues()));
         }
+        ms.dropPartitions(dbName, tableName, partNames);
       }
 
       return partPaths;
@@ -2150,11 +2158,7 @@ public class HiveMetaStore extends Thrif
         isArchived = MetaStoreUtils.isArchived(part);
         if (isArchived) {
           archiveParentDir = MetaStoreUtils.getOriginalLocation(part);
-          if (!wh.isWritable(archiveParentDir.getParent())) {
-            throw new MetaException("Table partition not deleted since " +
-                archiveParentDir.getParent() + " is not writable by " +
-                hiveConf.getUser());
-          }
+          verifyIsWritablePath(archiveParentDir);
         }
         if (!ms.dropPartition(db_name, tbl_name, part_vals)) {
           throw new MetaException("Unable to drop partition");
@@ -2162,11 +2166,7 @@ public class HiveMetaStore extends Thrif
         success = ms.commitTransaction();
         if ((part.getSd() != null) && (part.getSd().getLocation() != null)) {
           partPath = new Path(part.getSd().getLocation());
-          if (!wh.isWritable(partPath.getParent())) {
-            throw new MetaException("Table partition not deleted since " +
-                partPath.getParent() + " is not writable by " +
-                hiveConf.getUser());
-          }
+          verifyIsWritablePath(partPath);
         }
       } finally {
         if (!success) {
@@ -2211,6 +2211,162 @@ public class HiveMetaStore extends Thrif
           null);
     }
 
+    private static class PathAndPartValSize {
+      public PathAndPartValSize(Path path, int partValSize) {
+        this.path = path;
+        this.partValSize = partValSize;
+      }
+      public Path path;
+      public int partValSize;
+    }
+
+    @Override
+    public DropPartitionsResult drop_partitions_req(
+        DropPartitionsRequest request) throws MetaException, NoSuchObjectException, TException {
+      RawStore ms = getMS();
+      String dbName = request.getDbName(), tblName = request.getTblName();
+      boolean ifExists = request.isSetIfExists() && request.isIfExists();
+      boolean deleteData = request.isSetDeleteData() && request.isDeleteData();
+      boolean ignoreProtection = request.isSetIgnoreProtection() && request.isIgnoreProtection();
+      boolean needResult = !request.isSetNeedResult() || request.isNeedResult();
+      List<PathAndPartValSize> dirsToDelete = new ArrayList<PathAndPartValSize>();
+      List<Path> archToDelete = new ArrayList<Path>();
+      EnvironmentContext envContext = request.isSetEnvironmentContext()
+          ? request.getEnvironmentContext() : null;
+
+      boolean success = false;
+      ms.openTransaction();
+      Table tbl = null;
+      List<Partition> parts = null;
+      try {
+        // We need Partition-s for firing events and for result; DN needs MPartition-s to drop.
+        // Great... Maybe we could bypass fetching MPartitions by issuing direct SQL deletes.
+        tbl = get_table(dbName, tblName);
+        int minCount = 0;
+        RequestPartsSpec spec = request.getParts();
+        List<String> partNames = null;
+        if (spec.isSetExprs()) {
+          // Dropping by expressions.
+          parts = new ArrayList<Partition>(spec.getExprs().size());
+          for (DropPartitionsExpr expr : spec.getExprs()) {
+            ++minCount; // At least one partition per expression, if not ifExists
+            List<Partition> result = new ArrayList<Partition>();
+            boolean hasUnknown = ms.getPartitionsByExpr(
+                dbName, tblName, expr.getExpr(), null, (short)-1, result);
+            if (hasUnknown) {
+              // Expr is built by DDLSA, it should only contain part cols and simple ops
+              throw new MetaException("Unexpected unknown partitions to drop");
+            }
+            // this is to prevent dropping archived partition which is archived in a
+            // different level the drop command specified.
+            if (!ignoreProtection && expr.isSetPartArchiveLevel()) {
+              for (Partition part : parts) {
+                if (MetaStoreUtils.isArchived(part)
+                    && MetaStoreUtils.getArchivingLevel(part) < expr.getPartArchiveLevel()) {
+                  throw new MetaException("Cannot drop a subset of partitions "
+                      + " in an archive, partition " + part);
+                }
+              }
+            }
+            parts.addAll(result);
+          }
+        } else if (spec.isSetNames()) {
+          partNames = spec.getNames();
+          minCount = partNames.size();
+          parts = ms.getPartitionsByNames(dbName, tblName, partNames);
+        } else {
+          throw new MetaException("Partition spec is not set");
+        }
+
+        if ((parts.size() < minCount) && !ifExists) {
+          throw new NoSuchObjectException("Some partitions to drop are missing");
+        }
+
+        List<String> colNames = null;
+        if (partNames == null) {
+          partNames = new ArrayList<String>(parts.size());
+          colNames = new ArrayList<String>(tbl.getPartitionKeys().size());
+          for (FieldSchema col : tbl.getPartitionKeys()) {
+            colNames.add(col.getName());
+          }
+        }
+
+        for (Partition part : parts) {
+          if (!ignoreProtection && !MetaStoreUtils.canDropPartition(tbl, part)) {
+            throw new MetaException("Table " + tbl.getTableName()
+                + " Partition " + part + " is protected from being dropped");
+          }
+
+          firePreEvent(new PreDropPartitionEvent(tbl, part, deleteData, this));
+          if (colNames != null) {
+            partNames.add(FileUtils.makePartName(colNames, part.getValues()));
+          }
+          // Preserve the old behavior of failing when we cannot write, even w/o deleteData,
+          // and even if the table is external. That might not make any sense.
+          if (MetaStoreUtils.isArchived(part)) {
+            Path archiveParentDir = MetaStoreUtils.getOriginalLocation(part);
+            verifyIsWritablePath(archiveParentDir);
+            archToDelete.add(archiveParentDir);
+          }
+          if ((part.getSd() != null) && (part.getSd().getLocation() != null)) {
+            Path partPath = new Path(part.getSd().getLocation());
+            verifyIsWritablePath(partPath);
+            dirsToDelete.add(new PathAndPartValSize(partPath, part.getValues().size()));
+          }
+        }
+
+        ms.dropPartitions(dbName, tblName, partNames);
+        success = ms.commitTransaction();
+        DropPartitionsResult result = new DropPartitionsResult();
+        if (needResult) {
+          result.setPartitions(parts);
+        }
+        return result;
+      } finally {
+        if (!success) {
+          ms.rollbackTransaction();
+        } else if (deleteData && !isExternal(tbl)) {
+          // Archived partitions have har:/to_har_file as their location.
+          // The original directory was saved in params
+          for (Path path : archToDelete) {
+            wh.deleteDir(path, true);
+          }
+          for (PathAndPartValSize p : dirsToDelete) {
+            wh.deleteDir(p.path, true);
+            try {
+              deleteParentRecursive(p.path.getParent(), p.partValSize - 1);
+            } catch (IOException ex) {
+              LOG.warn("Error from deleteParentRecursive", ex);
+              throw new MetaException("Failed to delete parent: " + ex.getMessage());
+            }
+          }
+        }
+        if (parts != null) {
+          for (Partition part : parts) {
+            for (MetaStoreEventListener listener : listeners) {
+              DropPartitionEvent dropPartitionEvent =
+                new DropPartitionEvent(tbl, part, success, deleteData, this);
+              dropPartitionEvent.setEnvironmentContext(envContext);
+              listener.onDropPartition(dropPartitionEvent);
+            }
+          }
+        }
+      }
+    }
+
+    private void verifyIsWritablePath(Path dir) throws MetaException {
+      try {
+        if (!wh.isWritable(dir.getParent())) {
+          throw new MetaException("Table partition not deleted since " + dir.getParent()
+              + " is not writable by " + hiveConf.getUser());
+        }
+      } catch (IOException ex) {
+        LOG.warn("Error from isWritable", ex);
+        throw new MetaException("Table partition not deleted since " + dir.getParent()
+            + " access cannot be checked: " + ex.getMessage());
+      }
+    }
+
     @Override
     public boolean drop_partition_with_environment_context(final String db_name,
         final String tbl_name, final List<String> part_vals, final boolean deleteData,
@@ -3773,12 +3929,17 @@ public class HiveMetaStore extends Thrif
 
       List<Role> result = new ArrayList<Role>();
       try {
-        List<MRoleMap> roleMap = getMS().listRoles(principalName, principalType);
-        if (roleMap != null) {
-          for (MRoleMap role : roleMap) {
-            MRole r = role.getRole();
-            result.add(new Role(r.getRoleName(), r
-                .getCreateTime(), r.getOwnerName()));
+        List<MRoleMap> roleMaps = getMS().listRoles(principalName, principalType);
+        if (roleMaps != null) {
+          for (MRoleMap roleMap : roleMaps) {
+            MRole mrole = roleMap.getRole();
+            Role role = new Role(mrole.getRoleName(), mrole.getCreateTime(), mrole.getOwnerName());
+            role.setPrincipalName(roleMap.getPrincipalName());
+            role.setPrincipalType(roleMap.getPrincipalType());
+            role.setGrantOption(roleMap.getGrantOption());
+            role.setGrantTime(roleMap.getAddTime());
+            role.setGrantor(roleMap.getGrantor());
+            result.add(role);
           }
         }
         // all users by default belongs to public role

Modified: hive/branches/tez/metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStoreClient.java
URL: http://svn.apache.org/viewvc/hive/branches/tez/metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStoreClient.java?rev=1568236&r1=1568235&r2=1568236&view=diff
==============================================================================
--- hive/branches/tez/metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStoreClient.java (original)
+++ hive/branches/tez/metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStoreClient.java Fri Feb 14 10:53:31 2014
@@ -43,6 +43,7 @@ import javax.security.auth.login.LoginEx
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.hadoop.hive.common.ObjectPair;
 import org.apache.hadoop.hive.conf.HiveConf;
 import org.apache.hadoop.hive.conf.HiveConf.ConfVars;
 import org.apache.hadoop.hive.metastore.api.AddPartitionsRequest;
@@ -52,6 +53,9 @@ import org.apache.hadoop.hive.metastore.
 import org.apache.hadoop.hive.metastore.api.ColumnStatisticsObj;
 import org.apache.hadoop.hive.metastore.api.ConfigValSecurityException;
 import org.apache.hadoop.hive.metastore.api.Database;
+import org.apache.hadoop.hive.metastore.api.DropPartitionsExpr;
+import org.apache.hadoop.hive.metastore.api.DropPartitionsRequest;
+import org.apache.hadoop.hive.metastore.api.DropPartitionsResult;
 import org.apache.hadoop.hive.metastore.api.EnvironmentContext;
 import org.apache.hadoop.hive.metastore.api.FieldSchema;
 import org.apache.hadoop.hive.metastore.api.HiveObjectPrivilege;
@@ -71,6 +75,7 @@ import org.apache.hadoop.hive.metastore.
 import org.apache.hadoop.hive.metastore.api.PrincipalPrivilegeSet;
 import org.apache.hadoop.hive.metastore.api.PrincipalType;
 import org.apache.hadoop.hive.metastore.api.PrivilegeBag;
+import org.apache.hadoop.hive.metastore.api.RequestPartsSpec;
 import org.apache.hadoop.hive.metastore.api.Role;
 import org.apache.hadoop.hive.metastore.api.Table;
 import org.apache.hadoop.hive.metastore.api.TableStatsRequest;
@@ -634,6 +639,27 @@ public class HiveMetaStoreClient impleme
         envContext);
   }
 
+  @Override
+  public List<Partition> dropPartitions(String dbName, String tblName,
+      List<ObjectPair<Integer, byte[]>> partExprs, boolean deleteData, boolean ignoreProtection,
+      boolean ifExists) throws NoSuchObjectException, MetaException, TException {
+    RequestPartsSpec rps = new RequestPartsSpec();
+    List<DropPartitionsExpr> exprs = new ArrayList<DropPartitionsExpr>(partExprs.size());
+    for (ObjectPair<Integer, byte[]> partExpr : partExprs) {
+      DropPartitionsExpr dpe = new DropPartitionsExpr();
+      dpe.setExpr(partExpr.getSecond());
+      dpe.setPartArchiveLevel(partExpr.getFirst());
+      exprs.add(dpe);
+    }
+    rps.setExprs(exprs);
+    DropPartitionsRequest req = new DropPartitionsRequest(dbName, tblName, rps);
+    req.setDeleteData(deleteData);
+    req.setIgnoreProtection(ignoreProtection);
+    req.setNeedResult(true);
+    req.setIfExists(ifExists);
+    return client.drop_partitions_req(req).getPartitions();
+  }
+
   /**
    * @param name
    * @param dbname

Modified: hive/branches/tez/metastore/src/java/org/apache/hadoop/hive/metastore/IMetaStoreClient.java
URL: http://svn.apache.org/viewvc/hive/branches/tez/metastore/src/java/org/apache/hadoop/hive/metastore/IMetaStoreClient.java?rev=1568236&r1=1568235&r2=1568236&view=diff
==============================================================================
--- hive/branches/tez/metastore/src/java/org/apache/hadoop/hive/metastore/IMetaStoreClient.java (original)
+++ hive/branches/tez/metastore/src/java/org/apache/hadoop/hive/metastore/IMetaStoreClient.java Fri Feb 14 10:53:31 2014
@@ -20,8 +20,8 @@ package org.apache.hadoop.hive.metastore
 
 import java.util.List;
 import java.util.Map;
-import java.util.Set;
 
+import org.apache.hadoop.hive.common.ObjectPair;
 import org.apache.hadoop.hive.metastore.api.AlreadyExistsException;
 import org.apache.hadoop.hive.metastore.api.ColumnStatistics;
 import org.apache.hadoop.hive.metastore.api.ColumnStatisticsObj;
@@ -588,6 +588,10 @@ public interface IMetaStoreClient {
       List<String> part_vals, boolean deleteData) throws NoSuchObjectException,
       MetaException, TException;
 
+  List<Partition> dropPartitions(String dbName, String tblName,
+      List<ObjectPair<Integer, byte[]>> partExprs, boolean deleteData, boolean ignoreProtection,
+      boolean ifExists) throws NoSuchObjectException, MetaException, TException;
+
   public boolean dropPartition(String db_name, String tbl_name,
       String name, boolean deleteData) throws NoSuchObjectException,
       MetaException, TException;
@@ -931,6 +935,8 @@ public interface IMetaStoreClient {
       throws MetaException, TException;
 
   /**
+   * Return the privileges that the user, group have directly and indirectly through roles
+   * on the given hiveObject
    * @param hiveObject
    * @param user_name
    * @param group_names
@@ -943,6 +949,7 @@ public interface IMetaStoreClient {
       TException;
 
   /**
+   * Return the privileges that this principal has directly over the object (not through roles).
    * @param principal_name
    * @param principal_type
    * @param hiveObject

Modified: hive/branches/tez/metastore/src/java/org/apache/hadoop/hive/metastore/MetaStoreDirectSql.java
URL: http://svn.apache.org/viewvc/hive/branches/tez/metastore/src/java/org/apache/hadoop/hive/metastore/MetaStoreDirectSql.java?rev=1568236&r1=1568235&r2=1568236&view=diff
==============================================================================
--- hive/branches/tez/metastore/src/java/org/apache/hadoop/hive/metastore/MetaStoreDirectSql.java (original)
+++ hive/branches/tez/metastore/src/java/org/apache/hadoop/hive/metastore/MetaStoreDirectSql.java Fri Feb 14 10:53:31 2014
@@ -33,6 +33,7 @@ import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.TreeMap;
+import java.util.concurrent.atomic.AtomicLong;
 
 import javax.jdo.PersistenceManager;
 import javax.jdo.Query;
@@ -96,12 +97,6 @@ class MetaStoreDirectSql {
    */
   private final boolean isCompatibleDatastore;
 
-  // TODO: we might also want to work around the strange and arguably non-standard behavior
-  // of postgres where it rolls back a tx after a failed select (see SQL92 4.28, on page 69
-  // about implicit rollbacks; 4.10.1 last paragraph for the "spirit" of the standard).
-  // See #canUseDirectSql in ObjectStore, isActiveTransaction is undesirable but unavoidable
-  // for postgres; in MySQL and other databases we could avoid it.
-
   public MetaStoreDirectSql(PersistenceManager pm) {
     this.pm = pm;
     Transaction tx = pm.currentTransaction();
@@ -116,22 +111,30 @@ class MetaStoreDirectSql {
       tx = pm.currentTransaction();
       tx.begin();
     }
-    // Force the underlying db to initialize. This is for tests where tables might not
-    // exist otherwise. It would be nice if there was a "create db" command.s
-    pm.newQuery(MDatabase.class, "name == ''").execute();
-    pm.newQuery(MTableColumnStatistics.class, "dbName == ''").execute();
-    pm.newQuery(MPartitionColumnStatistics.class, "dbName == ''").execute();
-    // Self-test query. If it doesn't work, we will self-disable. What a PITA...
-    boolean isCompatibleDatastore = false;
-    String selfTestQuery = "select \"DB_ID\" from \"DBS\"";
+
+    boolean isCompatibleDatastore = true;
     try {
-      pm.newQuery("javax.jdo.query.SQL", selfTestQuery).execute();
-      isCompatibleDatastore = true;
-      tx.commit();
+      // Force the underlying db to initialize.
+      pm.newQuery(MDatabase.class, "name == ''").execute();
+      pm.newQuery(MTableColumnStatistics.class, "dbName == ''").execute();
+      pm.newQuery(MPartitionColumnStatistics.class, "dbName == ''").execute();
     } catch (Exception ex) {
-      LOG.error("Self-test query [" + selfTestQuery + "] failed; direct SQL is disabled", ex);
+      isCompatibleDatastore = false;
+      LOG.error("Database initialization failed; direct SQL is disabled", ex);
       tx.rollback();
     }
+    if (isCompatibleDatastore) {
+      // Self-test query. If it doesn't work, we will self-disable. What a PITA...
+      String selfTestQuery = "select \"DB_ID\" from \"DBS\"";
+      try {
+        pm.newQuery("javax.jdo.query.SQL", selfTestQuery).execute();
+        tx.commit();
+      } catch (Exception ex) {
+        isCompatibleDatastore = false;
+        LOG.error("Self-test query [" + selfTestQuery + "] failed; direct SQL is disabled", ex);
+        tx.rollback();
+      }
+    }
 
     this.isCompatibleDatastore = isCompatibleDatastore;
     this.isMySql = isMySql;

Modified: hive/branches/tez/metastore/src/java/org/apache/hadoop/hive/metastore/MetaStoreUtils.java
URL: http://svn.apache.org/viewvc/hive/branches/tez/metastore/src/java/org/apache/hadoop/hive/metastore/MetaStoreUtils.java?rev=1568236&r1=1568235&r2=1568236&view=diff
==============================================================================
--- hive/branches/tez/metastore/src/java/org/apache/hadoop/hive/metastore/MetaStoreUtils.java (original)
+++ hive/branches/tez/metastore/src/java/org/apache/hadoop/hive/metastore/MetaStoreUtils.java Fri Feb 14 10:53:31 2014
@@ -1424,4 +1424,43 @@ public class MetaStoreUtils {
     return null;
   }
 
+  public static ProtectMode getProtectMode(Partition partition) {
+    return getProtectMode(partition.getParameters());
+  }
+
+  public static ProtectMode getProtectMode(Table table) {
+    return getProtectMode(table.getParameters());
+  }
+
+  private static ProtectMode getProtectMode(Map<String, String> parameters) {
+    if (parameters == null) {
+      return null;
+    }
+
+    if (!parameters.containsKey(ProtectMode.PARAMETER_NAME)) {
+      return new ProtectMode();
+    } else {
+      return ProtectMode.getProtectModeFromString(parameters.get(ProtectMode.PARAMETER_NAME));
+    }
+  }
+
+  public static boolean canDropPartition(Table table, Partition partition) {
+    ProtectMode mode = getProtectMode(partition);
+    ProtectMode parentMode = getProtectMode(table);
+    return (!mode.noDrop && !mode.offline && !mode.readOnly && !parentMode.noDropCascade);
+  }
+
+  public static String ARCHIVING_LEVEL = "archiving_level";
+  public static int getArchivingLevel(Partition part) throws MetaException {
+    if (!isArchived(part)) {
+      throw new MetaException("Getting level of unarchived partition");
+    }
+
+    String lv = part.getParameters().get(ARCHIVING_LEVEL);
+    if (lv != null) {
+      return Integer.parseInt(lv);
+    } else {  // partitions archived before introducing multiple archiving
+      return part.getValues().size();
+    }
+  }
 }

Modified: hive/branches/tez/metastore/src/java/org/apache/hadoop/hive/metastore/ObjectStore.java
URL: http://svn.apache.org/viewvc/hive/branches/tez/metastore/src/java/org/apache/hadoop/hive/metastore/ObjectStore.java?rev=1568236&r1=1568235&r2=1568236&view=diff
==============================================================================
--- hive/branches/tez/metastore/src/java/org/apache/hadoop/hive/metastore/ObjectStore.java (original)
+++ hive/branches/tez/metastore/src/java/org/apache/hadoop/hive/metastore/ObjectStore.java Fri Feb 14 10:53:31 2014
@@ -39,6 +39,7 @@ import java.util.concurrent.locks.Lock;
 import java.util.concurrent.locks.ReentrantLock;
 
 import javax.jdo.JDODataStoreException;
+import javax.jdo.JDOEnhanceException;
 import javax.jdo.JDOHelper;
 import javax.jdo.JDOObjectNotFoundException;
 import javax.jdo.PersistenceManager;
@@ -56,6 +57,7 @@ import org.apache.commons.logging.LogFac
 import org.apache.hadoop.conf.Configurable;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.hive.common.FileUtils;
+import org.apache.hadoop.hive.common.ObjectPair;
 import org.apache.hadoop.hive.common.classification.InterfaceAudience;
 import org.apache.hadoop.hive.common.classification.InterfaceStability;
 import org.apache.hadoop.hive.conf.HiveConf;
@@ -362,7 +364,10 @@ public class ObjectStore implements RawS
       // currentTransaction is not active
       assert ((currentTransaction != null) && (currentTransaction.isActive()));
     }
-    return currentTransaction.isActive();
+
+    boolean result = currentTransaction.isActive();
+    debugLog("Open transaction: count = " + openTrasactionCalls + ", isActive = " + result);
+    return result;
   }
 
   /**
@@ -374,23 +379,31 @@ public class ObjectStore implements RawS
   @SuppressWarnings("nls")
   public boolean commitTransaction() {
     if (TXN_STATUS.ROLLBACK == transactionStatus) {
+      debugLog("Commit transaction: rollback");
       return false;
     }
     if (openTrasactionCalls <= 0) {
-      throw new RuntimeException("commitTransaction was called but openTransactionCalls = "
+      RuntimeException e = new RuntimeException("commitTransaction was called but openTransactionCalls = "
           + openTrasactionCalls + ". This probably indicates that there are unbalanced " +
-              "calls to openTransaction/commitTransaction");
+          "calls to openTransaction/commitTransaction");
+      LOG.error(e);
+      throw e;
     }
     if (!currentTransaction.isActive()) {
-      throw new RuntimeException(
-          "Commit is called, but transaction is not active. Either there are"
-              + " mismatching open and close calls or rollback was called in the same trasaction");
+      RuntimeException e = new RuntimeException("commitTransaction was called but openTransactionCalls = "
+          + openTrasactionCalls + ". This probably indicates that there are unbalanced " +
+          "calls to openTransaction/commitTransaction");
+      LOG.error(e);
+      throw e;
     }
     openTrasactionCalls--;
+    debugLog("Commit transaction: count = " + openTrasactionCalls + ", isactive "+ currentTransaction.isActive());
+
     if ((openTrasactionCalls == 0) && currentTransaction.isActive()) {
       transactionStatus = TXN_STATUS.COMMITED;
       currentTransaction.commit();
     }
+
     return true;
   }
 
@@ -410,9 +423,11 @@ public class ObjectStore implements RawS
    */
   public void rollbackTransaction() {
     if (openTrasactionCalls < 1) {
+      debugLog("rolling back transaction: no open transactions: " + openTrasactionCalls);
       return;
     }
     openTrasactionCalls = 0;
+    debugLog("Rollback transaction, isActive: " + currentTransaction.isActive());
     if (currentTransaction.isActive()
         && transactionStatus != TXN_STATUS.ROLLBACK) {
       transactionStatus = TXN_STATUS.ROLLBACK;
@@ -1308,7 +1323,7 @@ public class ObjectStore implements RawS
         return null;
       }
       // Change the query to use part_vals instead of the name which is
-      // redundant
+      // redundant TODO: callers of this often get part_vals out of name for no reason...
       String name = Warehouse.makePartName(convertToFieldSchemas(mtbl
           .getPartitionKeys()), part_vals);
       Query query = pm.newQuery(MPartition.class,
@@ -1407,6 +1422,33 @@ public class ObjectStore implements RawS
     return success;
   }
 
+  @Override
+  public void dropPartitions(String dbName, String tblName, List<String> partNames)
+      throws MetaException, NoSuchObjectException {
+    if (partNames.isEmpty()) return;
+    boolean success = false;
+    openTransaction();
+    try {
+      // Delete all things.
+      dropPartitionGrantsNoTxn(dbName, tblName, partNames);
+      dropPartitionAllColumnGrantsNoTxn(dbName, tblName, partNames);
+      dropPartitionColumnStatisticsNoTxn(dbName, tblName, partNames);
+
+      // CDs are reused; go thry partition SDs, detach all CDs from SDs, then remove unused CDs.
+      for (MColumnDescriptor mcd : detachCdsFromSdsNoTxn(dbName, tblName, partNames)) {
+        removeUnusedColumnDescriptor(mcd);
+      }
+      dropPartitionsNoTxn(dbName, tblName, partNames);
+      if (!(success = commitTransaction())) {
+        throw new MetaException("Failed to drop partitions"); // Should not happen?
+      }
+    } finally {
+      if (!success) {
+        rollbackTransaction();
+      }
+    }
+  }
+
   /**
    * Drop an MPartition and cascade deletes (e.g., delete partition privilege grants,
    *   drop the storage descriptor cleanly, etc.)
@@ -1433,7 +1475,7 @@ public class ObjectStore implements RawS
         List<MPartitionPrivilege> partGrants = listPartitionGrants(
             part.getTable().getDatabase().getName(),
             part.getTable().getTableName(),
-            partName);
+            Lists.newArrayList(partName));
 
         if (partGrants != null && partGrants.size() > 0) {
           pm.deletePersistentAll(partGrants);
@@ -1442,7 +1484,7 @@ public class ObjectStore implements RawS
         List<MPartitionColumnPrivilege> partColumnGrants = listPartitionAllColumnGrants(
             part.getTable().getDatabase().getName(),
             part.getTable().getTableName(),
-            partName);
+            Lists.newArrayList(partName));
         if (partColumnGrants != null && partColumnGrants.size() > 0) {
           pm.deletePersistentAll(partColumnGrants);
         }
@@ -1967,6 +2009,10 @@ public class ObjectStore implements RawS
     return results;
   }
 
+  private static class Out<T> {
+    public T val;
+  }
+
   /**
    * Gets partition names from the table via ORM (JDOQL) name filter.
    * @param dbName Database name.
@@ -1979,6 +2025,70 @@ public class ObjectStore implements RawS
     if (partNames.isEmpty()) {
       return new ArrayList<Partition>();
     }
+    Out<Query> query = new Out<Query>();
+    List<MPartition> mparts = null;
+    try {
+      mparts = getMPartitionsViaOrmFilter(dbName, tblName, partNames, query);
+      return convertToParts(dbName, tblName, mparts);
+    } finally {
+      if (query.val != null) {
+        query.val.closeAll();
+      }
+    }
+  }
+
+  private void dropPartitionsNoTxn(String dbName, String tblName, List<String> partNames) {
+    ObjectPair<Query, Map<String, String>> queryWithParams =
+        getPartQueryWithParams(dbName, tblName, partNames);
+    Query query = queryWithParams.getFirst();
+    query.setClass(MPartition.class);
+    long deleted = query.deletePersistentAll(queryWithParams.getSecond());
+    LOG.debug("Deleted " + deleted + " partition from store");
+    query.closeAll();
+  }
+
+  /**
+   * Detaches column descriptors from storage descriptors; returns the set of unique CDs
+   * thus detached. This is done before dropping partitions because CDs are reused between
+   * SDs; so, we remove the links to delete SDs and then check the returned CDs to see if
+   * they are referenced by other SDs.
+   */
+  private HashSet<MColumnDescriptor> detachCdsFromSdsNoTxn(
+      String dbName, String tblName, List<String> partNames) {
+    ObjectPair<Query, Map<String, String>> queryWithParams =
+        getPartQueryWithParams(dbName, tblName, partNames);
+    Query query = queryWithParams.getFirst();
+    query.setClass(MPartition.class);
+    query.setResult("sd");
+    @SuppressWarnings("unchecked")
+    List<MStorageDescriptor> sds = (List<MStorageDescriptor>)query.executeWithMap(
+        queryWithParams.getSecond());
+    HashSet<MColumnDescriptor> candidateCds = new HashSet<MColumnDescriptor>();
+    for (MStorageDescriptor sd : sds) {
+      if (sd != null && sd.getCD() != null) {
+        candidateCds.add(sd.getCD());
+        sd.setCD(null);
+      }
+    }
+    return candidateCds;
+  }
+
+  private List<MPartition> getMPartitionsViaOrmFilter(String dbName,
+      String tblName, List<String> partNames, Out<Query> out) {
+    ObjectPair<Query, Map<String, String>> queryWithParams =
+        getPartQueryWithParams(dbName, tblName, partNames);
+    Query query = out.val = queryWithParams.getFirst();
+    query.setResultClass(MPartition.class);
+    query.setClass(MPartition.class);
+    query.setOrdering("partitionName ascending");
+
+    @SuppressWarnings("unchecked")
+    List<MPartition> result = (List<MPartition>)query.executeWithMap(queryWithParams.getSecond());
+    return result;
+  }
+
+  private ObjectPair<Query, Map<String, String>> getPartQueryWithParams(
+      String dbName, String tblName, List<String> partNames) {
     StringBuilder sb = new StringBuilder(
         "table.tableName == t1 && table.database.name == t2 && (");
     int n = 0;
@@ -1994,24 +2104,15 @@ public class ObjectStore implements RawS
     sb.setLength(sb.length() - 4); // remove the last " || "
     sb.append(')');
 
-    Query query = pm.newQuery(MPartition.class, sb.toString());
+    Query query = pm.newQuery();
+    query.setFilter(sb.toString());
 
     LOG.debug(" JDOQL filter is " + sb.toString());
-    params.put("t1", tblName.trim());
-    params.put("t2", dbName.trim());
-
-    String parameterDeclaration = makeParameterDeclarationString(params);
-
-    query.declareParameters(parameterDeclaration);
-    query.setOrdering("partitionName ascending");
+    params.put("t1", tblName.trim().toLowerCase());
+    params.put("t2", dbName.trim().toLowerCase());
 
-    @SuppressWarnings("unchecked")
-    List<MPartition> mparts = (List<MPartition>) query.executeWithMap(params);
-    // pm.retrieveAll(mparts); // retrieveAll is pessimistic. some fields may not be needed
-    List<Partition> results = convertToParts(dbName, tblName, mparts);
-    // pm.makeTransientAll(mparts); // makeTransient will prohibit future access of unfetched fields
-    query.closeAll();
-    return results;
+    query.declareParameters(makeParameterDeclarationString(params));
+    return new ObjectPair<Query, Map<String,String>>(query, params);
   }
 
   @Override
@@ -4168,7 +4269,7 @@ public class ObjectStore implements RawS
 
   @SuppressWarnings("unchecked")
   public List<MPartitionColumnPrivilege> listPartitionAllColumnGrants(String dbName,
-      String tableName, String partName) {
+      String tableName, List<String> partNames) {
     boolean success = false;
     tableName = tableName.toLowerCase().trim();
     dbName = dbName.toLowerCase().trim();
@@ -4177,12 +4278,9 @@ public class ObjectStore implements RawS
     try {
       openTransaction();
       LOG.debug("Executing listPartitionAllColumnGrants");
-      String queryStr = "partition.table.tableName == t1 && partition.table.database.name == t2 && partition.partitionName == t3";
-      Query query = pm.newQuery(MPartitionColumnPrivilege.class, queryStr);
-      query.declareParameters(
-          "java.lang.String t1, java.lang.String t2, java.lang.String t3");
-      mSecurityColList = (List<MPartitionColumnPrivilege>) query
-          .executeWithArray(tableName, dbName, partName);
+      mSecurityColList = queryByPartitionNames(
+          dbName, tableName, partNames, MPartitionColumnPrivilege.class,
+          "partition.table.tableName", "partition.table.database.name", "partition.partitionName");
       LOG.debug("Done executing query for listPartitionAllColumnGrants");
       pm.retrieveAll(mSecurityColList);
       success = commitTransaction();
@@ -4195,6 +4293,14 @@ public class ObjectStore implements RawS
     return mSecurityColList;
   }
 
+  public void dropPartitionAllColumnGrantsNoTxn(
+      String dbName, String tableName, List<String> partNames) {
+    ObjectPair<Query, Object[]> queryWithParams = makeQueryByPartitionNames(
+          dbName, tableName, partNames, MPartitionColumnPrivilege.class,
+          "partition.table.tableName", "partition.table.database.name", "partition.partitionName");
+    queryWithParams.getFirst().deletePersistentAll(queryWithParams.getSecond());
+  }
+
   @SuppressWarnings("unchecked")
   private List<MDBPrivilege> listDatabaseGrants(String dbName) {
     dbName = dbName.toLowerCase().trim();
@@ -4222,7 +4328,7 @@ public class ObjectStore implements RawS
 
   @SuppressWarnings("unchecked")
   private List<MPartitionPrivilege> listPartitionGrants(String dbName, String tableName,
-      String partName) {
+      List<String> partNames) {
     tableName = tableName.toLowerCase().trim();
     dbName = dbName.toLowerCase().trim();
 
@@ -4231,12 +4337,9 @@ public class ObjectStore implements RawS
     try {
       openTransaction();
       LOG.debug("Executing listPartitionGrants");
-      Query query = pm.newQuery(MPartitionPrivilege.class,
-          "partition.table.tableName == t1 && partition.table.database.name == t2 && partition.partitionName == t3");
-      query.declareParameters(
-          "java.lang.String t1, java.lang.String t2, java.lang.String t3");
-      mSecurityTabPartList = (List<MPartitionPrivilege>) query
-          .executeWithArray(tableName, dbName, partName);
+      mSecurityTabPartList = queryByPartitionNames(
+          dbName, tableName, partNames, MPartitionPrivilege.class, "partition.table.tableName",
+          "partition.table.database.name", "partition.partitionName");
       LOG.debug("Done executing query for listPartitionGrants");
       pm.retrieveAll(mSecurityTabPartList);
       success = commitTransaction();
@@ -4249,6 +4352,42 @@ public class ObjectStore implements RawS
     return mSecurityTabPartList;
   }
 
+  private void dropPartitionGrantsNoTxn(String dbName, String tableName, List<String> partNames) {
+    ObjectPair<Query, Object[]> queryWithParams = makeQueryByPartitionNames(
+          dbName, tableName, partNames,MPartitionPrivilege.class, "partition.table.tableName",
+          "partition.table.database.name", "partition.partitionName");
+    queryWithParams.getFirst().deletePersistentAll(queryWithParams.getSecond());
+  }
+
+  @SuppressWarnings("unchecked")
+  private <T> List<T> queryByPartitionNames(String dbName, String tableName,
+      List<String> partNames, Class<T> clazz, String tbCol, String dbCol, String partCol) {
+    ObjectPair<Query, Object[]> queryAndParams = makeQueryByPartitionNames(
+        dbName, tableName, partNames, clazz, tbCol, dbCol, partCol);
+    return (List<T>)queryAndParams.getFirst().executeWithArray(queryAndParams.getSecond());
+  }
+
+  private ObjectPair<Query, Object[]> makeQueryByPartitionNames(
+      String dbName, String tableName, List<String> partNames, Class<?> clazz,
+      String tbCol, String dbCol, String partCol) {
+    String queryStr = tbCol + " == t1 && " + dbCol + " == t2";
+    String paramStr = "java.lang.String t1, java.lang.String t2";
+    Object[] params = new Object[2 + partNames.size()];
+    params[0] = tableName;
+    params[1] = dbName;
+    int index = 0;
+    for (String partName : partNames) {
+      params[index + 2] = partName;
+      queryStr += ((index == 0) ? " && (" : " || ") + partCol + " == p" + index;
+      paramStr += ", java.lang.String p" + index;
+      ++index;
+    }
+    queryStr += ")";
+    Query query = pm.newQuery(clazz, queryStr);
+    query.declareParameters(paramStr);
+    return new ObjectPair<Query, Object[]>(query, params);
+  }
+
   @SuppressWarnings("unchecked")
   public List<MTablePrivilege> listAllTableGrants(
       String principalName, PrincipalType principalType, String dbName,
@@ -5602,8 +5741,16 @@ public class ObjectStore implements RawS
     }
   }
 
+  private void dropPartitionColumnStatisticsNoTxn(
+      String dbName, String tableName, List<String> partNames) throws MetaException {
+    ObjectPair<Query, Object[]> queryWithParams = makeQueryByPartitionNames(
+        dbName, tableName, partNames, MPartitionColumnStatistics.class,
+        "tableName", "dbName", "partition.partitionName");
+    queryWithParams.getFirst().deletePersistentAll(queryWithParams.getSecond());
+  }
+
   public boolean deletePartitionColumnStatistics(String dbName, String tableName,
-    String partName, List<String> partVals,String colName)
+    String partName, List<String> partVals, String colName)
     throws NoSuchObjectException, MetaException, InvalidObjectException, InvalidInputException {
     boolean ret = false;
 
@@ -6151,27 +6298,24 @@ public class ObjectStore implements RawS
     }
   }
 
-  /** Add this to code to debug lexer if needed. DebugTokenStream may also be added here. */
-  private void debugLexer(CommonTokenStream stream, FilterLexer lexer) {
-    try {
-      stream.fill();
-      List<?> tokens = stream.getTokens();
-      String report = "LEXER: tokens (" + ((tokens == null) ? "null" : tokens.size()) + "): ";
-      if (tokens != null) {
-        for (Object o : tokens) {
-          if (o == null || !(o instanceof Token)) {
-            report += "[not a token: " + o + "], ";
-          } else {
-            Token t = (Token)o;
-            report += "[at " + t.getCharPositionInLine() + ": "
-                + t.getType() + " " + t.getText() + "], ";
-          }
-        }
-      }
-      report += "; lexer error: " + lexer.errorMsg;
-      LOG.error(report);
-    } catch (Throwable t) {
-      LOG.error("LEXER: tokens (error)", t);
+
+  private void debugLog(String message) {
+    if (LOG.isDebugEnabled()) {
+      LOG.debug(message + getCallStack());
+    }
+  }
+
+  private static final int stackLimit = 5;
+
+  private String getCallStack() {
+    StackTraceElement[] stackTrace = Thread.currentThread().getStackTrace();
+    int thislimit = Math.min(stackLimit, stackTrace.length);
+    StringBuilder sb = new StringBuilder();
+    sb.append(" at:");
+    for (int i = 4; i < thislimit; i++) {
+      sb.append("\n\t");
+      sb.append(stackTrace[i].toString());
     }
+    return sb.toString();
   }
 }

Modified: hive/branches/tez/metastore/src/java/org/apache/hadoop/hive/metastore/RawStore.java
URL: http://svn.apache.org/viewvc/hive/branches/tez/metastore/src/java/org/apache/hadoop/hive/metastore/RawStore.java?rev=1568236&r1=1568235&r2=1568236&view=diff
==============================================================================
--- hive/branches/tez/metastore/src/java/org/apache/hadoop/hive/metastore/RawStore.java (original)
+++ hive/branches/tez/metastore/src/java/org/apache/hadoop/hive/metastore/RawStore.java Fri Feb 14 10:53:31 2014
@@ -454,6 +454,9 @@ public interface RawStore extends Config
 
   public abstract void setMetaStoreSchemaVersion(String version, String comment) throws MetaException;
 
+  void dropPartitions(String dbName, String tblName, List<String> partNames)
+      throws MetaException, NoSuchObjectException;
+
   List<HiveObjectPrivilege> listPrincipalDBGrantsAll(
       String principalName, PrincipalType principalType);
 

Modified: hive/branches/tez/metastore/src/java/org/apache/hadoop/hive/metastore/RetryingHMSHandler.java
URL: http://svn.apache.org/viewvc/hive/branches/tez/metastore/src/java/org/apache/hadoop/hive/metastore/RetryingHMSHandler.java?rev=1568236&r1=1568235&r2=1568236&view=diff
==============================================================================
--- hive/branches/tez/metastore/src/java/org/apache/hadoop/hive/metastore/RetryingHMSHandler.java (original)
+++ hive/branches/tez/metastore/src/java/org/apache/hadoop/hive/metastore/RetryingHMSHandler.java Fri Feb 14 10:53:31 2014
@@ -45,13 +45,13 @@ public class RetryingHMSHandler implemen
     new MetaStoreInit.MetaStoreInitData();
   private final HiveConf hiveConf;
 
-  protected RetryingHMSHandler(HiveConf hiveConf, String name) throws MetaException {
+  protected RetryingHMSHandler(final HiveConf hiveConf, final String name) throws MetaException {
     this.hiveConf = hiveConf;
 
     // This has to be called before initializing the instance of HMSHandler
     init();
 
-    this.base = (IHMSHandler) new HiveMetaStore.HMSHandler(name, hiveConf);
+    this.base = new HiveMetaStore.HMSHandler(name, hiveConf);
   }
 
   public static IHMSHandler getProxy(HiveConf hiveConf, String name) throws MetaException {
@@ -75,8 +75,10 @@ public class RetryingHMSHandler implemen
     base.setConf(getConf());
   }
 
+
   @Override
-  public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
+  public Object invoke(final Object proxy, final Method method, final Object[] args) throws Throwable {
+
     Object ret = null;
 
     boolean gotNewConnectUrl = false;
@@ -144,7 +146,7 @@ public class RetryingHMSHandler implemen
       }
 
       if (retryCount >= retryLimit) {
-        LOG.error(ExceptionUtils.getStackTrace(caughtException));
+        LOG.error("HMSHandler Fatal error: " + ExceptionUtils.getStackTrace(caughtException));
         // Since returning exceptions with a nested "cause" can be a problem in
         // Thrift, we are stuffing the stack trace into the message itself.
         throw new MetaException(ExceptionUtils.getStackTrace(caughtException));
@@ -153,9 +155,10 @@ public class RetryingHMSHandler implemen
       assert (retryInterval >= 0);
       retryCount++;
       LOG.error(
-          String.format(
-              "JDO datastore error. Retrying HMSHandler " +
-                  "after %d ms (attempt %d of %d)", retryInterval, retryCount, retryLimit));
+        String.format(
+          "Retrying HMSHandler after %d ms (attempt %d of %d)", retryInterval, retryCount, retryLimit) +
+          " with error: " + ExceptionUtils.getStackTrace(caughtException));
+
       Thread.sleep(retryInterval);
       // If we have a connection error, the JDO connection URL hook might
       // provide us with a new URL to access the datastore.

Modified: hive/branches/tez/metastore/src/test/org/apache/hadoop/hive/metastore/DummyRawStoreControlledCommit.java
URL: http://svn.apache.org/viewvc/hive/branches/tez/metastore/src/test/org/apache/hadoop/hive/metastore/DummyRawStoreControlledCommit.java?rev=1568236&r1=1568235&r2=1568236&view=diff
==============================================================================
--- hive/branches/tez/metastore/src/test/org/apache/hadoop/hive/metastore/DummyRawStoreControlledCommit.java (original)
+++ hive/branches/tez/metastore/src/test/org/apache/hadoop/hive/metastore/DummyRawStoreControlledCommit.java Fri Feb 14 10:53:31 2014
@@ -656,4 +656,10 @@ public class DummyRawStoreControlledComm
       throws InvalidObjectException, MetaException {
     return objectStore.addPartitions(dbName, tblName, parts);
   }
+
+  @Override
+  public void dropPartitions(String dbName, String tblName, List<String> partNames)
+      throws MetaException, NoSuchObjectException {
+    objectStore.dropPartitions(dbName, tblName, partNames);
+  }
 }

Modified: hive/branches/tez/metastore/src/test/org/apache/hadoop/hive/metastore/DummyRawStoreForJdoConnection.java
URL: http://svn.apache.org/viewvc/hive/branches/tez/metastore/src/test/org/apache/hadoop/hive/metastore/DummyRawStoreForJdoConnection.java?rev=1568236&r1=1568235&r2=1568236&view=diff
==============================================================================
--- hive/branches/tez/metastore/src/test/org/apache/hadoop/hive/metastore/DummyRawStoreForJdoConnection.java (original)
+++ hive/branches/tez/metastore/src/test/org/apache/hadoop/hive/metastore/DummyRawStoreForJdoConnection.java Fri Feb 14 10:53:31 2014
@@ -686,6 +686,10 @@ public class DummyRawStoreForJdoConnecti
       throws InvalidObjectException, MetaException {
     return false;
   }
+
+  @Override
+  public void dropPartitions(String dbName, String tblName, List<String> partNames) {
+  }
 }
 
 

Modified: hive/branches/tez/packaging/src/main/assembly/bin.xml
URL: http://svn.apache.org/viewvc/hive/branches/tez/packaging/src/main/assembly/bin.xml?rev=1568236&r1=1568235&r2=1568236&view=diff
==============================================================================
--- hive/branches/tez/packaging/src/main/assembly/bin.xml (original)
+++ hive/branches/tez/packaging/src/main/assembly/bin.xml Fri Feb 14 10:53:31 2014
@@ -259,6 +259,7 @@
         <include>hcatcfg.py</include>
         <include>hcat.py</include>
         <include>templeton.cmd</include>
+        <include>common.sh</include>
       </includes>
       <outputDirectory>hcatalog/bin</outputDirectory>
     </fileSet>

Modified: hive/branches/tez/pom.xml
URL: http://svn.apache.org/viewvc/hive/branches/tez/pom.xml?rev=1568236&r1=1568235&r2=1568236&view=diff
==============================================================================
--- hive/branches/tez/pom.xml (original)
+++ hive/branches/tez/pom.xml Fri Feb 14 10:53:31 2014
@@ -102,8 +102,8 @@
     <hbase.hadoop1.version>0.96.0-hadoop1</hbase.hadoop1.version>
     <hbase.hadoop2.version>0.96.0-hadoop2</hbase.hadoop2.version>
     <!-- httpcomponents are not always in version sync -->
-    <httpcomponents.client.version>4.2.5</httpcomponents.client.version>
-    <httpcomponents.core.version>4.2.4</httpcomponents.core.version>
+    <httpcomponents.client.version>4.3.2</httpcomponents.client.version>
+    <httpcomponents.core.version>4.3.1</httpcomponents.core.version>
     <jackson.version>1.9.2</jackson.version>
     <javaewah.version>0.3.2</javaewah.version>
     <javolution.version>5.5.1</javolution.version>
@@ -111,6 +111,7 @@
     <!-- TODO figure out how to reconcile jetty versions -->
     <jetty.version>6.1.26</jetty.version>
     <jetty.webhcat.version>7.6.0.v20120127</jetty.webhcat.version>
+    <jetty.hive-service.version>7.6.0.v20120127</jetty.hive-service.version>
     <jersey.version>1.14</jersey.version>
     <jline.version>0.9.94</jline.version>
     <jms.version>1.1</jms.version>
@@ -127,7 +128,8 @@
         requires netty < 3.6.0 we force hadoops version
       -->
     <netty.version>3.4.0.Final</netty.version>
-    <pig.version>0.10.1</pig.version>
+    <parquet.version>1.3.2</parquet.version>
+    <pig.version>0.12.0</pig.version>
     <protobuf.version>2.5.0</protobuf.version>
     <stax.version>1.0.1</stax.version>
     <slf4j.version>1.7.5</slf4j.version>
@@ -233,6 +235,17 @@
         <version>${bonecp.version}</version>
       </dependency>
       <dependency>
+        <groupId>com.twitter</groupId>
+        <artifactId>parquet-hadoop-bundle</artifactId>
+        <version>${parquet.version}</version>
+      </dependency>
+      <dependency>
+        <groupId>com.twitter</groupId>
+        <artifactId>parquet-column</artifactId>
+        <version>${parquet.version}</version>
+        <classifier>tests</classifier>
+      </dependency>
+      <dependency>
         <groupId>com.sun.jersey</groupId>
         <artifactId>jersey-core</artifactId>
         <version>${jersey.version}</version>

Modified: hive/branches/tez/ql/pom.xml
URL: http://svn.apache.org/viewvc/hive/branches/tez/ql/pom.xml?rev=1568236&r1=1568235&r2=1568236&view=diff
==============================================================================
--- hive/branches/tez/ql/pom.xml (original)
+++ hive/branches/tez/ql/pom.xml Fri Feb 14 10:53:31 2014
@@ -67,6 +67,10 @@
       <version>${kryo.version}</version>
     </dependency>
     <dependency>
+      <groupId>com.twitter</groupId>
+      <artifactId>parquet-hadoop-bundle</artifactId>
+    </dependency>
+    <dependency>
       <groupId>commons-codec</groupId>
       <artifactId>commons-codec</artifactId>
       <version>${commons-codec.version}</version>
@@ -204,6 +208,12 @@
     <!-- test intra-project -->
     <!-- test inter-project -->
     <dependency>
+      <groupId>com.twitter</groupId>
+      <artifactId>parquet-column</artifactId>
+      <classifier>tests</classifier>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
       <groupId>junit</groupId>
       <artifactId>junit</artifactId>
       <version>${junit.version}</version>
@@ -476,6 +486,7 @@
                   <include>org.apache.hive:hive-exec</include>
                   <include>org.apache.hive:hive-serde</include>
                   <include>com.esotericsoftware.kryo:kryo</include>
+                  <include>com.twiter:parquet-hadoop-bundle</include>
                   <include>org.apache.thrift:libthrift</include>
                   <include>commons-lang:commons-lang</include>
                   <include>org.json:json</include>

Modified: hive/branches/tez/ql/src/gen/vectorization/ExpressionTemplates/ColumnArithmeticColumnDecimal.txt
URL: http://svn.apache.org/viewvc/hive/branches/tez/ql/src/gen/vectorization/ExpressionTemplates/ColumnArithmeticColumnDecimal.txt?rev=1568236&r1=1568235&r2=1568236&view=diff
==============================================================================
--- hive/branches/tez/ql/src/gen/vectorization/ExpressionTemplates/ColumnArithmeticColumnDecimal.txt (original)
+++ hive/branches/tez/ql/src/gen/vectorization/ExpressionTemplates/ColumnArithmeticColumnDecimal.txt Fri Feb 14 10:53:31 2014
@@ -42,9 +42,11 @@ public class <ClassName> extends VectorE
     this.colNum1 = colNum1;
     this.colNum2 = colNum2;
     this.outputColumn = outputColumn;
+    this.outputType = "decimal";
   }
 
   public <ClassName>() {
+    this.outputType = "decimal";
   }
 
   @Override
@@ -144,11 +146,6 @@ public class <ClassName> extends VectorE
     return outputColumn;
   }
 
-  @Override
-  public String getOutputType() {
-    return "decimal";
-  }
-
   public int getColNum1() {
     return colNum1;
   }

Modified: hive/branches/tez/ql/src/gen/vectorization/ExpressionTemplates/ColumnArithmeticScalarDecimal.txt
URL: http://svn.apache.org/viewvc/hive/branches/tez/ql/src/gen/vectorization/ExpressionTemplates/ColumnArithmeticScalarDecimal.txt?rev=1568236&r1=1568235&r2=1568236&view=diff
==============================================================================
--- hive/branches/tez/ql/src/gen/vectorization/ExpressionTemplates/ColumnArithmeticScalarDecimal.txt (original)
+++ hive/branches/tez/ql/src/gen/vectorization/ExpressionTemplates/ColumnArithmeticScalarDecimal.txt Fri Feb 14 10:53:31 2014
@@ -42,9 +42,11 @@ public class <ClassName> extends VectorE
     this.colNum = colNum;
     this.value = value;
     this.outputColumn = outputColumn;
+    this.outputType = "decimal";
   }
 
   public <ClassName>() {
+    this.outputType = "decimal";
   }
 
   @Override
@@ -128,11 +130,6 @@ public class <ClassName> extends VectorE
     return outputColumn;
   }
   
-  @Override
-  public String getOutputType() {
-    return "decimal";
-  }
-  
   public int getColNum() {
     return colNum;
   }

Modified: hive/branches/tez/ql/src/gen/vectorization/ExpressionTemplates/ColumnDivideColumnDecimal.txt
URL: http://svn.apache.org/viewvc/hive/branches/tez/ql/src/gen/vectorization/ExpressionTemplates/ColumnDivideColumnDecimal.txt?rev=1568236&r1=1568235&r2=1568236&view=diff
==============================================================================
--- hive/branches/tez/ql/src/gen/vectorization/ExpressionTemplates/ColumnDivideColumnDecimal.txt (original)
+++ hive/branches/tez/ql/src/gen/vectorization/ExpressionTemplates/ColumnDivideColumnDecimal.txt Fri Feb 14 10:53:31 2014
@@ -42,9 +42,11 @@ public class <ClassName> extends VectorE
     this.colNum1 = colNum1;
     this.colNum2 = colNum2;
     this.outputColumn = outputColumn;
+    this.outputType = "decimal";
   }
 
   public <ClassName>() {
+    this.outputType = "decimal";
   }
 
   @Override
@@ -136,11 +138,6 @@ public class <ClassName> extends VectorE
     return outputColumn;
   }
 
-  @Override
-  public String getOutputType() {
-    return "decimal";
-  }
-
   public int getColNum1() {
     return colNum1;
   }

Modified: hive/branches/tez/ql/src/gen/vectorization/ExpressionTemplates/ColumnDivideScalarDecimal.txt
URL: http://svn.apache.org/viewvc/hive/branches/tez/ql/src/gen/vectorization/ExpressionTemplates/ColumnDivideScalarDecimal.txt?rev=1568236&r1=1568235&r2=1568236&view=diff
==============================================================================
--- hive/branches/tez/ql/src/gen/vectorization/ExpressionTemplates/ColumnDivideScalarDecimal.txt (original)
+++ hive/branches/tez/ql/src/gen/vectorization/ExpressionTemplates/ColumnDivideScalarDecimal.txt Fri Feb 14 10:53:31 2014
@@ -43,9 +43,11 @@ public class <ClassName> extends VectorE
     this.colNum = colNum;
     this.value = value;
     this.outputColumn = outputColumn;
+    this.outputType = "decimal";
   }
 
   public <ClassName>() {
+    this.outputType = "decimal";
   }
 
   @Override
@@ -140,11 +142,6 @@ public class <ClassName> extends VectorE
     return outputColumn;
   }
 
-  @Override
-  public String getOutputType() {
-    return "decimal";
-  }
-
   public int getColNum() {
     return colNum;
   }

Modified: hive/branches/tez/ql/src/gen/vectorization/ExpressionTemplates/ScalarArithmeticColumnDecimal.txt
URL: http://svn.apache.org/viewvc/hive/branches/tez/ql/src/gen/vectorization/ExpressionTemplates/ScalarArithmeticColumnDecimal.txt?rev=1568236&r1=1568235&r2=1568236&view=diff
==============================================================================
--- hive/branches/tez/ql/src/gen/vectorization/ExpressionTemplates/ScalarArithmeticColumnDecimal.txt (original)
+++ hive/branches/tez/ql/src/gen/vectorization/ExpressionTemplates/ScalarArithmeticColumnDecimal.txt Fri Feb 14 10:53:31 2014
@@ -42,9 +42,11 @@ public class <ClassName> extends VectorE
     this.colNum = colNum;
     this.value = value;
     this.outputColumn = outputColumn;
+    this.outputType = "decimal";
   }
 
   public <ClassName>() {
+    this.outputType = "decimal";
   }
 
   @Override
@@ -125,11 +127,6 @@ public class <ClassName> extends VectorE
     return outputColumn;
   }
   
-  @Override
-  public String getOutputType() {
-    return "decimal";
-  }
-  
   public int getColNum() {
     return colNum;
   }

Modified: hive/branches/tez/ql/src/gen/vectorization/ExpressionTemplates/ScalarDivideColumnDecimal.txt
URL: http://svn.apache.org/viewvc/hive/branches/tez/ql/src/gen/vectorization/ExpressionTemplates/ScalarDivideColumnDecimal.txt?rev=1568236&r1=1568235&r2=1568236&view=diff
==============================================================================
--- hive/branches/tez/ql/src/gen/vectorization/ExpressionTemplates/ScalarDivideColumnDecimal.txt (original)
+++ hive/branches/tez/ql/src/gen/vectorization/ExpressionTemplates/ScalarDivideColumnDecimal.txt Fri Feb 14 10:53:31 2014
@@ -42,9 +42,11 @@ public class <ClassName> extends VectorE
     this.colNum = colNum;
     this.value = value;
     this.outputColumn = outputColumn;
+    this.outputType = "decimal";
   }
 
   public <ClassName>() {
+    this.outputType = "decimal";
   }
 
   @Override
@@ -127,11 +129,6 @@ public class <ClassName> extends VectorE
     return outputColumn;
   }
 
-  @Override
-  public String getOutputType() {
-    return "decimal";
-  }
-
   public int getColNum() {
     return colNum;
   }

Modified: hive/branches/tez/ql/src/java/org/apache/hadoop/hive/ql/Context.java
URL: http://svn.apache.org/viewvc/hive/branches/tez/ql/src/java/org/apache/hadoop/hive/ql/Context.java?rev=1568236&r1=1568235&r2=1568236&view=diff
==============================================================================
--- hive/branches/tez/ql/src/java/org/apache/hadoop/hive/ql/Context.java (original)
+++ hive/branches/tez/ql/src/java/org/apache/hadoop/hive/ql/Context.java Fri Feb 14 10:53:31 2014
@@ -49,7 +49,6 @@ import org.apache.hadoop.hive.ql.lockmgr
 import org.apache.hadoop.hive.ql.plan.LoadTableDesc;
 import org.apache.hadoop.hive.shims.ShimLoader;
 import org.apache.hadoop.util.StringUtils;
-import org.apache.velocity.runtime.parser.node.GetExecutor;
 
 /**
  * Context for Semantic Analyzers. Usage: not reusable - construct a new one for