-
Notifications
You must be signed in to change notification settings - Fork 58
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
Add datasource field in accelerations cache #1525
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,10 +4,7 @@ | |
*/ | ||
|
||
import { useEffect, useState } from 'react'; | ||
import { | ||
ASYNC_POLLING_INTERVAL, | ||
CATALOG_CACHE_VERSION, | ||
} from '../../../common/constants/data_sources'; | ||
import { ASYNC_POLLING_INTERVAL } from '../../../common/constants/data_sources'; | ||
import { | ||
AsyncPollingResult, | ||
CachedDataSourceStatus, | ||
|
@@ -44,7 +41,7 @@ | |
} | ||
|
||
const combinedData = combineSchemaAndDatarows(pollingResult.schema, pollingResult.datarows); | ||
const newDatabases = combinedData.map((row: any) => ({ | ||
name: row.namespace, | ||
tables: [], | ||
lastUpdated: '', | ||
|
@@ -78,9 +75,8 @@ | |
} | ||
|
||
const combinedData = combineSchemaAndDatarows(pollingResult.schema, pollingResult.datarows); | ||
const newTables = combinedData.map((row: any) => ({ | ||
name: row.tableName, | ||
columns: [], | ||
})); | ||
|
||
CatalogCacheManager.updateDatabase(dataSourceName, { | ||
|
@@ -91,12 +87,15 @@ | |
}); | ||
}; | ||
|
||
export const updateAccelerationsToCache = (pollingResult: AsyncPollingResult) => { | ||
export const updateAccelerationsToCache = ( | ||
dataSourceName: string, | ||
pollingResult: AsyncPollingResult | ||
) => { | ||
const currentTime = new Date().toUTCString(); | ||
|
||
if (!pollingResult) { | ||
CatalogCacheManager.saveAccelerationsCache({ | ||
version: CATALOG_CACHE_VERSION, | ||
CatalogCacheManager.addOrUpdateAccelerationsByDataSource({ | ||
name: dataSourceName, | ||
accelerations: [], | ||
lastUpdated: currentTime, | ||
status: CachedDataSourceStatus.Failed, | ||
|
@@ -106,7 +105,7 @@ | |
|
||
const combinedData = combineSchemaAndDatarows(pollingResult.schema, pollingResult.datarows); | ||
|
||
const newAccelerations = combinedData.map((row: any) => ({ | ||
flintIndexName: row.flint_index_name, | ||
type: row.kind === 'mv' ? 'materialized' : row.kind, | ||
database: row.database, | ||
|
@@ -116,8 +115,8 @@ | |
status: row.status, | ||
})); | ||
|
||
CatalogCacheManager.saveAccelerationsCache({ | ||
version: CATALOG_CACHE_VERSION, | ||
CatalogCacheManager.addOrUpdateAccelerationsByDataSource({ | ||
name: dataSourceName, | ||
accelerations: newAccelerations, | ||
lastUpdated: currentTime, | ||
status: CachedDataSourceStatus.Updated, | ||
|
@@ -125,7 +124,7 @@ | |
}; | ||
|
||
export const updateToCache = ( | ||
pollResults: any, | ||
loadCacheType: LoadCacheType, | ||
dataSourceName: string, | ||
databaseName?: string | ||
|
@@ -138,7 +137,7 @@ | |
updateTablesToCache(dataSourceName, databaseName!, pollResults); | ||
break; | ||
case 'accelerations': | ||
updateAccelerationsToCache(pollResults); | ||
updateAccelerationsToCache(dataSourceName, pollResults); | ||
break; | ||
default: | ||
break; | ||
|
@@ -184,11 +183,12 @@ | |
error: pollingError, | ||
startPolling, | ||
stopPolling: stopLoading, | ||
} = usePolling<any, any>((params) => { | ||
Check warning on line 186 in public/framework/catalog_cache/cache_loader.tsx GitHub Actions / Lint
|
||
return sqlService.fetchWithJobId(params); | ||
}, ASYNC_POLLING_INTERVAL); | ||
|
||
const startLoading = (dataSourceName: string, databaseName?: string) => { | ||
setLoadStatus(DirectQueryLoadingStatus.SCHEDULED); | ||
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. is this meaning that, 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. this is added as we want to start with status as scheduled whenever the 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.
If |
||
setCurrentDataSourceName(dataSourceName); | ||
setCurrentDatabaseName(databaseName); | ||
|
||
|
@@ -257,7 +257,7 @@ | |
} else { | ||
setLoadStatus(status); | ||
} | ||
}, [pollingResult, pollingError]); | ||
Check warning on line 260 in public/framework/catalog_cache/cache_loader.tsx GitHub Actions / Lint
|
||
|
||
return { loadStatus, startLoading, stopLoading }; | ||
}; | ||
|
@@ -272,7 +272,7 @@ | |
return { loadStatus, startLoading, stopLoading }; | ||
}; | ||
|
||
export const useAccelerationsToCache = () => { | ||
export const useLoadAccelerationsToCache = () => { | ||
const { loadStatus, startLoading, stopLoading } = useLoadToCache('accelerations'); | ||
return { loadStatus, startLoading, stopLoading }; | ||
}; |
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.
Why optional here?
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.
Cause columns are lazy loaded for tables. These will be loaded in cache when users open
table flyout
or use a table increate acceleration flyout
.