Skip to content

feat(sheets): support Connected Sheets (BigQuery data sources) #938

Description

@ryo-touch

I run several reporting spreadsheets wired to BigQuery via Connected Sheets. Keeping the underlying SQL in sync and forcing a refresh from a script (cron / CI / an agent) currently requires opening the Sheets UI by hand — gog can't touch the data source side of a spreadsheet at all.

The gap

None of the ~35 sheets subcommands touch DataSource, BigQueryDataSourceSpec, or data execution status, and nothing in the docs mentions it either.

It's not just "no write path" — read is barely there either:

  • Spreadsheet has top-level dataSources[] and dataSourceSchedules[] fields (per the Sheets API reference), but SheetsMetadataCmd's Fields(...) mask only requests spreadsheetId,title,locale,timeZone,sheetsdataSources is silently dropped.
  • The only way to even see a connected sheet's dataSourceId today is an unfiltered gog sheets raw <id> dump. There's no structured list, and no way to inspect dataExecutionStatus to tell whether a refresh succeeded, failed, or is still running.
  • There's no command to create a data source, change its query/table, delete it, or force a refresh — so any Connected Sheet has to be built and maintained by hand in the browser.

What already exists to build on

The underlying Sheets API v4 supports the full lifecycle via spreadsheets.batchUpdate:

  • AddDataSourceRequest — attach a new BigQuery data source (custom SQL via BigQueryQuerySpec, or a native table via BigQueryTableSpec) and create the linked DATA_SOURCE sheet
  • UpdateDataSourceRequest — change an existing data source's spec
  • DeleteDataSourceRequest — remove a data source and its linked sheet
  • RefreshDataSourceRequest — force/queue a re-execution of the data source's query

All of these types already exist in google.golang.org/api/sheets/v4, the SDK version gogcli is already pinned to (v0.286.0) — this is missing CLI surface, not an SDK gap.

Proposed CLI surface

gog sheets datasource list <spreadsheetId>
gog sheets datasource add <spreadsheetId> --project <gcpProjectId> --query <sql>
gog sheets datasource add <spreadsheetId> --project <gcpProjectId> --table-project <p> --dataset <d> --table <t>
gog sheets datasource refresh <spreadsheetId> <dataSourceId> [--force]
gog sheets datasource delete <spreadsheetId> <dataSourceId>

Note this needs a new OAuth scope (https://www.googleapis.com/auth/bigquery.readonly) added alongside the existing spreadsheets/drive scopes for the sheets service — existing users would need to re-consent.

Ref: spreadsheets.batchUpdateAddDataSourceRequest / UpdateDataSourceRequest / DeleteDataSourceRequest / RefreshDataSourceRequest; Spreadsheet.dataSources[] / DataSource / BigQueryDataSourceSpec resources.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Low-risk cleanup, docs, polish, ergonomics, or speculative feature.clawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.clawsweeper:needs-product-decisionClawSweeper marked this issue as needing a product or behavior decision.clawsweeper:needs-security-reviewClawSweeper marked this issue as needing security-sensitive review.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.enhancementNew feature or requestimpact:auth-providerThis issue is about auth, provider routing, model choice, or SecretRef resolution.issue-rating: 🌊 off-meta tidepoolIssue quality rating does not apply to this item.no-staleExempts this issue from stale automation.

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions