FAQ
Author: namit
Date: Tue Mar 20 00:59:47 2012
New Revision: 1302739

URL: http://svn.apache.org/viewvc?rev=1302739&view=rev
Log:
HIVE-2471 Add timestamp column to the partition stats table.
(Kevin Wilfong via namit)


Modified:
hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/stats/jdbc/JDBCStatsSetupConstants.java
hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/stats/jdbc/JDBCStatsUtils.java

Modified: hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/stats/jdbc/JDBCStatsSetupConstants.java
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/stats/jdbc/JDBCStatsSetupConstants.java?rev=1302739&r1=1302738&r2=1302739&view=diff
==============================================================================
--- hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/stats/jdbc/JDBCStatsSetupConstants.java (original)
+++ hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/stats/jdbc/JDBCStatsSetupConstants.java Tue Mar 20 00:59:47 2012
@@ -21,7 +21,12 @@ public final class JDBCStatsSetupConstan

public static final String PART_STAT_ID_COLUMN_NAME = "ID";

- public static final String PART_STAT_TABLE_NAME = "PARTITION_STATS";
+ public static final String PART_STAT_TIMESTAMP_COLUMN_NAME = "TS";
+
+ // NOTE:
+ // For all table names past and future, Hive will not drop old versions of this table, it is up
+ // to the administrator
+ public static final String PART_STAT_TABLE_NAME = "PARTITION_STATS_V2";

// supported statistics - column names


Modified: hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/stats/jdbc/JDBCStatsUtils.java
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/stats/jdbc/JDBCStatsUtils.java?rev=1302739&r1=1302738&r2=1302739&view=diff
==============================================================================
--- hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/stats/jdbc/JDBCStatsUtils.java (original)
+++ hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/stats/jdbc/JDBCStatsUtils.java Tue Mar 20 00:59:47 2012
@@ -72,6 +72,10 @@ public class JDBCStatsUtils {
return JDBCStatsSetupConstants.PART_STAT_ID_COLUMN_NAME;
}

+ public static String getTimestampColumnName() {
+ return JDBCStatsSetupConstants.PART_STAT_TIMESTAMP_COLUMN_NAME;
+ }
+
public static String getStatTableName() {
return JDBCStatsSetupConstants.PART_STAT_TABLE_NAME;
}
@@ -104,7 +108,8 @@ public class JDBCStatsUtils {
*/
public static String getCreate(String comment) {
String create = "CREATE TABLE /* " + comment + " */ " + JDBCStatsUtils.getStatTableName() +
- " (" + JDBCStatsUtils.getIdColumnName() + " VARCHAR(255) PRIMARY KEY ";
+ " (" + getTimestampColumnName() + " TIMESTAMP DEFAULT CURRENT_TIMESTAMP, " +
+ JDBCStatsUtils.getIdColumnName() + " VARCHAR(255) PRIMARY KEY ";
for (int i = 0; i < supportedStats.size(); i++) {
create += ", " + getStatColumnName(supportedStats.get(i)) + " BIGINT ";
}
@@ -120,7 +125,7 @@ public class JDBCStatsUtils {
for (int i = 0; i < supportedStats.size(); i++) {
update += columnNameMapping.get(supportedStats.get(i)) + " = ? , ";
}
- update = update.substring(0, update.length() - 2);
+ update += getTimestampColumnName() + " = CURRENT_TIMESTAMP";
update += " WHERE " + JDBCStatsUtils.getIdColumnName() + " = ? AND ? > ( SELECT TEMP."
+ getStatColumnName(getBasicStat()) + " FROM ( " +
" SELECT " + getStatColumnName(getBasicStat()) + " FROM " + getStatTableName() + " WHERE "
@@ -132,12 +137,15 @@ public class JDBCStatsUtils {
* Prepares INSERT statement for statistic publishing.
*/
public static String getInsert(String comment) {
- String insert = "INSERT INTO /* " + comment + " */ " + getStatTableName() + " VALUES (?, ";
+ String columns = JDBCStatsUtils.getIdColumnName();
+ String values = "?";
+
for (int i = 0; i < supportedStats.size(); i++) {
- insert += "? , ";
+ columns += ", " + getStatColumnName(supportedStats.get(i));
+ values += ", ?";
}
- insert = insert.substring(0, insert.length() - 3);
- insert += ")";
+ String insert = "INSERT INTO /* " + comment + " */ " + getStatTableName() + "(" + columns +
+ ") VALUES (" + values + ")";
return insert;
}

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupcommits @
categorieshive, hadoop
postedMar 20, '12 at 1:00a
activeMar 20, '12 at 1:00a
posts1
users1
websitehive.apache.org

1 user in discussion

Namit: 1 post

People

Translate

site design / logo © 2021 Grokbase