Skip to content

Conversation

msyavuz
Copy link
Member

@msyavuz msyavuz commented Sep 24, 2025

SUMMARY

Implements dataset cache clearing functionality to ensure fresh data is fetched after dataset modifications. This addresses potential stale data issues where cached API responses were not being invalidated when datasets were updated.

Key Changes:

  • Added datasetCache.ts utility with functions to clear cached API responses for specific datasets
  • Integrated cache clearing in SaveDatasetModal after dataset updates
  • Integrated cache clearing in DatasourceModal and DatasourceEditor components
  • Ensures that any subsequent API calls fetch fresh data from the server

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

N/A - This is a backend caching improvement with no visible UI changes

TESTING INSTRUCTIONS

  1. Navigate to SQL Lab and create/modify a dataset
  2. Open the dataset in the datasource editor and make changes
  3. Verify that the changes are immediately reflected without requiring a page refresh
  4. Test saving datasets from SQL Lab and confirm fresh data is loaded
  5. Check browser network tab to verify cache invalidation is working (no stale cached responses)

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • Migration is atomic, supports rollback & is backwards-compatible
    • Confirm DB migration upgrade and downgrade tested
    • Runtime estimates and downtime expectations provided
  • Introduces new feature or API
  • Removes existing feature or API

🤖 Generated with Claude Code

- Add datasetCache utility with functions to clear cached API responses
- Integrate cache clearing in SaveDatasetModal after dataset updates
- Integrate cache clearing in DatasourceModal and DatasourceEditor
- Ensures fresh data is fetched after dataset modifications

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
@dosubot dosubot bot added change:frontend Requires changing the frontend data:dataset Related to dataset configurations labels Sep 24, 2025
Copy link

@korbit-ai korbit-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review by Korbit AI

Korbit automatically attempts to detect when you fix issues in new commits.
Category Issue Status
Functionality Redundant and imprecise cache key matching ▹ view 🧠 Not in standard
Functionality Invalid dataset ID 0 rejected by falsy check ▹ view 🧠 Not in scope
Design Inefficient Two-Pass Cache Operation ▹ view 🧠 Incorrect
Functionality Unawaited dataset cache clear ▹ view 🧠 Not in scope
Files scanned
File Path Reviewed
superset-frontend/src/utils/datasetCache.ts
superset-frontend/src/components/Datasource/DatasourceModal/index.tsx
superset-frontend/src/SqlLab/components/SaveDatasetModal/index.tsx
superset-frontend/src/components/Datasource/components/DatasourceEditor/DatasourceEditor.jsx

Explore our documentation to understand the languages and file types we support and the files we ignore.

Check out our docs on how you can make Korbit work best for you and your team.

Loving Korbit!? Share us on LinkedIn Reddit and X

Comment on lines +28 to +48
export function clearDatasetCache(datasetId: number | string): void {
if (!datasetId) return;

const keysToDelete: string[] = [];

// Find all cache keys related to this dataset
supersetGetCache.forEach((_value, key) => {
// Match any endpoint that references this dataset ID
// This includes:
// - /api/v1/dataset/{id}
// - /api/v1/dataset/{id}?q=...
// - /api/v1/dataset/{id}/related_objects
// - etc.
if (
key.includes(`/api/v1/dataset/${datasetId}`) ||
key.includes(`/api/v1/dataset/${datasetId}/`) ||
key.includes(`/api/v1/dataset/${datasetId}?`)
) {
keysToDelete.push(key);
}
});

This comment was marked as resolved.

Comment on lines +41 to +45
if (
key.includes(`/api/v1/dataset/${datasetId}`) ||
key.includes(`/api/v1/dataset/${datasetId}/`) ||
key.includes(`/api/v1/dataset/${datasetId}?`)
) {

This comment was marked as resolved.

* @param datasetId - The ID of the dataset to clear from cache
*/
export function clearDatasetCache(datasetId: number | string): void {
if (!datasetId) return;

This comment was marked as resolved.


// Clear the dataset cache to ensure fresh data when fetching columns for filters
// This ensures that changes to the dataset are immediately reflected
clearDatasetCache(currentDatasource.id);

This comment was marked as resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
change:frontend Requires changing the frontend data:dataset Related to dataset configurations size/M
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant