adesh-rao commented on a change in pull request #1109: URL: https://github.com/apache/hive/pull/1109#discussion_r450599566
########## File path: standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/cache/CachedStore.java ########## @@ -2497,26 +2610,87 @@ long getPartsFound() { @Override public List<SQLPrimaryKey> getPrimaryKeys(String catName, String dbName, String tblName) throws MetaException { - // TODO constraintCache - return rawStore.getPrimaryKeys(catName, dbName, tblName); + catName = normalizeIdentifier(catName); + dbName = StringUtils.normalizeIdentifier(dbName); + tblName = StringUtils.normalizeIdentifier(tblName); + if (!shouldCacheTable(catName, dbName, tblName) || (canUseEvents && rawStore.isActiveTransaction())) { + return rawStore.getPrimaryKeys(catName, dbName, tblName); + } + + Table tbl = sharedCache.getTableFromCache(catName, dbName, tblName); + if (tbl == null) { + // The table containing the primary keys is not yet loaded in cache + return rawStore.getPrimaryKeys(catName, dbName, tblName); + } + List<SQLPrimaryKey> keys = sharedCache.listCachedPrimaryKeys(catName, dbName, tblName); + + return keys; } @Override public List<SQLForeignKey> getForeignKeys(String catName, String parentDbName, String parentTblName, String foreignDbName, String foreignTblName) throws MetaException { - // TODO constraintCache - return rawStore.getForeignKeys(catName, parentDbName, parentTblName, foreignDbName, foreignTblName); + // Get correct ForeignDBName and TableName + if (foreignDbName == null || foreignTblName == null) { + return rawStore.getForeignKeys(catName, parentDbName, parentTblName, foreignDbName, foreignTblName); Review comment: Created https://issues.apache.org/jira/browse/HIVE-23810 for followup. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: gitbox-unsubscr...@hive.apache.org For additional commands, e-mail: gitbox-h...@hive.apache.org