Skip to content

Conversation

@AryanBagade
Copy link
Contributor

@AryanBagade AryanBagade commented Nov 20, 2025

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}/query which does not accept parameters. This blocks users who need filtered/parameterized query exports.

This PR adds support for the /query/{export-format} endpoint that:

  • ✅ Accepts parameters (the critical feature!)
  • ✅ Supports csv, json, xlsx, api formats
  • ✅ Enables format_rows and pivot_results options

Changes

  • Added exportCardQuery() method to metabase.app.mjs
  • Created new action: export-query-with-format
  • Updated README and bumped version to 0.2.0

Testing

  • ✅ Follows existing Metabase component patterns
  • ✅ Version bumped correctly
  • ✅ Implements exact Metabase API spec

Closes #18970
cc @ssowonny @jcortes

Summary by CodeRabbit

  • New Features

    • Added "Export Query with Format" action to export queries in CSV, JSON, XLSX, or API formats with options for row formatting, pivoting, and custom parameters.
    • Client now supports performing card query exports in the selected format.
  • Documentation

    • README updated to document the new export action and usage.
  • Chores

    • Package version bumped to 0.2.0 and several action versions incremented to 0.0.4.

✏️ Tip: You can customize this high-level summary in your review settings.

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
@vercel
Copy link

vercel bot commented Nov 20, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Preview Comments Updated (UTC)
pipedream-docs-redirect-do-not-edit Ignored Ignored Nov 21, 2025 7:10am

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 20, 2025

Walkthrough

Adds a new Metabase action "Export Query with Format" and its run logic, an app client method exportCardQuery that POSTs to /card/{cardId}/query/{exportFormat}, updates the README to list the new action, bumps @pipedream/metabase to 0.2.0, and increments several action versions from 0.0.3 → 0.0.4.

Changes

Cohort / File(s) Summary
Documentation Update
components/metabase/README.md
Inserted "Export Query with Format" into the actions list, positioned before "Get Dashboard".
New Action Implementation
components/metabase/actions/export-query-with-format/export-query-with-format.mjs
Added metabase-export-query-with-format action with props (app, cardId, exportFormat, formatRows, pivotResults, parameters) and run({ $ }) that parses parameters (strings → JSON) and calls app.exportCardQuery with payload including format_rows, pivot_results, and optional parameters.
App Client Enhancement
components/metabase/metabase.app.mjs
Added exportCardQuery({ cardId, exportFormat, ...args } = {}) which POSTs to /card/{cardId}/query/{exportFormat} with provided args.
Package Version
components/metabase/package.json
Bumped package version from 0.1.10.2.0.
Action Version Bumps
components/metabase/actions/create-dashboard/create-dashboard.mjs, components/metabase/actions/get-dashboard/get-dashboard.mjs, components/metabase/actions/get-database/get-database.mjs, components/metabase/actions/run-query/run-query.mjs
Incremented exported action version fields from 0.0.30.0.4. No logic 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
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Inspect parameter string → JSON parsing and error handling in export-query-with-format.mjs.
  • Verify payload field names (format_rows, pivot_results, parameters) match Metabase API expectations.
  • Confirm exportCardQuery URL construction and POST behavior in metabase.app.mjs.
  • Quick check: README insertion and package version bump consistency.

Pre-merge checks and finishing touches

❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Out of Scope Changes check ❓ Inconclusive Version bumps for existing actions (create-dashboard, get-dashboard, get-database, run-query) and package appear outside the scope of the core feature implementation requested in #18970. Clarify whether version bumps for all existing actions should have been included or if only the new action and main component version bump were required.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Metabase - Add export query with format action' clearly and concisely describes the main change: adding a new export query action to the Metabase component.
Description check ✅ Passed The PR description is comprehensive and well-structured, covering summary, rationale, changes made, testing notes, and issue resolution, though it exceeds the minimal template.
Linked Issues check ✅ Passed The PR implements all requirements from #18970: adds the export-query-with-format action wrapping /api/card/{card-id}/query/{export-format}, accepts parameters, supports csv/json/xlsx/api formats, and resolves the critical blocker.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

  • Provide your own instructions using the high_level_summary_instructions setting.
  • Format the summary however you like (bullet lists, tables, multi-section layouts, contributor stats, etc.).
  • Use high_level_summary_in_walkthrough to move the summary from the description to the walkthrough section.

Example instruction:

"Divide the high-level summary into five sections:

  1. 📝 Description — Summarize the main change in 50–60 words, explaining what was done.
  2. 📓 References — List relevant issues, discussions, documentation, or related PRs.
  3. 📦 Dependencies & Requirements — Mention any new/updated dependencies, environment variable changes, or configuration updates.
  4. 📊 Contributor Summary — Include a Markdown table showing contributions:
    | Contributor | Lines Added | Lines Removed | Files Changed |
  5. ✔️ Additional Notes — Add any extra reviewer context.
    Keep each section concise (under 200 words) and use bullet or numbered lists for clarity."

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@pipedream-component-development
Copy link
Collaborator

Thank you so much for submitting this! We've added it to our backlog to review, and our team has been notified.

@pipedream-component-development
Copy link
Collaborator

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:

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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

📥 Commits

Reviewing files that changed from the base of the PR and between 6f9a2f5 and b8ae9b5.

📒 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 exportCardQuery method follows the same pattern as runCardQuery above it. The implementation correctly constructs the API path and delegates to the existing post method.

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: true correctly indicates this is a query/export operation.


14-65: LGTM!

The prop definitions are comprehensive and well-documented. The exportFormat options correctly match the Metabase API specification, and the parameters prop 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.

Address CodeRabbit feedback: wrap JSON.parse in try-catch to provide clear error messages when users provide invalid JSON strings.
Copy link
Collaborator

@jcortes jcortes left a 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

@jcortes jcortes moved this from Ready for PR Review to Ready for QA in Component (Source and Action) Backlog Nov 20, 2025
@AryanBagade AryanBagade requested a review from jcortes November 20, 2025 20:18
@vunguyenhung vunguyenhung moved this from Ready for QA to Ready for Release in Component (Source and Action) Backlog Nov 21, 2025
@vunguyenhung
Copy link
Collaborator

Hi everyone, all test cases are passed! Ready for release!

Test reports

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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

📥 Commits

Reviewing files that changed from the base of the PR and between 45ee533 and c38f1bb.

📒 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.

@vunguyenhung
Copy link
Collaborator

Hi everyone, all test cases are passed! Ready for release!

Test reports

@jcortes jcortes merged commit f891b6f into PipedreamHQ:master Nov 21, 2025
9 of 10 checks passed
@github-project-automation github-project-automation bot moved this from Ready for Release to Done in Component (Source and Action) Backlog Nov 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

User submitted Submitted by a user

Development

Successfully merging this pull request may close these issues.

[ACTION] Metabase /query/{export-format} API

5 participants