-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Metabase - Add export query with format action #19144
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
Metabase - Add export query with format action #19144
Conversation
Add new action to export card queries with parameters in multiple formats (CSV, JSON, XLSX, API).
This implements the /query/{export-format} endpoint which accepts parameters, resolving the critical blocker mentioned in issue PipedreamHQ#18970.
Features:
- Support for csv, json, xlsx, and api export formats
- Parameters support for filtered queries
- format_rows and pivot_results options
- Follows existing Metabase component patterns
Closes PipedreamHQ#18970
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
WalkthroughAdds a new Metabase action "Export Query with Format" and its run logic, an app client method Changes
Sequence Diagram(s)sequenceDiagram
actor User
participant Action as Export Query Action
participant App as Metabase App Client
participant API as Metabase API
User->>Action: invoke with props (cardId, exportFormat, formatRows, pivotResults, parameters)
Note right of Action: parse `parameters` strings → JSON
Action->>App: exportCardQuery(cardId, exportFormat, { format_rows, pivot_results, parameters? })
App->>API: POST /card/{cardId}/query/{exportFormat} (body)
API-->>App: 200 / export response
App-->>Action: return response
Action->>User: set summary and return API response
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Pre-merge checks and finishing touches❌ Failed checks (1 inconclusive)
✅ Passed checks (4 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Tip 📝 Customizable high-level summaries are now available in beta!You can now customize how CodeRabbit generates the high-level summary in your pull requests — including its content, structure, tone, and formatting.
Example instruction:
Note: This feature is currently in beta for Pro-tier users, and pricing will be announced later. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Thank you so much for submitting this! We've added it to our backlog to review, and our team has been notified. |
|
Thanks for submitting this PR! When we review PRs, we follow the Pipedream component guidelines. If you're not familiar, here's a quick checklist:
|
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.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (4)
components/metabase/README.md(1 hunks)components/metabase/actions/export-query-with-format/export-query-with-format.mjs(1 hunks)components/metabase/metabase.app.mjs(1 hunks)components/metabase/package.json(1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2024-07-04T18:11:59.822Z
Learnt from: GTFalcao
Repo: PipedreamHQ/pipedream PR: 12731
File: components/hackerone/actions/get-members/get-members.mjs:3-28
Timestamp: 2024-07-04T18:11:59.822Z
Learning: When exporting a summary message in the `run` method of an action, ensure the message is correctly formatted. For example, in the `hackerone-get-members` action, the correct format is `Successfully retrieved ${response.data.length} members`.
Applied to files:
components/metabase/actions/export-query-with-format/export-query-with-format.mjs
🔇 Additional comments (6)
components/metabase/metabase.app.mjs (1)
143-150: LGTM!The
exportCardQuerymethod follows the same pattern asrunCardQueryabove it. The implementation correctly constructs the API path and delegates to the existingpostmethod.components/metabase/package.json (1)
3-3: LGTM!The minor version bump from 0.1.1 to 0.2.0 is appropriate for adding a new action, following semantic versioning conventions.
components/metabase/README.md (1)
10-11: LGTM!The documentation clearly describes the new "Export Query with Format" action and accurately lists the supported formats.
components/metabase/actions/export-query-with-format/export-query-with-format.mjs (3)
1-13: LGTM!The action metadata is well-structured with appropriate annotations. The
readOnlyHint: truecorrectly indicates this is a query/export operation.
14-65: LGTM!The prop definitions are comprehensive and well-documented. The
exportFormatoptions correctly match the Metabase API specification, and theparametersprop appropriately uses string array for JSON objects.
84-100: LGTM!The API call construction is correct with proper snake_case field names (
format_rows,pivot_results) for the Metabase API. The success message follows the established pattern for summary exports.
components/metabase/actions/export-query-with-format/export-query-with-format.mjs
Outdated
Show resolved
Hide resolved
Address CodeRabbit feedback: wrap JSON.parse in try-catch to provide clear error messages when users provide invalid JSON strings.
jcortes
left a comment
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.
Hi @AryanBagade lgtm. Ready for QA!
But in the meantime please increase the patch version of the rest of components that depends on metabase.app.mjs
components/metabase/actions/export-query-with-format/export-query-with-format.mjs
Outdated
Show resolved
Hide resolved
|
Hi everyone, all test cases are passed! Ready for release! Test reports
|
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.
Actionable comments posted: 2
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (1)
components/metabase/actions/export-query-with-format/export-query-with-format.mjs(1 hunks)
🧰 Additional context used
🧠 Learnings (2)
📚 Learning: 2024-07-04T18:11:59.822Z
Learnt from: GTFalcao
Repo: PipedreamHQ/pipedream PR: 12731
File: components/hackerone/actions/get-members/get-members.mjs:3-28
Timestamp: 2024-07-04T18:11:59.822Z
Learning: When exporting a summary message in the `run` method of an action, ensure the message is correctly formatted. For example, in the `hackerone-get-members` action, the correct format is `Successfully retrieved ${response.data.length} members`.
Applied to files:
components/metabase/actions/export-query-with-format/export-query-with-format.mjs
📚 Learning: 2025-10-20T01:01:02.970Z
Learnt from: js07
Repo: PipedreamHQ/pipedream PR: 18744
File: components/slack_v2/actions/send-large-message/send-large-message.mjs:49-64
Timestamp: 2025-10-20T01:01:02.970Z
Learning: In components/slack_v2/actions/send-large-message/send-large-message.mjs, the metadata_event_payload prop is typed as string, so the code only needs to handle string-to-JSON parsing and does not need to handle object inputs.
Applied to files:
components/metabase/actions/export-query-with-format/export-query-with-format.mjs
🔇 Additional comments (2)
components/metabase/actions/export-query-with-format/export-query-with-format.mjs (2)
14-64: LGTM!The props are well-structured with appropriate types, clear descriptions, and sensible defaults. The parameters prop includes a helpful example JSON string, and all optional props follow best practices by providing default values.
77-86: LGTM!The JSON parsing logic correctly addresses the previous review comment by wrapping
JSON.parse()in a try-catch block. The error message includes the parameter index and original error, providing clear debugging context.
components/metabase/actions/export-query-with-format/export-query-with-format.mjs
Show resolved
Hide resolved
components/metabase/actions/export-query-with-format/export-query-with-format.mjs
Show resolved
Hide resolved
|
Hi everyone, all test cases are passed! Ready for release! Test reports
|
Summary
Adds new action to export Metabase card queries with parameters in multiple formats (CSV, JSON, XLSX, API).
Implements the
/api/card/{card-id}/query/{export-format}endpoint which accepts parameters, resolving the critical blocker mentioned in #18970.Why
The current "Run Query" action uses
/api/card/{card-id}/querywhich does not accept parameters. This blocks users who need filtered/parameterized query exports.This PR adds support for the
/query/{export-format}endpoint that:Changes
exportCardQuery()method tometabase.app.mjsexport-query-with-formatTesting
Closes #18970
cc @ssowonny @jcortes
Summary by CodeRabbit
New Features
Documentation
Chores
✏️ Tip: You can customize this high-level summary in your review settings.