8000 feat: use new paginated endpoint for pivoted sql results by almeidabbm · Pull Request #14845 · lightdash/lightdash · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

feat: use new paginated endpoint for pivoted sql results #14845

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

Merged

Conversation

almeidabbm
Copy link
Contributor
@almeidabbm almeidabbm commented May 15, 2025

Relates to: Update FE Sql tiles to use the new paginated endpoints

Closes: #14633

Description:

  • Uses POST /api/v2/projects/{projectUuid}/query/sql-chart to trigger the sql chart query

Reviewer actions

  • I have manually tested the changes in the preview environment
  • I have reviewed the code
  • I understand that "request changes" will block this PR from merging

Copy link
Contributor Author
almeidabbm commented May 15, 2025

@almeidabbm almeidabbm marked this pull request as ready for review May 15, 2025 19:24
@almeidabbm almeidabbm marked this pull request as draft May 15, 2025 19:24
Comment on lines +22 to +33
const { groupByColumns, valuesColumns: valuesColumnsConfig } =
queryHistory.pivot_configuration;

// From ProjectService.pivotQueryWorkerTask
return groupByColumns && groupByColumns.length > 0
? Object.values(queryHistory.pivot_values_columns ?? {})
: null;
: valuesColumnsConfig.map((col) => ({
referenceField: col.reference,
pivotColumnName: `${col.reference}_${col.aggregation}`,
aggregation: col.aggregation,
pivotValues: [],
}));
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We need this, because in the frontend a query that just aggregates results is considered a pivoted query and depends on the valuesColumns returned by the endpoint

@almeidabbm almeidabbm force-pushed the 05-15-chore_use_new_paginated_endpoint_for_pivoted_sql_results branch from 486fd7d to 30c638b Compare May 15, 2025 19:43
@almeidabbm almeidabbm force-pushed the 05-15-chore_fetch_results_from_new_endpoint branch from 03d62f9 to d019b18 Compare May 15, 2025 21:39
@almeidabbm almeidabbm force-pushed the 05-15-chore_use_new_paginated_endpoint_for_pivoted_sql_results branch from 30c638b to 199ab61 Compare May 15, 2025 21:39
@ZeRego ZeRego force-pushed the 05-15-chore_use_new_paginated_endpoint_for_pivoted_sql_results branch from 199ab61 to 688ea63 Compare May 15, 2025 21:47
@almeidabbm almeidabbm force-pushed the 05-15-chore_use_new_paginated_endpoint_for_pivoted_sql_results branch from 688ea63 to 2ba7882 Compare May 15, 2025 22:11
@almeidabbm
Copy link
Contributor Author
almeidabbm commented May 15, 2025

TODO: need to implement backoff strategy like we do for useQueryResults - DONE

@almeidabbm almeidabbm force-pushed the 05-15-chore_fetch_results_from_new_endpoint branch from d019b18 to 557cd78 Compare May 16, 2025 13:19
@almeidabbm almeidabbm force-pushed the 05-15-chore_use_new_paginated_endpoint_for_pivoted_sql_results branch 3 times, most recently from 7b1b0e4 to 5dfcc22 Compare May 16, 2025 13:54
@almeidabbm almeidabbm force-pushed the 05-15-chore_fetch_results_from_new_endpoint branch from 557cd 8000 78 to 41b5f35 Compare May 16, 2025 13:54
@almeidabbm almeidabbm force-pushed the 05-15-chore_use_new_paginated_endpoint_for_pivoted_sql_results branch 2 times, most recently from d301f94 to 36c7bd6 Compare May 16, 2025 14:26
@almeidabbm almeidabbm marked this pull request as ready for review May 19, 2025 10:14
@ZeRego ZeRego force-pushed the 05-15-chore_use_new_paginated_endpoint_for_pivoted_sql_results branch from 36c7bd6 to b742d6d Compare May 19, 2025 10:37
@ZeRego ZeRego force-pushed the 05-15-chore_fetch_results_from_new_endpoint branch from 41b5f35 to 628eacf Compare May 19, 2025 10:37
Base automatically changed from 05-15-chore_fetch_results_from_new_endpoint to main May 19, 2025 10:56
@ZeRego ZeRego force-pushed the 05-15-chore_use_new_paginated_endpoint_for_pivoted_sql_results branch from b742d6d to 264b6be Compare May 19, 2025 10:57
@owlas owlas requested a deployment to 05-15-chore_use_new_paginated_endpoint_for_pivoted_sql_results - jaffle_db_pg_13 PR #14845 May 19, 2025 10:57 — with Render Abandoned
@owlas owlas deployed to 05-15-chore_use_new_paginated_endpoint_for_pivoted_sql_results - headless-browser PR #14845 May 19, 2025 10:57 — with Render Active
@ZeRego ZeRego linked an issue May 19, 2025 that may be closed by this pull request
@ZeRego ZeRego changed the title chore: use new paginated endpoint for pivoted sql results feat: use new paginated endpoint for pivoted sql results May 19, 2025
@owlas owlas temporarily deployed to 05-15-chore_use_new_paginated_endpoint_for_pivoted_sql_results - lightdash PR #14845 May 19, 2025 13:50 — with Render Destroyed
@owlas owlas temporarily deployed to 05-15-chore_use_new_paginated_endpoint_for_pivoted_sql_results - headless-browser PR #14845 May 19, 2025 13:50 — with Render Destroyed
Comment on lines +386 to +391
await new Promise<void>((resolve, reject) => {
readStream.on('end', () => {
res.end();
resolve();
});
});
Copy link
Contributor

Choose a reason for hiding this comment

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

The stream error event isn't being handled in this Promise wrapper. If the stream encounters an error during piping, the Promise will never resolve or reject, potentially causing the request to hang. Consider adding an error handler:

await new Promise<void>((resolve, reject) => {
    readStream.on('end', () => {
        res.end();
        resolve();
    });
    readStream.on('error', (err) => {
        reject(err);
    });
});

This ensures proper error propagation and prevents request timeouts when stream errors occur.

Suggested change
await new Promise<void>((resolve, reject) => {
readStream.on('end', () => {
res.end();
resolve();
});
});
await new Promise<void>((resolve, reject) => {
readStream.on('end', () => {
res.end();
resolve();
});
readStream.on('error', (err) => {
reject(err);
});
});

Spotted by Diamond

Is this helpful? React 👍 or 👎 to let us know.

@ZeRego ZeRego merged commit a51d70b into main May 19, 2025
45 of 49 checks passed
@ZeRego ZeRego deleted the 05-15-chore_use_new_paginated_endpoint_for_pivoted_sql_results branch May 19, 2025 14:19
lightdash-bot pushed a commit that referenced this pull request May 19, 2025
# [0.1632.0](0.1631.1...0.1632.0) (2025-05-19)

### Features

* use new paginated endpoint for pivoted sql results ([#14845](#14845)) ([a51d70b](a51d70b))
@lightdash-bot
Copy link
Collaborator

🎉 This PR is included in version 0.1632.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update FE Sql tiles to use the new paginated endpoints
4 participants
0