Skip to content

Commit

Permalink
Correctly Utilize Cache in Tables Flyout (opensearch-project#1662)
Browse files Browse the repository at this point in the history
* correctly check for cache on table flyout

Signed-off-by: Sean Li <lnse@amazon.com>

* skip start loading if fail

Signed-off-by: Sean Li <lnse@amazon.com>

---------

Signed-off-by: Sean Li <lnse@amazon.com>
  • Loading branch information
sejli authored Mar 29, 2024
1 parent 628f3fd commit 3be2d39
Showing 1 changed file with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,21 @@ export const AssociatedObjectsDetailsFlyout = ({

useEffect(() => {
if (tableDetail && !tableDetail.columns) {
startLoading(datasourceName, tableDetail.database, tableDetail.name);
try {
const tables = CatalogCacheManager.getTable(
datasourceName,
tableDetail.database,
tableDetail.name
);
if (tables?.columns) {
setTableColumns(tables?.columns);
} else {
startLoading(datasourceName, tableDetail.database, tableDetail.name);
}
} catch (error) {
console.error(error);
setToast('Your cache is outdated, refresh databases and tables', 'warning');
}
} else if (tableDetail && tableDetail.columns) {
setTableColumns(tableDetail.columns);
}
Expand Down

0 comments on commit 3be2d39

Please sign in to comment.