-
Notifications
You must be signed in to change notification settings - Fork 4.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
HIVE-28677: Implement direct sql for delete table/partition column stats #5587
Merged
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10234,30 +10234,47 @@ protected Integer getJdoResult(GetHelper<Integer> ctx) throws MetaException, NoS | |
public boolean deletePartitionColumnStatistics(String catName, String dbName, String tableName, | ||
String partName, List<String> partVals, String colName, String engine) | ||
throws NoSuchObjectException, MetaException, InvalidObjectException, InvalidInputException { | ||
boolean ret = false; | ||
Query query = null; | ||
dbName = org.apache.commons.lang3.StringUtils.defaultString(dbName, | ||
Warehouse.DEFAULT_DATABASE_NAME); | ||
catName = normalizeIdentifier(catName); | ||
if (tableName == null) { | ||
throw new InvalidInputException("Table name is null."); | ||
} | ||
// Note: this does not verify ACID state; called internally when removing cols/etc. | ||
// Also called via an unused metastore API that checks for ACID tables. | ||
MPartition mPartition = getMPartition(catName, dbName, tableName, partName); | ||
if (mPartition == null) { | ||
throw new NoSuchObjectException("Partition " + partName | ||
+ " for which stats deletion is requested doesn't exist"); | ||
} | ||
|
||
return new GetHelper<Boolean>(catName, dbName, tableName, true, true) { | ||
@Override | ||
protected String describeResult() { | ||
return "delete prtition column stats"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: partition spelling. |
||
} | ||
|
||
@Override | ||
protected Boolean getSqlResult(GetHelper<Boolean> ctx) throws MetaException { | ||
return directSql.deletePartitionColumnStats(catName, dbName, tableName, partName, colName, engine); | ||
} | ||
|
||
@Override | ||
protected Boolean getJdoResult(GetHelper<Boolean> ctx) | ||
throws MetaException, NoSuchObjectException, InvalidObjectException { | ||
return deletePartitionColumnStatisticsVisJDO(catName, dbName, tableName, partName, colName, engine); | ||
} | ||
}.run(false); | ||
} | ||
|
||
private boolean deletePartitionColumnStatisticsVisJDO(String catName, String dbName, String tableName, | ||
String partName, String colName, String engine) throws NoSuchObjectException { | ||
boolean ret = false; | ||
Query query = null; | ||
try { | ||
openTransaction(); | ||
MTable mTable = getMTable(catName, dbName, tableName); | ||
MPartitionColumnStatistics mStatsObj; | ||
List<MPartitionColumnStatistics> mStatsObjColl; | ||
if (mTable == null) { | ||
throw new NoSuchObjectException("Table " + tableName | ||
+ " for which stats deletion is requested doesn't exist"); | ||
} | ||
// Note: this does not verify ACID state; called internally when removing cols/etc. | ||
// Also called via an unused metastore API that checks for ACID tables. | ||
MPartition mPartition = getMPartition(catName, dbName, tableName, partVals, mTable); | ||
if (mPartition == null) { | ||
throw new NoSuchObjectException("Partition " + partName | ||
+ " for which stats deletion is requested doesn't exist"); | ||
} | ||
query = pm.newQuery(MPartitionColumnStatistics.class); | ||
String filter; | ||
String parameters; | ||
|
@@ -10334,25 +10351,42 @@ public boolean deletePartitionColumnStatistics(String catName, String dbName, St | |
public boolean deleteTableColumnStatistics(String catName, String dbName, String tableName, | ||
String colName, String engine) | ||
throws NoSuchObjectException, MetaException, InvalidObjectException, InvalidInputException { | ||
boolean ret = false; | ||
Query query = null; | ||
dbName = org.apache.commons.lang3.StringUtils.defaultString(dbName, | ||
Warehouse.DEFAULT_DATABASE_NAME); | ||
if (tableName == null) { | ||
throw new InvalidInputException("Table name is null."); | ||
} | ||
|
||
// Note: this does not verify ACID state; called internally when removing cols/etc. | ||
// Also called via an unused metastore API that checks for ACID tables. | ||
return new GetHelper<Boolean>(catName, dbName, tableName, true, true) { | ||
|
||
@Override | ||
protected String describeResult() { | ||
return "delete table column stats"; | ||
} | ||
|
||
@Override | ||
protected Boolean getSqlResult(GetHelper<Boolean> ctx) throws MetaException { | ||
return directSql.deleteTableColumnStatistics(getTable().getId(), colName, engine); | ||
} | ||
|
||
@Override | ||
protected Boolean getJdoResult(GetHelper<Boolean> ctx) | ||
throws MetaException, NoSuchObjectException, InvalidObjectException { | ||
return deleteTableColumnStatisticsViaJdo(catName, dbName, tableName, colName, engine); | ||
} | ||
}.run(true); | ||
} | ||
|
||
private boolean deleteTableColumnStatisticsViaJdo(String catName, String dbName, String tableName, | ||
String colName, String engine) throws NoSuchObjectException { | ||
boolean ret = false; | ||
Query query = null; | ||
try { | ||
openTransaction(); | ||
MTable mTable = getMTable(catName, dbName, tableName); | ||
MTableColumnStatistics mStatsObj; | ||
List<MTableColumnStatistics> mStatsObjColl; | ||
if (mTable == null) { | ||
throw new NoSuchObjectException("Table " + | ||
TableName.getQualified(catName, dbName, tableName) | ||
+ " for which stats deletion is requested doesn't exist"); | ||
} | ||
// Note: this does not verify ACID state; called internally when removing cols/etc. | ||
// Also called via an unused metastore API that checks for ACID tables. | ||
query = pm.newQuery(MTableColumnStatistics.class); | ||
String filter; | ||
String parameters; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Empty String can be removed from the value of
sqlFilter
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed.