You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by na...@apache.org on 2010/11/05 23:55:48 UTC
svn commit: r1031871 - in /hive/trunk: CHANGES.txt
metastore/if/hive_metastore.thrift
metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java
ql/src/java/org/apache/hadoop/hive/ql/metadata/Hive.java
Author: namit
Date: Fri Nov 5 22:55:47 2010
New Revision: 1031871
URL: http://svn.apache.org/viewvc?rev=1031871&view=rev
Log:
HIVE-1768 Update transident_lastDdlTime only if not specified
(Paul Yang via namit)
Modified:
hive/trunk/CHANGES.txt
hive/trunk/metastore/if/hive_metastore.thrift
hive/trunk/metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java
hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/metadata/Hive.java
Modified: hive/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hive/trunk/CHANGES.txt?rev=1031871&r1=1031870&r2=1031871&view=diff
==============================================================================
--- hive/trunk/CHANGES.txt (original)
+++ hive/trunk/CHANGES.txt Fri Nov 5 22:55:47 2010
@@ -223,6 +223,9 @@ Trunk - Unreleased
HIVE-1750 Remove partition filtering conditions when possible
(Siying Dong via namit)
+ HIVE-1768 Update transident_lastDdlTime only if not specified
+ (Paul Yang via namit)
+
OPTIMIZATIONS
BUG FIXES
Modified: hive/trunk/metastore/if/hive_metastore.thrift
URL: http://svn.apache.org/viewvc/hive/trunk/metastore/if/hive_metastore.thrift?rev=1031871&r1=1031870&r2=1031871&view=diff
==============================================================================
--- hive/trunk/metastore/if/hive_metastore.thrift (original)
+++ hive/trunk/metastore/if/hive_metastore.thrift Fri Nov 5 22:55:47 2010
@@ -178,6 +178,7 @@ service ThriftHiveMetastore extends fb30
// sd.inputFormat (SequenceFileInputFormat (binary like falcon tables or u_full) or TextInputFormat)
// sd.outputFormat (SequenceFileInputFormat (binary) or TextInputFormat)
// sd.serdeInfo.serializationLib (SerDe class name eg org.apache.hadoop.hive.serde.simple_meta.MetadataTypedColumnsetSerDe
+ // * See notes on DDL_TIME
void create_table(1:Table tbl) throws(1:AlreadyExistsException o1, 2:InvalidObjectException o2, 3:MetaException o3, 4:NoSuchObjectException o4)
// drops the table and all the partitions associated with it if the table has partitions
// delete data (including partitions) if deleteData is set to true
@@ -189,10 +190,12 @@ service ThriftHiveMetastore extends fb30
Table get_table(1:string dbname, 2:string tbl_name)
throws (1:MetaException o1, 2:NoSuchObjectException o2)
// alter table applies to only future partitions not for existing partitions
+ // * See notes on DDL_TIME
void alter_table(1:string dbname, 2:string tbl_name, 3:Table new_tbl)
throws (1:InvalidOperationException o1, 2:MetaException o2)
// the following applies to only tables that have partitions
+ // * See notes on DDL_TIME
Partition add_partition(1:Partition new_part)
throws(1:InvalidObjectException o1, 2:AlreadyExistsException o2, 3:MetaException o3)
Partition append_partition(1:string db_name, 2:string tbl_name, 3:list<string> part_vals)
@@ -235,6 +238,7 @@ service ThriftHiveMetastore extends fb30
// changes the partition to the new partition object. partition is identified from the part values
// in the new_part
+ // * See notes on DDL_TIME
void alter_partition(1:string db_name, 2:string tbl_name, 3:Partition new_part)
throws(1:InvalidOperationException o1, 2:MetaException o2)
@@ -267,6 +271,9 @@ service ThriftHiveMetastore extends fb30
throws(1:MetaException o2)
}
+// * Note about the DDL_TIME: When creating or altering a table or a partition,
+// if the DDL_TIME is not set, the current time will be used.
+
// For storing info about archived partitions in parameters
// Whether the partition is archived
Modified: hive/trunk/metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java
URL: http://svn.apache.org/viewvc/hive/trunk/metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java?rev=1031871&r1=1031870&r2=1031871&view=diff
==============================================================================
--- hive/trunk/metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java (original)
+++ hive/trunk/metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java Fri Nov 5 22:55:47 2010
@@ -784,8 +784,10 @@ public class HiveMetaStore extends Thrif
// set create time
long time = System.currentTimeMillis() / 1000;
tbl.setCreateTime((int) time);
- tbl.putToParameters(Constants.DDL_TIME, Long.toString(time));
-
+ if (tbl.getParameters() == null ||
+ tbl.getParameters().get(Constants.DDL_TIME) == null) {
+ tbl.putToParameters(Constants.DDL_TIME, Long.toString(time));
+ }
ms.createTable(tbl);
success = ms.commitTransaction();
@@ -1160,8 +1162,10 @@ public class HiveMetaStore extends Thrif
// set create time
long time = System.currentTimeMillis() / 1000;
part.setCreateTime((int) time);
- part.putToParameters(Constants.DDL_TIME, Long.toString(time));
-
+ if (part.getParameters() == null ||
+ part.getParameters().get(Constants.DDL_TIME) == null) {
+ part.putToParameters(Constants.DDL_TIME, Long.toString(time));
+ }
success = ms.addPartition(part) && ms.commitTransaction();
} finally {
@@ -1360,8 +1364,13 @@ public class HiveMetaStore extends Thrif
final String tbl_name, final Partition new_part)
throws InvalidOperationException, MetaException, TException {
try {
- new_part.putToParameters(Constants.DDL_TIME, Long.toString(System
- .currentTimeMillis() / 1000));
+ // Set DDL time to now if not specified
+ if (new_part.getParameters() == null ||
+ new_part.getParameters().get(Constants.DDL_TIME) == null ||
+ Integer.parseInt(new_part.getParameters().get(Constants.DDL_TIME)) == 0) {
+ new_part.putToParameters(Constants.DDL_TIME, Long.toString(System
+ .currentTimeMillis() / 1000));
+ }
ms.alterPartition(db_name, tbl_name, new_part);
} catch (InvalidObjectException e) {
throw new InvalidOperationException("alter is not possible");
@@ -1414,8 +1423,13 @@ public class HiveMetaStore extends Thrif
incrementCounter("alter_table");
logStartFunction("alter_table: db=" + dbname + " tbl=" + name
+ " newtbl=" + newTable.getTableName());
- newTable.putToParameters(Constants.DDL_TIME, Long.toString(System
- .currentTimeMillis() / 1000));
+
+ // Update the time if it hasn't been specified.
+ if (newTable.getParameters() == null ||
+ newTable.getParameters().get(Constants.DDL_TIME) == null) {
+ newTable.putToParameters(Constants.DDL_TIME, Long.toString(System
+ .currentTimeMillis() / 1000));
+ }
try {
executeWithRetry(new Command<Boolean>() {
Modified: hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/metadata/Hive.java
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/metadata/Hive.java?rev=1031871&r1=1031870&r2=1031871&view=diff
==============================================================================
--- hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/metadata/Hive.java (original)
+++ hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/metadata/Hive.java Fri Nov 5 22:55:47 2010
@@ -54,6 +54,7 @@ import org.apache.hadoop.hive.metastore.
import org.apache.hadoop.hive.metastore.TableType;
import org.apache.hadoop.hive.metastore.Warehouse;
import org.apache.hadoop.hive.metastore.api.AlreadyExistsException;
+import org.apache.hadoop.hive.metastore.api.Constants;
import org.apache.hadoop.hive.metastore.api.Database;
import org.apache.hadoop.hive.metastore.api.FieldSchema;
import org.apache.hadoop.hive.metastore.api.Index;
@@ -336,6 +337,10 @@ public class Hive {
public void alterTable(String tblName, Table newTbl)
throws InvalidOperationException, HiveException {
try {
+ // Remove the DDL_TIME so it gets refreshed
+ if (newTbl.getParameters() != null) {
+ newTbl.getParameters().remove(Constants.DDL_TIME);
+ }
getMSC().alter_table(getCurrentDatabase(), tblName, newTbl.getTTable());
} catch (MetaException e) {
throw new HiveException("Unable to alter table.", e);
@@ -358,6 +363,10 @@ public class Hive {
public void alterPartition(String tblName, Partition newPart)
throws InvalidOperationException, HiveException {
try {
+ // Remove the DDL time so that it gets refreshed
+ if (newPart.getParameters() != null) {
+ newPart.getParameters().remove(Constants.DDL_TIME);
+ }
getMSC().alter_partition(getCurrentDatabase(), tblName,
newPart.getTPartition());
@@ -398,6 +407,9 @@ public class Hive {
tbl.getDeserializer()));
}
tbl.checkValidity();
+ if (tbl.getParameters() != null) {
+ tbl.getParameters().remove(Constants.DDL_TIME);
+ }
getMSC().createTable(tbl.getTTable());
} catch (AlreadyExistsException e) {
if (!ifNotExists) {
@@ -1087,6 +1099,8 @@ public class Hive {
try {
Partition tmpPart = new Partition(tbl, partSpec, location);
+ // No need to clear DDL_TIME in parameters since we know it's
+ // not populated on construction.
partition = getMSC().add_partition(tmpPart.getTPartition());
} catch (Exception e) {
LOG.error(StringUtils.stringifyException(e));