diff --git metastore/if/hive_metastore.thrift metastore/if/hive_metastore.thrift index 7ec0ebe..d0b38f6 100755 --- metastore/if/hive_metastore.thrift +++ metastore/if/hive_metastore.thrift @@ -120,7 +120,8 @@ struct Database { 2: string description, 3: string locationUri, 4: map parameters, // properties associated with the database - 5: optional PrincipalPrivilegeSet privileges + 5: optional PrincipalPrivilegeSet privileges, + 6: optional string owner, } // This object holds the information needed by SerDes diff --git metastore/scripts/upgrade/derby/016-HIVE-6386.derby.sql metastore/scripts/upgrade/derby/016-HIVE-6386.derby.sql new file mode 100644 index 0000000..8577a66 --- /dev/null +++ metastore/scripts/upgrade/derby/016-HIVE-6386.derby.sql @@ -0,0 +1 @@ +ALTER TABLE "DBS" ADD "OWNER" CHAR(128); diff --git metastore/scripts/upgrade/mysql/016-HIVE-6386.mysql.sql metastore/scripts/upgrade/mysql/016-HIVE-6386.mysql.sql new file mode 100644 index 0000000..a5cf8a9 --- /dev/null +++ metastore/scripts/upgrade/mysql/016-HIVE-6386.mysql.sql @@ -0,0 +1,3 @@ +SELECT '< HIVE-6386: Add owner filed to database >' AS ' '; + +ALTER TABLE `DBS` ADD `OWNER` varchar(128); diff --git metastore/scripts/upgrade/oracle/016-HIVE-6386.oracle.sql metastore/scripts/upgrade/oracle/016-HIVE-6386.oracle.sql new file mode 100644 index 0000000..4584891 --- /dev/null +++ metastore/scripts/upgrade/oracle/016-HIVE-6386.oracle.sql @@ -0,0 +1 @@ +ALTER TABLE DBS ADD OWNER VARCHAR2(128); diff --git metastore/scripts/upgrade/postgres/016-HIVE-6386.postgres.sql metastore/scripts/upgrade/postgres/016-HIVE-6386.postgres.sql new file mode 100644 index 0000000..7105b9f --- /dev/null +++ metastore/scripts/upgrade/postgres/016-HIVE-6386.postgres.sql @@ -0,0 +1,3 @@ +SELECT '< HIVE-6386 Database should have an owner >'; + +ALTER TABLE "DBS" ADD COLUMN "OWNER" character varying(128); diff --git metastore/src/gen/thrift/gen-cpp/hive_metastore_types.cpp metastore/src/gen/thrift/gen-cpp/hive_metastore_types.cpp index 8c9a98d..6d6b073 100644 --- metastore/src/gen/thrift/gen-cpp/hive_metastore_types.cpp +++ metastore/src/gen/thrift/gen-cpp/hive_metastore_types.cpp @@ -1148,8 +1148,8 @@ void swap(Role &a, Role &b) { swap(a.__isset, b.__isset); } -const char* Database::ascii_fingerprint = "213967572143E49C9F1A23F7A866E2F5"; -const uint8_t Database::binary_fingerprint[16] = {0x21,0x39,0x67,0x57,0x21,0x43,0xE4,0x9C,0x9F,0x1A,0x23,0xF7,0xA8,0x66,0xE2,0xF5}; +const char* Database::ascii_fingerprint = "DD47DEA7DE04F8C7193D3208B63884B9"; +const uint8_t Database::binary_fingerprint[16] = {0xDD,0x47,0xDE,0xA7,0xDE,0x04,0xF8,0xC7,0x19,0x3D,0x32,0x08,0xB6,0x38,0x84,0xB9}; uint32_t Database::read(::apache::thrift::protocol::TProtocol* iprot) { @@ -1226,6 +1226,14 @@ uint32_t Database::read(::apache::thrift::protocol::TProtocol* iprot) { xfer += iprot->skip(ftype); } break; + case 6: + if (ftype == ::apache::thrift::protocol::T_STRING) { + xfer += iprot->readString(this->owner); + this->__isset.owner = true; + } else { + xfer += iprot->skip(ftype); + } + break; default: xfer += iprot->skip(ftype); break; @@ -1272,6 +1280,11 @@ uint32_t Database::write(::apache::thrift::protocol::TProtocol* oprot) const { xfer += this->privileges.write(oprot); xfer += oprot->writeFieldEnd(); } + if (this->__isset.owner) { + xfer += oprot->writeFieldBegin("owner", ::apache::thrift::protocol::T_STRING, 6); + xfer += oprot->writeString(this->owner); + xfer += oprot->writeFieldEnd(); + } xfer += oprot->writeFieldStop(); xfer += oprot->writeStructEnd(); return xfer; @@ -1284,6 +1297,7 @@ void swap(Database &a, Database &b) { swap(a.locationUri, b.locationUri); swap(a.parameters, b.parameters); swap(a.privileges, b.privileges); + swap(a.owner, b.owner); swap(a.__isset, b.__isset); } diff --git metastore/src/gen/thrift/gen-cpp/hive_metastore_types.h metastore/src/gen/thrift/gen-cpp/hive_metastore_types.h index a10cac8..2e46041 100644 --- metastore/src/gen/thrift/gen-cpp/hive_metastore_types.h +++ metastore/src/gen/thrift/gen-cpp/hive_metastore_types.h @@ -667,21 +667,22 @@ class Role { void swap(Role &a, Role &b); typedef struct _Database__isset { - _Database__isset() : name(false), description(false), locationUri(false), parameters(false), privileges(false) {} + _Database__isset() : name(false), description(false), locationUri(false), parameters(false), privileges(false), owner(false) {} bool name; bool description; bool locationUri; bool parameters; bool privileges; + bool owner; } _Database__isset; class Database { public: - static const char* ascii_fingerprint; // = "213967572143E49C9F1A23F7A866E2F5"; - static const uint8_t binary_fingerprint[16]; // = {0x21,0x39,0x67,0x57,0x21,0x43,0xE4,0x9C,0x9F,0x1A,0x23,0xF7,0xA8,0x66,0xE2,0xF5}; + static const char* ascii_fingerprint; // = "DD47DEA7DE04F8C7193D3208B63884B9"; + static const uint8_t binary_fingerprint[16]; // = {0xDD,0x47,0xDE,0xA7,0xDE,0x04,0xF8,0xC7,0x19,0x3D,0x32,0x08,0xB6,0x38,0x84,0xB9}; - Database() : name(), description(), locationUri() { + Database() : name(), description(), locationUri(), owner() { } virtual ~Database() throw() {} @@ -691,6 +692,7 @@ class Database { std::string locationUri; std::map parameters; PrincipalPrivilegeSet privileges; + std::string owner; _Database__isset __isset; @@ -715,6 +717,11 @@ class Database { __isset.privileges = true; } + void __set_owner(const std::string& val) { + owner = val; + __isset.owner = true; + } + bool operator == (const Database & rhs) const { if (!(name == rhs.name)) @@ -729,6 +736,10 @@ class Database { return false; else if (__isset.privileges && !(privileges == rhs.privileges)) return false; + if (__isset.owner != rhs.__isset.owner) + return false; + else if (__isset.owner && !(owner == rhs.owner)) + return false; return true; } bool operator != (const Database &rhs) const { diff --git metastore/src/gen/thrift/gen-javabean/org/apache/hadoop/hive/metastore/api/Database.java metastore/src/gen/thrift/gen-javabean/org/apache/hadoop/hive/metastore/api/Database.java index 8fd2024..f0d8f04 100644 --- metastore/src/gen/thrift/gen-javabean/org/apache/hadoop/hive/metastore/api/Database.java +++ metastore/src/gen/thrift/gen-javabean/org/apache/hadoop/hive/metastore/api/Database.java @@ -39,6 +39,7 @@ private static final org.apache.thrift.protocol.TField LOCATION_URI_FIELD_DESC = new org.apache.thrift.protocol.TField("locationUri", org.apache.thrift.protocol.TType.STRING, (short)3); private static final org.apache.thrift.protocol.TField PARAMETERS_FIELD_DESC = new org.apache.thrift.protocol.TField("parameters", org.apache.thrift.protocol.TType.MAP, (short)4); private static final org.apache.thrift.protocol.TField PRIVILEGES_FIELD_DESC = new org.apache.thrift.protocol.TField("privileges", org.apache.thrift.protocol.TType.STRUCT, (short)5); + private static final org.apache.thrift.protocol.TField OWNER_FIELD_DESC = new org.apache.thrift.protocol.TField("owner", org.apache.thrift.protocol.TType.STRING, (short)6); private static final Map, SchemeFactory> schemes = new HashMap, SchemeFactory>(); static { @@ -51,6 +52,7 @@ private String locationUri; // required private Map parameters; // required private PrincipalPrivilegeSet privileges; // optional + private String owner; // optional /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ public enum _Fields implements org.apache.thrift.TFieldIdEnum { @@ -58,7 +60,8 @@ DESCRIPTION((short)2, "description"), LOCATION_URI((short)3, "locationUri"), PARAMETERS((short)4, "parameters"), - PRIVILEGES((short)5, "privileges"); + PRIVILEGES((short)5, "privileges"), + OWNER((short)6, "owner"); private static final Map byName = new HashMap(); @@ -83,6 +86,8 @@ public static _Fields findByThriftId(int fieldId) { return PARAMETERS; case 5: // PRIVILEGES return PRIVILEGES; + case 6: // OWNER + return OWNER; default: return null; } @@ -123,7 +128,7 @@ public String getFieldName() { } // isset id assignments - private _Fields optionals[] = {_Fields.PRIVILEGES}; + private _Fields optionals[] = {_Fields.PRIVILEGES,_Fields.OWNER}; public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; static { Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); @@ -139,6 +144,8 @@ public String getFieldName() { new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)))); tmpMap.put(_Fields.PRIVILEGES, new org.apache.thrift.meta_data.FieldMetaData("privileges", org.apache.thrift.TFieldRequirementType.OPTIONAL, new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, PrincipalPrivilegeSet.class))); + tmpMap.put(_Fields.OWNER, new org.apache.thrift.meta_data.FieldMetaData("owner", org.apache.thrift.TFieldRequirementType.OPTIONAL, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); metaDataMap = Collections.unmodifiableMap(tmpMap); org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(Database.class, metaDataMap); } @@ -190,6 +197,9 @@ public Database(Database other) { if (other.isSetPrivileges()) { this.privileges = new PrincipalPrivilegeSet(other.privileges); } + if (other.isSetOwner()) { + this.owner = other.owner; + } } public Database deepCopy() { @@ -203,6 +213,7 @@ public void clear() { this.locationUri = null; this.parameters = null; this.privileges = null; + this.owner = null; } public String getName() { @@ -331,6 +342,29 @@ public void setPrivilegesIsSet(boolean value) { } } + public String getOwner() { + return this.owner; + } + + public void setOwner(String owner) { + this.owner = owner; + } + + public void unsetOwner() { + this.owner = null; + } + + /** Returns true if field owner is set (has been assigned a value) and false otherwise */ + public boolean isSetOwner() { + return this.owner != null; + } + + public void setOwnerIsSet(boolean value) { + if (!value) { + this.owner = null; + } + } + public void setFieldValue(_Fields field, Object value) { switch (field) { case NAME: @@ -373,6 +407,14 @@ public void setFieldValue(_Fields field, Object value) { } break; + case OWNER: + if (value == null) { + unsetOwner(); + } else { + setOwner((String)value); + } + break; + } } @@ -393,6 +435,9 @@ public Object getFieldValue(_Fields field) { case PRIVILEGES: return getPrivileges(); + case OWNER: + return getOwner(); + } throw new IllegalStateException(); } @@ -414,6 +459,8 @@ public boolean isSet(_Fields field) { return isSetParameters(); case PRIVILEGES: return isSetPrivileges(); + case OWNER: + return isSetOwner(); } throw new IllegalStateException(); } @@ -476,6 +523,15 @@ public boolean equals(Database that) { return false; } + boolean this_present_owner = true && this.isSetOwner(); + boolean that_present_owner = true && that.isSetOwner(); + if (this_present_owner || that_present_owner) { + if (!(this_present_owner && that_present_owner)) + return false; + if (!this.owner.equals(that.owner)) + return false; + } + return true; } @@ -508,6 +564,11 @@ public int hashCode() { if (present_privileges) builder.append(privileges); + boolean present_owner = true && (isSetOwner()); + builder.append(present_owner); + if (present_owner) + builder.append(owner); + return builder.toHashCode(); } @@ -569,6 +630,16 @@ public int compareTo(Database other) { return lastComparison; } } + lastComparison = Boolean.valueOf(isSetOwner()).compareTo(typedOther.isSetOwner()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetOwner()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.owner, typedOther.owner); + if (lastComparison != 0) { + return lastComparison; + } + } return 0; } @@ -630,6 +701,16 @@ public String toString() { } first = false; } + if (isSetOwner()) { + if (!first) sb.append(", "); + sb.append("owner:"); + if (this.owner == null) { + sb.append("null"); + } else { + sb.append(this.owner); + } + first = false; + } sb.append(")"); return sb.toString(); } @@ -729,6 +810,14 @@ public void read(org.apache.thrift.protocol.TProtocol iprot, Database struct) th org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; + case 6: // OWNER + if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { + struct.owner = iprot.readString(); + struct.setOwnerIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; default: org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } @@ -777,6 +866,13 @@ public void write(org.apache.thrift.protocol.TProtocol oprot, Database struct) t oprot.writeFieldEnd(); } } + if (struct.owner != null) { + if (struct.isSetOwner()) { + oprot.writeFieldBegin(OWNER_FIELD_DESC); + oprot.writeString(struct.owner); + oprot.writeFieldEnd(); + } + } oprot.writeFieldStop(); oprot.writeStructEnd(); } @@ -810,7 +906,10 @@ public void write(org.apache.thrift.protocol.TProtocol prot, Database struct) th if (struct.isSetPrivileges()) { optionals.set(4); } - oprot.writeBitSet(optionals, 5); + if (struct.isSetOwner()) { + optionals.set(5); + } + oprot.writeBitSet(optionals, 6); if (struct.isSetName()) { oprot.writeString(struct.name); } @@ -833,12 +932,15 @@ public void write(org.apache.thrift.protocol.TProtocol prot, Database struct) th if (struct.isSetPrivileges()) { struct.privileges.write(oprot); } + if (struct.isSetOwner()) { + oprot.writeString(struct.owner); + } } @Override public void read(org.apache.thrift.protocol.TProtocol prot, Database struct) throws org.apache.thrift.TException { TTupleProtocol iprot = (TTupleProtocol) prot; - BitSet incoming = iprot.readBitSet(5); + BitSet incoming = iprot.readBitSet(6); if (incoming.get(0)) { struct.name = iprot.readString(); struct.setNameIsSet(true); @@ -871,6 +973,10 @@ public void read(org.apache.thrift.protocol.TProtocol prot, Database struct) thr struct.privileges.read(iprot); struct.setPrivilegesIsSet(true); } + if (incoming.get(5)) { + struct.owner = iprot.readString(); + struct.setOwnerIsSet(true); + } } } diff --git metastore/src/gen/thrift/gen-php/metastore/Types.php metastore/src/gen/thrift/gen-php/metastore/Types.php index 4f486d9..f218347 100644 --- metastore/src/gen/thrift/gen-php/metastore/Types.php +++ metastore/src/gen/thrift/gen-php/metastore/Types.php @@ -1494,6 +1494,7 @@ class Database { public $locationUri = null; public $parameters = null; public $privileges = null; + public $owner = null; public function __construct($vals=null) { if (!isset(self::$_TSPEC)) { @@ -1527,6 +1528,10 @@ class Database { 'type' => TType::STRUCT, 'class' => '\metastore\PrincipalPrivilegeSet', ), + 6 => array( + 'var' => 'owner', + 'type' => TType::STRING, + ), ); } if (is_array($vals)) { @@ -1545,6 +1550,9 @@ class Database { if (isset($vals['privileges'])) { $this->privileges = $vals['privileges']; } + if (isset($vals['owner'])) { + $this->owner = $vals['owner']; + } } } @@ -1616,6 +1624,13 @@ class Database { $xfer += $input->skip($ftype); } break; + case 6: + if ($ftype == TType::STRING) { + $xfer += $input->readString($this->owner); + } else { + $xfer += $input->skip($ftype); + } + break; default: $xfer += $input->skip($ftype); break; @@ -1670,6 +1685,11 @@ class Database { $xfer += $this->privileges->write($output); $xfer += $output->writeFieldEnd(); } + if ($this->owner !== null) { + $xfer += $output->writeFieldBegin('owner', TType::STRING, 6); + $xfer += $output->writeString($this->owner); + $xfer += $output->writeFieldEnd(); + } $xfer += $output->writeFieldStop(); $xfer += $output->writeStructEnd(); return $xfer; diff --git metastore/src/gen/thrift/gen-py/hive_metastore/ttypes.py metastore/src/gen/thrift/gen-py/hive_metastore/ttypes.py index bf6c2b0..1473ef1 100644 --- metastore/src/gen/thrift/gen-py/hive_metastore/ttypes.py +++ metastore/src/gen/thrift/gen-py/hive_metastore/ttypes.py @@ -1015,6 +1015,7 @@ class Database: - locationUri - parameters - privileges + - owner """ thrift_spec = ( @@ -1024,14 +1025,16 @@ class Database: (3, TType.STRING, 'locationUri', None, None, ), # 3 (4, TType.MAP, 'parameters', (TType.STRING,None,TType.STRING,None), None, ), # 4 (5, TType.STRUCT, 'privileges', (PrincipalPrivilegeSet, PrincipalPrivilegeSet.thrift_spec), None, ), # 5 + (6, TType.STRING, 'owner', None, None, ), # 6 ) - def __init__(self, name=None, description=None, locationUri=None, parameters=None, privileges=None,): + def __init__(self, name=None, description=None, locationUri=None, parameters=None, privileges=None, owner=None,): self.name = name self.description = description self.locationUri = locationUri self.parameters = parameters self.privileges = privileges + self.owner = owner 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: @@ -1074,6 +1077,11 @@ def read(self, iprot): self.privileges.read(iprot) else: iprot.skip(ftype) + elif fid == 6: + if ftype == TType.STRING: + self.owner = iprot.readString(); + else: + iprot.skip(ftype) else: iprot.skip(ftype) iprot.readFieldEnd() @@ -1108,6 +1116,10 @@ def write(self, oprot): oprot.writeFieldBegin('privileges', TType.STRUCT, 5) self.privileges.write(oprot) oprot.writeFieldEnd() + if self.owner is not None: + oprot.writeFieldBegin('owner', TType.STRING, 6) + oprot.writeString(self.owner) + oprot.writeFieldEnd() oprot.writeFieldStop() oprot.writeStructEnd() diff --git metastore/src/gen/thrift/gen-rb/hive_metastore_types.rb metastore/src/gen/thrift/gen-rb/hive_metastore_types.rb index 403f423..8f77647 100644 --- metastore/src/gen/thrift/gen-rb/hive_metastore_types.rb +++ metastore/src/gen/thrift/gen-rb/hive_metastore_types.rb @@ -244,13 +244,15 @@ class Database LOCATIONURI = 3 PARAMETERS = 4 PRIVILEGES = 5 + OWNER = 6 FIELDS = { NAME => {:type => ::Thrift::Types::STRING, :name => 'name'}, DESCRIPTION => {:type => ::Thrift::Types::STRING, :name => 'description'}, LOCATIONURI => {:type => ::Thrift::Types::STRING, :name => 'locationUri'}, PARAMETERS => {:type => ::Thrift::Types::MAP, :name => 'parameters', :key => {:type => ::Thrift::Types::STRING}, :value => {:type => ::Thrift::Types::STRING}}, - PRIVILEGES => {:type => ::Thrift::Types::STRUCT, :name => 'privileges', :class => ::PrincipalPrivilegeSet, :optional => true} + PRIVILEGES => {:type => ::Thrift::Types::STRUCT, :name => 'privileges', :class => ::PrincipalPrivilegeSet, :optional => true}, + OWNER => {:type => ::Thrift::Types::STRING, :name => 'owner', :optional => true} } def struct_fields; FIELDS; end diff --git metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java index 622124f..6623cd0 100644 --- metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java +++ metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java @@ -453,9 +453,10 @@ private void createDefaultDB_core(RawStore ms) throws MetaException, InvalidObje try { ms.getDatabase(DEFAULT_DATABASE_NAME); } catch (NoSuchObjectException e) { - ms.createDatabase( - new Database(DEFAULT_DATABASE_NAME, DEFAULT_DATABASE_COMMENT, - wh.getDefaultDatabasePath(DEFAULT_DATABASE_NAME).toString(), null)); + Database db = new Database(DEFAULT_DATABASE_NAME, DEFAULT_DATABASE_COMMENT, + wh.getDefaultDatabasePath(DEFAULT_DATABASE_NAME).toString(), null); + db.setOwner(HiveMetaStore.PUBLIC); + ms.createDatabase(db); } HMSHandler.createDefaultDB = true; } diff --git metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStoreClient.java metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStoreClient.java index 6dce0aa..2803f16 100644 --- metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStoreClient.java +++ metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStoreClient.java @@ -196,6 +196,7 @@ private void promoteRandomMetaStoreURI() { metastoreUris[index] = tmp; } + @Override public void reconnect() throws MetaException { if (localMetaStore) { // For direct DB connections we don't yet support reestablishing connections. @@ -222,6 +223,7 @@ public void reconnect() throws MetaException { * java.lang.String, java.lang.String, * org.apache.hadoop.hive.metastore.api.Table) */ + @Override public void alter_table(String dbname, String tbl_name, Table new_tbl) throws InvalidOperationException, MetaException, TException { alter_table(dbname, tbl_name, new_tbl, null); @@ -243,6 +245,7 @@ public void alter_table(String dbname, String tbl_name, Table new_tbl, * @see org.apache.hadoop.hive.metastore.api.ThriftHiveMetastore.Iface#rename_partition( * java.lang.String, java.lang.String, java.util.List, org.apache.hadoop.hive.metastore.api.Partition) */ + @Override public void renamePartition(final String dbname, final String name, final List part_vals, final Partition newPart) throws InvalidOperationException, MetaException, TException { client.rename_partition(dbname, name, part_vals, newPart); @@ -353,6 +356,7 @@ public String getTokenStrForm() throws IOException { return tokenStrForm; } + @Override public void close() { isConnected = false; try { @@ -378,6 +382,7 @@ public void close() { * @throws TException * @see org.apache.hadoop.hive.metastore.api.ThriftHiveMetastore.Iface#add_partition(org.apache.hadoop.hive.metastore.api.Partition) */ + @Override public Partition add_partition(Partition new_part) throws InvalidObjectException, AlreadyExistsException, MetaException, TException { @@ -398,6 +403,7 @@ public Partition add_partition(Partition new_part, EnvironmentContext envContext * @throws TException * @see org.apache.hadoop.hive.metastore.api.ThriftHiveMetastore.Iface#add_partitions(List) */ + @Override public int add_partitions(List new_parts) throws InvalidObjectException, AlreadyExistsException, MetaException, TException { @@ -431,6 +437,7 @@ public int add_partitions(List new_parts) * @see org.apache.hadoop.hive.metastore.api.ThriftHiveMetastore.Iface#append_partition(java.lang.String, * java.lang.String, java.util.List) */ + @Override public Partition appendPartition(String db_name, String table_name, List part_vals) throws InvalidObjectException, AlreadyExistsException, MetaException, TException { @@ -444,6 +451,7 @@ public Partition appendPartition(String db_name, String table_name, List part_vals, envContext)); } + @Override public Partition appendPartition(String dbName, String tableName, String partName) throws InvalidObjectException, AlreadyExistsException, MetaException, TException { return appendPartition(dbName, tableName, partName, null); @@ -472,6 +480,7 @@ public Partition exchange_partition(Map partitionSpecs, destDb, destinationTableName); } + @Override public void validatePartitionNameCharacters(List partVals) throws TException, MetaException { client.partition_name_has_valid_characters(partVals, true); @@ -486,8 +495,15 @@ public void validatePartitionNameCharacters(List partVals) * @throws TException * @see org.apache.hadoop.hive.metastore.api.ThriftHiveMetastore.Iface#create_database(Database) */ + @Override public void createDatabase(Database db) throws AlreadyExistsException, InvalidObjectException, MetaException, TException { + try { + db.setOwner(conf.getUser()); + } catch (IOException e) { + LOG.debug(e); + throw new MetaException(e.getMessage()); + } client.create_database(db); } @@ -498,6 +514,7 @@ public void createDatabase(Database db) * @throws TException * @see org.apache.hadoop.hive.metastore.api.ThriftHiveMetastore.Iface#create_table(org.apache.hadoop.hive.metastore.api.Table) */ + @Override public void createTable(Table tbl) throws AlreadyExistsException, InvalidObjectException, MetaException, NoSuchObjectException, TException { createTable(tbl, null); @@ -545,16 +562,19 @@ public boolean createType(Type type) throws AlreadyExistsException, * @throws TException * @see org.apache.hadoop.hive.metastore.api.ThriftHiveMetastore.Iface#drop_database(java.lang.String, boolean, boolean) */ + @Override public void dropDatabase(String name) throws NoSuchObjectException, InvalidOperationException, MetaException, TException { dropDatabase(name, true, false, false); } + @Override public void dropDatabase(String name, boolean deleteData, boolean ignoreUnknownDb) throws NoSuchObjectException, InvalidOperationException, MetaException, TException { dropDatabase(name, deleteData, ignoreUnknownDb, false); } + @Override public void dropDatabase(String name, boolean deleteData, boolean ignoreUnknownDb, boolean cascade) throws NoSuchObjectException, InvalidOperationException, MetaException, TException { try { @@ -602,6 +622,7 @@ public boolean dropPartition(String db_name, String tbl_name, List part_ return dropPartition(db_name, tbl_name, part_vals, true, env_context); } + @Override public boolean dropPartition(String dbName, String tableName, String partName, boolean deleteData) throws NoSuchObjectException, MetaException, TException { return dropPartition(dbName, tableName, partName, deleteData, null); @@ -626,6 +647,7 @@ public boolean dropPartition(String dbName, String tableName, String partName, b * @see org.apache.hadoop.hive.metastore.api.ThriftHiveMetastore.Iface#drop_partition(java.lang.String, * java.lang.String, java.util.List, boolean) */ + @Override public boolean dropPartition(String db_name, String tbl_name, List part_vals, boolean deleteData) throws NoSuchObjectException, MetaException, TException { @@ -670,12 +692,14 @@ public boolean dropPartition(String db_name, String tbl_name, List part_ * @see org.apache.hadoop.hive.metastore.api.ThriftHiveMetastore.Iface#drop_table(java.lang.String, * java.lang.String, boolean) */ + @Override public void dropTable(String dbname, String name) throws NoSuchObjectException, MetaException, TException { dropTable(dbname, name, true, true, null); } /** {@inheritDoc} */ + @Override @Deprecated public void dropTable(String tableName, boolean deleteData) throws MetaException, UnknownTableException, TException, NoSuchObjectException { @@ -694,6 +718,7 @@ public void dropTable(String tableName, boolean deleteData) * @see org.apache.hadoop.hive.metastore.api.ThriftHiveMetastore.Iface#drop_table(java.lang.String, * java.lang.String, boolean) */ + @Override public void dropTable(String dbname, String name, boolean deleteData, boolean ignoreUnknownTab) throws MetaException, TException, NoSuchObjectException, UnsupportedOperationException { @@ -769,6 +794,7 @@ public boolean dropType(String type) throws NoSuchObjectException, MetaException } /** {@inheritDoc} */ + @Override public List getDatabases(String databasePattern) throws MetaException { try { @@ -780,6 +806,7 @@ public boolean dropType(String type) throws NoSuchObjectException, MetaException } /** {@inheritDoc} */ + @Override public List getAllDatabases() throws MetaException { try { return client.get_all_databases(); @@ -798,6 +825,7 @@ public boolean dropType(String type) throws NoSuchObjectException, MetaException * @throws MetaException * @throws TException */ + @Override public List listPartitions(String db_name, String tbl_name, short max_parts) throws NoSuchObjectException, MetaException, TException { return deepCopyPartitions( @@ -843,6 +871,7 @@ public boolean dropType(String type) throws NoSuchObjectException, MetaException * @throws NoSuchObjectException * @throws TException */ + @Override public List listPartitionsByFilter(String db_name, String tbl_name, String filter, short max_parts) throws MetaException, NoSuchObjectException, TException { @@ -889,6 +918,7 @@ public boolean listPartitionsByExpr(String db_name, String tbl_name, byte[] expr * @throws TException * @see org.apache.hadoop.hive.metastore.api.ThriftHiveMetastore.Iface#get_database(java.lang.String) */ + @Override public Database getDatabase(String name) throws NoSuchObjectException, MetaException, TException { return deepCopy(client.get_database(name)); @@ -904,11 +934,13 @@ public Database getDatabase(String name) throws NoSuchObjectException, * @see org.apache.hadoop.hive.metastore.api.ThriftHiveMetastore.Iface#get_partition(java.lang.String, * java.lang.String, java.util.List) */ + @Override public Partition getPartition(String db_name, String tbl_name, List part_vals) throws NoSuchObjectException, MetaException, TException { return deepCopy(client.get_partition(db_name, tbl_name, part_vals)); } + @Override public List getPartitionsByNames(String db_name, String tbl_name, List part_names) throws NoSuchObjectException, MetaException, TException { return deepCopyPartitions(client.get_partitions_by_names(db_name, tbl_name, part_names)); @@ -933,12 +965,14 @@ public Partition getPartitionWithAuthInfo(String db_name, String tbl_name, * @see org.apache.hadoop.hive.metastore.api.ThriftHiveMetastore.Iface#get_table(java.lang.String, * java.lang.String) */ + @Override public Table getTable(String dbname, String name) throws MetaException, TException, NoSuchObjectException { return deepCopy(client.get_table(dbname, name)); } /** {@inheritDoc} */ + @Override @Deprecated public Table getTable(String tableName) throws MetaException, TException, NoSuchObjectException { @@ -946,12 +980,14 @@ public Table getTable(String tableName) throws MetaException, TException, } /** {@inheritDoc} */ + @Override public List getTableObjectsByName(String dbName, List tableNames) throws MetaException, InvalidOperationException, UnknownDBException, TException { return deepCopyTables(client.get_table_objects_by_name(dbName, tableNames)); } /** {@inheritDoc} */ + @Override public List listTableNamesByFilter(String dbName, String filter, short maxTables) throws MetaException, TException, InvalidOperationException, UnknownDBException { return client.get_table_names_by_filter(dbName, filter, maxTables); @@ -970,6 +1006,7 @@ public Type getType(String name) throws NoSuchObjectException, MetaException, TE } /** {@inheritDoc} */ + @Override public List getTables(String dbname, String tablePattern) throws MetaException { try { return client.get_tables(dbname, tablePattern); @@ -980,6 +1017,7 @@ public Type getType(String name) throws NoSuchObjectException, MetaException, TE } /** {@inheritDoc} */ + @Override public List getAllTables(String dbname) throws MetaException { try { return client.get_all_tables(dbname); @@ -989,6 +1027,7 @@ public Type getType(String name) throws NoSuchObjectException, MetaException, TE return null; } + @Override public boolean tableExists(String databaseName, String tableName) throws MetaException, TException, UnknownDBException { try { @@ -1000,12 +1039,14 @@ public boolean tableExists(String databaseName, String tableName) throws MetaExc } /** {@inheritDoc} */ + @Override @Deprecated public boolean tableExists(String tableName) throws MetaException, TException, UnknownDBException { return tableExists(DEFAULT_DATABASE_NAME, tableName); } + @Override public List listPartitionNames(String dbName, String tblName, short max) throws MetaException, TException { return client.get_partition_names(dbName, tblName, max); @@ -1018,16 +1059,19 @@ public boolean tableExists(String tableName) throws MetaException, return client.get_partition_names_ps(db_name, tbl_name, part_vals, max_parts); } + @Override public void alter_partition(String dbName, String tblName, Partition newPart) throws InvalidOperationException, MetaException, TException { client.alter_partition(dbName, tblName, newPart); } + @Override public void alter_partitions(String dbName, String tblName, List newParts) throws InvalidOperationException, MetaException, TException { client.alter_partitions(dbName, tblName, newParts); } + @Override public void alterDatabase(String dbName, Database db) throws MetaException, NoSuchObjectException, TException { client.alter_database(dbName, db); @@ -1042,6 +1086,7 @@ public void alterDatabase(String dbName, Database db) * @see org.apache.hadoop.hive.metastore.api.ThriftHiveMetastore.Iface#get_fields(java.lang.String, * java.lang.String) */ + @Override public List getFields(String db, String tableName) throws MetaException, TException, UnknownTableException, UnknownDBException { @@ -1058,6 +1103,7 @@ public void alterDatabase(String dbName, Database db) * @throws TException * @throws AlreadyExistsException */ + @Override public void createIndex(Index index, Table indexTable) throws AlreadyExistsException, InvalidObjectException, MetaException, NoSuchObjectException, TException { client.add_index(index, indexTable); } @@ -1073,6 +1119,7 @@ public void createIndex(Index index, Table indexTable) throws AlreadyExistsExcep * @see org.apache.hadoop.hive.metastore.api.ThriftHiveMetastore.Iface#alter_index(java.lang.String, * java.lang.String, java.lang.String, org.apache.hadoop.hive.metastore.api.Index) */ + @Override public void alter_index(String dbname, String base_tbl_name, String idx_name, Index new_idx) throws InvalidOperationException, MetaException, TException { client.alter_index(dbname, base_tbl_name, idx_name, new_idx); @@ -1088,6 +1135,7 @@ public void alter_index(String dbname, String base_tbl_name, String idx_name, In * @throws NoSuchObjectException * @throws TException */ + @Override public Index getIndex(String dbName, String tblName, String indexName) throws MetaException, UnknownTableException, NoSuchObjectException, TException { @@ -1104,6 +1152,7 @@ public Index getIndex(String dbName, String tblName, String indexName) * @throws MetaException * @throws TException */ + @Override public List listIndexNames(String dbName, String tblName, short max) throws MetaException, TException { return client.get_index_names(dbName, tblName, max); @@ -1119,12 +1168,14 @@ public Index getIndex(String dbName, String tblName, String indexName) * @throws MetaException * @throws TException */ + @Override public List listIndexes(String dbName, String tblName, short max) throws NoSuchObjectException, MetaException, TException { return client.get_indexes(dbName, tblName, max); } /** {@inheritDoc} */ + @Override public boolean updateTableColumnStatistics(ColumnStatistics statsObj) throws NoSuchObjectException, InvalidObjectException, MetaException, TException, InvalidInputException{ @@ -1132,6 +1183,7 @@ public boolean updateTableColumnStatistics(ColumnStatistics statsObj) } /** {@inheritDoc} */ + @Override public boolean updatePartitionColumnStatistics(ColumnStatistics statsObj) throws NoSuchObjectException, InvalidObjectException, MetaException, TException, InvalidInputException{ @@ -1139,6 +1191,7 @@ public boolean updatePartitionColumnStatistics(ColumnStatistics statsObj) } /** {@inheritDoc} */ + @Override public List getTableColumnStatistics(String dbName, String tableName, List colNames) throws NoSuchObjectException, MetaException, TException, InvalidInputException, InvalidObjectException { @@ -1147,6 +1200,7 @@ public boolean updatePartitionColumnStatistics(ColumnStatistics statsObj) } /** {@inheritDoc} */ + @Override public Map> getPartitionColumnStatistics( String dbName, String tableName, List partNames, List colNames) throws NoSuchObjectException, MetaException, TException { @@ -1155,6 +1209,7 @@ public boolean updatePartitionColumnStatistics(ColumnStatistics statsObj) } /** {@inheritDoc} */ + @Override public boolean deletePartitionColumnStatistics(String dbName, String tableName, String partName, String colName) throws NoSuchObjectException, InvalidObjectException, MetaException, TException, InvalidInputException @@ -1163,6 +1218,7 @@ public boolean deletePartitionColumnStatistics(String dbName, String tableName, } /** {@inheritDoc} */ + @Override public boolean deleteTableColumnStatistics(String dbName, String tableName, String colName) throws NoSuchObjectException, InvalidObjectException, MetaException, TException, InvalidInputException @@ -1180,17 +1236,20 @@ public boolean deleteTableColumnStatistics(String dbName, String tableName, Stri * @see org.apache.hadoop.hive.metastore.api.ThriftHiveMetastore.Iface#get_schema(java.lang.String, * java.lang.String) */ + @Override public List getSchema(String db, String tableName) throws MetaException, TException, UnknownTableException, UnknownDBException { return deepCopyFieldSchemas(client.get_schema(db, tableName)); } + @Override public String getConfigValue(String name, String defaultValue) throws TException, ConfigValSecurityException { return client.get_config_value(name, defaultValue); } + @Override public Partition getPartition(String db, String tableName, String partName) throws MetaException, TException, UnknownTableException, NoSuchObjectException { return deepCopy(client.get_partition_by_name(db, tableName, partName)); @@ -1460,6 +1519,7 @@ public static IMetaStoreClient newSynchronizedClient( this.client = client; } + @Override public Object invoke(Object proxy, Method method, Object [] args) throws Throwable { try { diff --git metastore/src/java/org/apache/hadoop/hive/metastore/ObjectStore.java metastore/src/java/org/apache/hadoop/hive/metastore/ObjectStore.java index 4724ae0..9b0d3b3 100644 --- metastore/src/java/org/apache/hadoop/hive/metastore/ObjectStore.java +++ metastore/src/java/org/apache/hadoop/hive/metastore/ObjectStore.java @@ -184,6 +184,7 @@ public ObjectStore() { } + @Override public Configuration getConf() { return hiveConf; } @@ -193,6 +194,7 @@ public Configuration getConf() { * on connection retries. In cases of connection retries, conf will usually * contain modified values. */ + @Override @SuppressWarnings("nls") public void setConf(Configuration conf) { // Although an instance of ObjectStore is accessed by one thread, there may @@ -267,7 +269,7 @@ private static PartitionExpressionProxy createExpressionProxy(Configuration conf @SuppressWarnings("unchecked") Class clazz = (Class)MetaStoreUtils.getClass(className); - return (PartitionExpressionProxy)MetaStoreUtils.newInstance( + return MetaStoreUtils.newInstance( clazz, new Class[0], new Object[0]); } catch (MetaException e) { LOG.error("Error loading PartitionExpressionProxy", e); @@ -340,6 +342,7 @@ public PersistenceManager getPersistenceManager() { return getPMF().getPersistenceManager(); } + @Override public void shutdown() { if (pm != null) { pm.close(); @@ -353,6 +356,7 @@ public void shutdown() { * @return an active transaction */ + @Override public boolean openTransaction() { openTrasactionCalls++; if (openTrasactionCalls == 1) { @@ -376,6 +380,7 @@ public boolean openTransaction() { * * @return Always returns true */ + @Override @SuppressWarnings("nls") public boolean commitTransaction() { if (TXN_STATUS.ROLLBACK == transactionStatus) { @@ -421,6 +426,7 @@ public boolean isActiveTransaction() { /** * Rolls back the current transaction if it is active */ + @Override public void rollbackTransaction() { if (openTrasactionCalls < 1) { debugLog("rolling back transaction: no open transactions: " + openTrasactionCalls); @@ -440,6 +446,7 @@ public void rollbackTransaction() { } } + @Override public void createDatabase(Database db) throws InvalidObjectException, MetaException { boolean commited = false; MDatabase mdb = new MDatabase(); @@ -447,6 +454,7 @@ public void createDatabase(Database db) throws InvalidObjectException, MetaExcep mdb.setLocationUri(db.getLocationUri()); mdb.setDescription(db.getDescription()); mdb.setParameters(db.getParameters()); + mdb.setOwner(db.getOwner()); try { openTransaction(); pm.makePersistent(mdb); @@ -482,6 +490,7 @@ private MDatabase getMDatabase(String name) throws NoSuchObjectException { return mdb; } + @Override public Database getDatabase(String name) throws NoSuchObjectException { MDatabase mdb = null; boolean commited = false; @@ -510,6 +519,7 @@ public Database getDatabase(String name) throws NoSuchObjectException { * @throws MetaException * @throws NoSuchObjectException */ + @Override public boolean alterDatabase(String dbName, Database db) throws MetaException, NoSuchObjectException { @@ -531,6 +541,7 @@ public boolean alterDatabase(String dbName, Database db) return true; } + @Override public boolean dropDatabase(String dbname) throws NoSuchObjectException, MetaException { boolean success = false; LOG.info("Dropping database " + dbname + " along with all tables"); @@ -558,6 +569,7 @@ public boolean dropDatabase(String dbname) throws NoSuchObjectException, MetaExc } + @Override public List getDatabases(String pattern) throws MetaException { boolean commited = false; List databases = null; @@ -595,6 +607,7 @@ public boolean dropDatabase(String dbname) throws NoSuchObjectException, MetaExc return databases; } + @Override public List getAllDatabases() throws MetaException { return getDatabases(".*"); } @@ -626,6 +639,7 @@ private Type getType(MType mtype) { return ret; } + @Override public boolean createType(Type type) { boolean success = false; MType mtype = getMType(type); @@ -643,6 +657,7 @@ public boolean createType(Type type) { return success; } + @Override public Type getType(String typeName) { Type type = null; boolean commited = false; @@ -665,6 +680,7 @@ public Type getType(String typeName) { return type; } + @Override public boolean dropType(String typeName) { boolean success = false; try { @@ -689,6 +705,7 @@ public boolean dropType(String typeName) { return success; } + @Override public void createTable(Table tbl) throws InvalidObjectException, MetaException { boolean commited = false; try { @@ -751,6 +768,7 @@ private void putPersistentPrivObjects(MTable mtbl, List toPersistPrivObj } } + @Override public boolean dropTable(String dbName, String tableName) throws MetaException, NoSuchObjectException, InvalidObjectException, InvalidInputException { boolean success = false; @@ -801,6 +819,7 @@ public boolean dropTable(String dbName, String tableName) throws MetaException, return success; } + @Override public Table getTable(String dbName, String tableName) throws MetaException { boolean commited = false; Table tbl = null; @@ -816,6 +835,7 @@ public Table getTable(String dbName, String tableName) throws MetaException { return tbl; } + @Override public List getTables(String dbName, String pattern) throws MetaException { boolean commited = false; @@ -858,6 +878,7 @@ public Table getTable(String dbName, String tableName) throws MetaException { return tbls; } + @Override public List getAllTables(String dbName) throws MetaException { return getTables(dbName, ".*"); } @@ -883,6 +904,7 @@ private MTable getMTable(String db, String table) { return mtbl; } + @Override public List
getTableObjectsByName(String db, List tbl_names) throws MetaException, UnknownDBException { List
tables = new ArrayList
(); @@ -1296,6 +1318,7 @@ public boolean addPartition(Partition part) throws InvalidObjectException, return success; } + @Override public Partition getPartition(String dbName, String tableName, List part_vals) throws NoSuchObjectException, MetaException { openTransaction(); @@ -1511,6 +1534,7 @@ private boolean dropPartitionCommon(MPartition part) throws NoSuchObjectExceptio return success; } + @Override public List getPartitions( String dbName, String tableName, int maxParts) throws MetaException, NoSuchObjectException { return getPartitionsInternal(dbName, tableName, maxParts, true, true); @@ -1520,10 +1544,12 @@ private boolean dropPartitionCommon(MPartition part) throws NoSuchObjectExceptio String dbName, String tblName, final int maxParts, boolean allowSql, boolean allowJdo) throws MetaException, NoSuchObjectException { return new GetListHelper(dbName, tblName, allowSql, allowJdo) { + @Override protected List getSqlResult(GetHelper> ctx) throws MetaException { Integer max = (maxParts < 0) ? null : maxParts; return directSql.getPartitions(dbName, tblName, max); } + @Override protected List getJdoResult( GetHelper> ctx) throws MetaException, NoSuchObjectException { return convertToParts(listMPartitions(dbName, tblName, maxParts)); @@ -1626,6 +1652,7 @@ public Partition getPartitionWithAuth(String dbName, String tblName, } // TODO:pc implement max + @Override public List listPartitionNames(String dbName, String tableName, short max) throws MetaException { List pns = null; @@ -1824,9 +1851,11 @@ private Collection getPartitionPsQueryResults(String dbName, String tableName, final List partNames, boolean allowSql, boolean allowJdo) throws MetaException, NoSuchObjectException { return new GetListHelper(dbName, tblName, allowSql, allowJdo) { + @Override protected List getSqlResult(GetHelper> ctx) throws MetaException { return directSql.getPartitionsViaSqlFilter(dbName, tblName, partNames, null); } + @Override protected List getJdoResult( GetHelper> ctx) throws MetaException, NoSuchObjectException { return getPartitionsViaOrmFilter(dbName, tblName, partNames); @@ -1865,6 +1894,7 @@ protected boolean getPartitionsByExprInternal(String dbName, String tblName, fin final AtomicBoolean hasUnknownPartitions = new AtomicBoolean(false); result.addAll(new GetListHelper(dbName, tblName, allowSql, allowJdo) { + @Override protected List getSqlResult(GetHelper> ctx) throws MetaException { // If we have some sort of expression tree, try SQL filter pushdown. List result = null; @@ -1880,6 +1910,7 @@ protected boolean getPartitionsByExprInternal(String dbName, String tblName, fin } return result; } + @Override protected List getJdoResult( GetHelper> ctx) throws MetaException, NoSuchObjectException { // If we have some sort of expression tree, try JDOQL filter pushdown. @@ -2271,6 +2302,7 @@ protected String describeResult() { ? getFilterParser(filter).tree : ExpressionTree.EMPTY_TREE; return new GetListHelper(dbName, tblName, allowSql, allowJdo) { + @Override protected List getSqlResult(GetHelper> ctx) throws MetaException { List parts = directSql.getPartitionsViaSqlFilter( ctx.getTable(), tree, (maxParts < 0) ? null : (int)maxParts); @@ -2281,6 +2313,7 @@ protected String describeResult() { } return parts; } + @Override protected List getJdoResult( GetHelper> ctx) throws MetaException, NoSuchObjectException { return getPartitionsViaOrmFilter(ctx.getTable(), tree, maxParts, true); @@ -2499,6 +2532,7 @@ private String makeParameterDeclarationStringObj(Map params) { return partNames; } + @Override public void alterTable(String dbname, String name, Table newTable) throws InvalidObjectException, MetaException { boolean success = false; @@ -2540,6 +2574,7 @@ public void alterTable(String dbname, String name, Table newTable) } } + @Override public void alterIndex(String dbname, String baseTblName, String name, Index newIndex) throws InvalidObjectException, MetaException { boolean success = false; @@ -2593,6 +2628,7 @@ private void alterPartitionNoTxn(String dbname, String name, List part_v } } + @Override public void alterPartition(String dbname, String name, List part_vals, Partition newPart) throws InvalidObjectException, MetaException { boolean success = false; @@ -2617,6 +2653,7 @@ public void alterPartition(String dbname, String name, List part_vals, P } } + @Override public void alterPartitions(String dbname, String name, List> part_vals, List newParts) throws InvalidObjectException, MetaException { boolean success = false; @@ -3187,6 +3224,7 @@ public boolean removeRole(String roleName) throws MetaException, return mRoleMemebership; } + @Override public Role getRole(String roleName) throws NoSuchObjectException { MRole mRole = this.getMRole(roleName); if (mRole == null) { @@ -3216,6 +3254,7 @@ private MRole getMRole(String roleName) { return mrole; } + @Override public List listRoleNames() { boolean success = false; try { @@ -4388,6 +4427,7 @@ private void dropPartitionGrantsNoTxn(String dbName, String tableName, List(query, params); } + @Override @SuppressWarnings("unchecked") public List listAllTableGrants( String principalName, PrincipalType principalType, String dbName, @@ -4489,6 +4529,7 @@ private void dropPartitionGrantsNoTxn(String dbName, String tableName, List listPrincipalPartitionColumnGrants( String principalName, PrincipalType principalType, String dbName, @@ -5493,6 +5534,7 @@ private void writeMPartitionColumnStatistics(Table table, Partition partition, } } + @Override public boolean updateTableColumnStatistics(ColumnStatistics colStats) throws NoSuchObjectException, MetaException, InvalidObjectException, InvalidInputException { boolean committed = false; @@ -5520,6 +5562,7 @@ public boolean updateTableColumnStatistics(ColumnStatistics colStats) } } + @Override public boolean updatePartitionColumnStatistics(ColumnStatistics colStats, List partVals) throws NoSuchObjectException, MetaException, InvalidObjectException, InvalidInputException { boolean committed = false; @@ -5611,6 +5654,7 @@ private void validateTableCols(Table table, List colNames) throws MetaEx } } + @Override public ColumnStatistics getTableColumnStatistics(String dbName, String tableName, List colNames) throws MetaException, NoSuchObjectException { return getTableColumnStatisticsInternal(dbName, tableName, colNames, true, true); @@ -5620,9 +5664,11 @@ protected ColumnStatistics getTableColumnStatisticsInternal( String dbName, String tableName, final List colNames, boolean allowSql, boolean allowJdo) throws MetaException, NoSuchObjectException { return new GetStatHelper(dbName.toLowerCase(), tableName.toLowerCase(), allowSql, allowJdo) { + @Override protected ColumnStatistics getSqlResult(GetHelper ctx) throws MetaException { return directSql.getTableStats(dbName, tblName, colNames); } + @Override protected ColumnStatistics getJdoResult( GetHelper ctx) throws MetaException, NoSuchObjectException { List mStats = getMTableColumnStatistics(getTable(), colNames); @@ -5642,6 +5688,7 @@ protected ColumnStatistics getJdoResult( }.run(true); } + @Override public List getPartitionColumnStatistics(String dbName, String tableName, List partNames, List colNames) throws MetaException, NoSuchObjectException { return getPartitionColumnStatisticsInternal( @@ -5652,10 +5699,12 @@ protected ColumnStatistics getJdoResult( String dbName, String tableName, final List partNames, final List colNames, boolean allowSql, boolean allowJdo) throws MetaException, NoSuchObjectException { return new GetListHelper(dbName, tableName, allowSql, allowJdo) { + @Override protected List getSqlResult( GetHelper> ctx) throws MetaException { return directSql.getPartitionStats(dbName, tblName, partNames, colNames); } + @Override protected List getJdoResult( GetHelper> ctx) throws MetaException, NoSuchObjectException { List mStats = @@ -5749,6 +5798,7 @@ private void dropPartitionColumnStatisticsNoTxn( queryWithParams.getFirst().deletePersistentAll(queryWithParams.getSecond()); } + @Override public boolean deletePartitionColumnStatistics(String dbName, String tableName, String partName, List partVals, String colName) throws NoSuchObjectException, MetaException, InvalidObjectException, InvalidInputException { @@ -5837,6 +5887,7 @@ public boolean deletePartitionColumnStatistics(String dbName, String tableName, return ret; } + @Override public boolean deleteTableColumnStatistics(String dbName, String tableName, String colName) throws NoSuchObjectException, MetaException, InvalidObjectException, InvalidInputException { diff --git metastore/src/model/org/apache/hadoop/hive/metastore/model/MDatabase.java metastore/src/model/org/apache/hadoop/hive/metastore/model/MDatabase.java index 64e34b5..aefb3f3 100644 --- metastore/src/model/org/apache/hadoop/hive/metastore/model/MDatabase.java +++ metastore/src/model/org/apache/hadoop/hive/metastore/model/MDatabase.java @@ -31,6 +31,8 @@ private String name; private String locationUri; private String description; + private String owner; + private Map parameters; /** @@ -42,13 +44,15 @@ public MDatabase() {} * To create a database object * @param name of the database * @param locationUri Location of the database in the warehouse + * @param owner owner of database * @param description Comment describing the database */ - public MDatabase(String name, String locationUri, String description, + public MDatabase(String name, String locationUri, String description, String owner, Map parameters) { this.name = name; this.locationUri = locationUri; this.description = description; + this.owner = owner; this.parameters = parameters; } @@ -107,4 +111,12 @@ public void setDescription(String description) { public void setParameters(Map parameters) { this.parameters = parameters; } + + public String getOwner() { + return owner; + } + + public void setOwner(String owner) { + this.owner = owner; + } } diff --git metastore/src/model/package.jdo metastore/src/model/package.jdo index 49f2aac..f2fba9a 100644 --- metastore/src/model/package.jdo +++ metastore/src/model/package.jdo @@ -53,6 +53,9 @@ + + + diff --git serde/src/gen/thrift/gen-cpp/serde_constants.cpp serde/src/gen/thrift/gen-cpp/serde_constants.cpp index 3ead1fd..54503e3 100644 --- serde/src/gen/thrift/gen-cpp/serde_constants.cpp +++ serde/src/gen/thrift/gen-cpp/serde_constants.cpp @@ -39,6 +39,10 @@ serdeConstants::serdeConstants() { ESCAPE_CHAR = "escape.delim"; + HEADER_COUNT = "skip.header.line.count"; + + FOOTER_COUNT = "skip.footer.line.count"; + VOID_TYPE_NAME = "void"; BOOLEAN_TYPE_NAME = "boolean"; diff --git serde/src/gen/thrift/gen-cpp/serde_constants.h serde/src/gen/thrift/gen-cpp/serde_constants.h index 37f0b8f..d56c917 100644 --- serde/src/gen/thrift/gen-cpp/serde_constants.h +++ serde/src/gen/thrift/gen-cpp/serde_constants.h @@ -29,6 +29,8 @@ class serdeConstants { std::string MAPKEY_DELIM; std::string QUOTE_CHAR; std::string ESCAPE_CHAR; + std::string HEADER_COUNT; + std::string FOOTER_COUNT; std::string VOID_TYPE_NAME; std::string BOOLEAN_TYPE_NAME; std::string TINYINT_TYPE_NAME; diff --git serde/src/gen/thrift/gen-javabean/org/apache/hadoop/hive/serde/test/ThriftTestObj.java serde/src/gen/thrift/gen-javabean/org/apache/hadoop/hive/serde/test/ThriftTestObj.java index dda3c5f..1b708dd 100644 --- serde/src/gen/thrift/gen-javabean/org/apache/hadoop/hive/serde/test/ThriftTestObj.java +++ serde/src/gen/thrift/gen-javabean/org/apache/hadoop/hive/serde/test/ThriftTestObj.java @@ -528,7 +528,7 @@ public void read(org.apache.thrift.protocol.TProtocol iprot, ThriftTestObj struc struct.field3 = new ArrayList(_list0.size); for (int _i1 = 0; _i1 < _list0.size; ++_i1) { - InnerStruct _elem2; // optional + InnerStruct _elem2; // required _elem2 = new InnerStruct(); _elem2.read(iprot); struct.field3.add(_elem2); @@ -636,7 +636,7 @@ public void read(org.apache.thrift.protocol.TProtocol prot, ThriftTestObj struct struct.field3 = new ArrayList(_list5.size); for (int _i6 = 0; _i6 < _list5.size; ++_i6) { - InnerStruct _elem7; // optional + InnerStruct _elem7; // required _elem7 = new InnerStruct(); _elem7.read(iprot); struct.field3.add(_elem7); diff --git serde/src/gen/thrift/gen-javabean/org/apache/hadoop/hive/serde2/thrift/test/Complex.java serde/src/gen/thrift/gen-javabean/org/apache/hadoop/hive/serde2/thrift/test/Complex.java index aa404bf..e36a792 100644 --- serde/src/gen/thrift/gen-javabean/org/apache/hadoop/hive/serde2/thrift/test/Complex.java +++ serde/src/gen/thrift/gen-javabean/org/apache/hadoop/hive/serde2/thrift/test/Complex.java @@ -836,7 +836,7 @@ public void read(org.apache.thrift.protocol.TProtocol iprot, Complex struct) thr struct.lint = new ArrayList(_list0.size); for (int _i1 = 0; _i1 < _list0.size; ++_i1) { - int _elem2; // optional + int _elem2; // required _elem2 = iprot.readI32(); struct.lint.add(_elem2); } @@ -854,7 +854,7 @@ public void read(org.apache.thrift.protocol.TProtocol iprot, Complex struct) thr struct.lString = new ArrayList(_list3.size); for (int _i4 = 0; _i4 < _list3.size; ++_i4) { - String _elem5; // optional + String _elem5; // required _elem5 = iprot.readString(); struct.lString.add(_elem5); } @@ -872,7 +872,7 @@ public void read(org.apache.thrift.protocol.TProtocol iprot, Complex struct) thr struct.lintString = new ArrayList(_list6.size); for (int _i7 = 0; _i7 < _list6.size; ++_i7) { - IntString _elem8; // optional + IntString _elem8; // required _elem8 = new IntString(); _elem8.read(iprot); struct.lintString.add(_elem8); @@ -1074,7 +1074,7 @@ public void read(org.apache.thrift.protocol.TProtocol prot, Complex struct) thro struct.lint = new ArrayList(_list21.size); for (int _i22 = 0; _i22 < _list21.size; ++_i22) { - int _elem23; // optional + int _elem23; // required _elem23 = iprot.readI32(); struct.lint.add(_elem23); } @@ -1087,7 +1087,7 @@ public void read(org.apache.thrift.protocol.TProtocol prot, Complex struct) thro struct.lString = new ArrayList(_list24.size); for (int _i25 = 0; _i25 < _list24.size; ++_i25) { - String _elem26; // optional + String _elem26; // required _elem26 = iprot.readString(); struct.lString.add(_elem26); } @@ -1100,7 +1100,7 @@ public void read(org.apache.thrift.protocol.TProtocol prot, Complex struct) thro struct.lintString = new ArrayList(_list27.size); for (int _i28 = 0; _i28 < _list27.size; ++_i28) { - IntString _elem29; // optional + IntString _elem29; // required _elem29 = new IntString(); _elem29.read(iprot); struct.lintString.add(_elem29); diff --git serde/src/gen/thrift/gen-javabean/org/apache/hadoop/hive/serde2/thrift/test/MegaStruct.java serde/src/gen/thrift/gen-javabean/org/apache/hadoop/hive/serde2/thrift/test/MegaStruct.java index fba49e4..386fef9 100644 --- serde/src/gen/thrift/gen-javabean/org/apache/hadoop/hive/serde2/thrift/test/MegaStruct.java +++ serde/src/gen/thrift/gen-javabean/org/apache/hadoop/hive/serde2/thrift/test/MegaStruct.java @@ -2280,7 +2280,7 @@ public void read(org.apache.thrift.protocol.TProtocol iprot, MegaStruct struct) _val19 = new ArrayList(_list20.size); for (int _i21 = 0; _i21 < _list20.size; ++_i21) { - String _elem22; // optional + String _elem22; // required _elem22 = iprot.readString(); _val19.add(_elem22); } @@ -2310,7 +2310,7 @@ public void read(org.apache.thrift.protocol.TProtocol iprot, MegaStruct struct) _val26 = new ArrayList(_list27.size); for (int _i28 = 0; _i28 < _list27.size; ++_i28) { - MiniStruct _elem29; // optional + MiniStruct _elem29; // required _elem29 = new MiniStruct(); _elem29.read(iprot); _val26.add(_elem29); @@ -2333,7 +2333,7 @@ public void read(org.apache.thrift.protocol.TProtocol iprot, MegaStruct struct) struct.my_stringlist = new ArrayList(_list30.size); for (int _i31 = 0; _i31 < _list30.size; ++_i31) { - String _elem32; // optional + String _elem32; // required _elem32 = iprot.readString(); struct.my_stringlist.add(_elem32); } @@ -2351,7 +2351,7 @@ public void read(org.apache.thrift.protocol.TProtocol iprot, MegaStruct struct) struct.my_structlist = new ArrayList(_list33.size); for (int _i34 = 0; _i34 < _list33.size; ++_i34) { - MiniStruct _elem35; // optional + MiniStruct _elem35; // required _elem35 = new MiniStruct(); _elem35.read(iprot); struct.my_structlist.add(_elem35); @@ -2370,7 +2370,7 @@ public void read(org.apache.thrift.protocol.TProtocol iprot, MegaStruct struct) struct.my_enumlist = new ArrayList(_list36.size); for (int _i37 = 0; _i37 < _list36.size; ++_i37) { - MyEnum _elem38; // optional + MyEnum _elem38; // required _elem38 = MyEnum.findByValue(iprot.readI32()); struct.my_enumlist.add(_elem38); } @@ -2388,7 +2388,7 @@ public void read(org.apache.thrift.protocol.TProtocol iprot, MegaStruct struct) struct.my_stringset = new HashSet(2*_set39.size); for (int _i40 = 0; _i40 < _set39.size; ++_i40) { - String _elem41; // optional + String _elem41; // required _elem41 = iprot.readString(); struct.my_stringset.add(_elem41); } @@ -2406,7 +2406,7 @@ public void read(org.apache.thrift.protocol.TProtocol iprot, MegaStruct struct) struct.my_enumset = new HashSet(2*_set42.size); for (int _i43 = 0; _i43 < _set42.size; ++_i43) { - MyEnum _elem44; // optional + MyEnum _elem44; // required _elem44 = MyEnum.findByValue(iprot.readI32()); struct.my_enumset.add(_elem44); } @@ -2424,7 +2424,7 @@ public void read(org.apache.thrift.protocol.TProtocol iprot, MegaStruct struct) struct.my_structset = new HashSet(2*_set45.size); for (int _i46 = 0; _i46 < _set45.size; ++_i46) { - MiniStruct _elem47; // optional + MiniStruct _elem47; // required _elem47 = new MiniStruct(); _elem47.read(iprot); struct.my_structset.add(_elem47); @@ -3023,7 +3023,7 @@ public void read(org.apache.thrift.protocol.TProtocol prot, MegaStruct struct) t _val95 = new ArrayList(_list96.size); for (int _i97 = 0; _i97 < _list96.size; ++_i97) { - String _elem98; // optional + String _elem98; // required _elem98 = iprot.readString(); _val95.add(_elem98); } @@ -3047,7 +3047,7 @@ public void read(org.apache.thrift.protocol.TProtocol prot, MegaStruct struct) t _val102 = new ArrayList(_list103.size); for (int _i104 = 0; _i104 < _list103.size; ++_i104) { - MiniStruct _elem105; // optional + MiniStruct _elem105; // required _elem105 = new MiniStruct(); _elem105.read(iprot); _val102.add(_elem105); @@ -3064,7 +3064,7 @@ public void read(org.apache.thrift.protocol.TProtocol prot, MegaStruct struct) t struct.my_stringlist = new ArrayList(_list106.size); for (int _i107 = 0; _i107 < _list106.size; ++_i107) { - String _elem108; // optional + String _elem108; // required _elem108 = iprot.readString(); struct.my_stringlist.add(_elem108); } @@ -3077,7 +3077,7 @@ public void read(org.apache.thrift.protocol.TProtocol prot, MegaStruct struct) t struct.my_structlist = new ArrayList(_list109.size); for (int _i110 = 0; _i110 < _list109.size; ++_i110) { - MiniStruct _elem111; // optional + MiniStruct _elem111; // required _elem111 = new MiniStruct(); _elem111.read(iprot); struct.my_structlist.add(_elem111); @@ -3091,7 +3091,7 @@ public void read(org.apache.thrift.protocol.TProtocol prot, MegaStruct struct) t struct.my_enumlist = new ArrayList(_list112.size); for (int _i113 = 0; _i113 < _list112.size; ++_i113) { - MyEnum _elem114; // optional + MyEnum _elem114; // required _elem114 = MyEnum.findByValue(iprot.readI32()); struct.my_enumlist.add(_elem114); } @@ -3104,7 +3104,7 @@ public void read(org.apache.thrift.protocol.TProtocol prot, MegaStruct struct) t struct.my_stringset = new HashSet(2*_set115.size); for (int _i116 = 0; _i116 < _set115.size; ++_i116) { - String _elem117; // optional + String _elem117; // required _elem117 = iprot.readString(); struct.my_stringset.add(_elem117); } @@ -3117,7 +3117,7 @@ public void read(org.apache.thrift.protocol.TProtocol prot, MegaStruct struct) t struct.my_enumset = new HashSet(2*_set118.size); for (int _i119 = 0; _i119 < _set118.size; ++_i119) { - MyEnum _elem120; // optional + MyEnum _elem120; // required _elem120 = MyEnum.findByValue(iprot.readI32()); struct.my_enumset.add(_elem120); } @@ -3130,7 +3130,7 @@ public void read(org.apache.thrift.protocol.TProtocol prot, MegaStruct struct) t struct.my_structset = new HashSet(2*_set121.size); for (int _i122 = 0; _i122 < _set121.size; ++_i122) { - MiniStruct _elem123; // optional + MiniStruct _elem123; // required _elem123 = new MiniStruct(); _elem123.read(iprot); struct.my_structset.add(_elem123); diff --git serde/src/gen/thrift/gen-php/org/apache/hadoop/hive/serde/Types.php serde/src/gen/thrift/gen-php/org/apache/hadoop/hive/serde/Types.php index ecbee27..837dd11 100644 --- serde/src/gen/thrift/gen-php/org/apache/hadoop/hive/serde/Types.php +++ serde/src/gen/thrift/gen-php/org/apache/hadoop/hive/serde/Types.php @@ -44,6 +44,10 @@ $GLOBALS['serde_CONSTANTS']['QUOTE_CHAR'] = "quote.delim"; $GLOBALS['serde_CONSTANTS']['ESCAPE_CHAR'] = "escape.delim"; +$GLOBALS['serde_CONSTANTS']['HEADER_COUNT'] = "skip.header.line.count"; + +$GLOBALS['serde_CONSTANTS']['FOOTER_COUNT'] = "skip.footer.line.count"; + $GLOBALS['serde_CONSTANTS']['VOID_TYPE_NAME'] = "void"; $GLOBALS['serde_CONSTANTS']['BOOLEAN_TYPE_NAME'] = "boolean"; diff --git serde/src/gen/thrift/gen-py/org_apache_hadoop_hive_serde/constants.py serde/src/gen/thrift/gen-py/org_apache_hadoop_hive_serde/constants.py index 474b775..8eac87d 100644 --- serde/src/gen/thrift/gen-py/org_apache_hadoop_hive_serde/constants.py +++ serde/src/gen/thrift/gen-py/org_apache_hadoop_hive_serde/constants.py @@ -23,6 +23,8 @@ MAPKEY_DELIM = "mapkey.delim" QUOTE_CHAR = "quote.delim" ESCAPE_CHAR = "escape.delim" +HEADER_COUNT = "skip.header.line.count" +FOOTER_COUNT = "skip.footer.line.count" VOID_TYPE_NAME = "void" BOOLEAN_TYPE_NAME = "boolean" TINYINT_TYPE_NAME = "tinyint" diff --git serde/src/gen/thrift/gen-rb/serde_constants.rb serde/src/gen/thrift/gen-rb/serde_constants.rb index 248418d..ed86522 100644 --- serde/src/gen/thrift/gen-rb/serde_constants.rb +++ serde/src/gen/thrift/gen-rb/serde_constants.rb @@ -35,6 +35,10 @@ QUOTE_CHAR = %q"quote.delim" ESCAPE_CHAR = %q"escape.delim" +HEADER_COUNT = %q"skip.header.line.count" + +FOOTER_COUNT = %q"skip.footer.line.count" + VOID_TYPE_NAME = %q"void" BOOLEAN_TYPE_NAME = %q"boolean"