Skip to content

Reports and CSV export #9827

Description

@dfliess

Hi, I might be misunderstanding how reports are meant to work, so I would like to ask before assuming anything is broken.

The reports reference has an example titled "Example: query-based report with CSV export" that uses a data: block with metrics:, together with export: format: csv:

https://docs.rilldata.com/reference/project-files/reports#examples

When I copy that example, the report parses, reconciles and schedules without any error, and the email is delivered. But the download link in the email returns 400:

{"code":3,"message":"unsupported report resolver: metrics"}

The check that rejects it seems to be here:

// Get legacy query info back from resolver because currently resolvers does not all options like include headers and also not all resolvers support exports so until then. TODO change UI to support resolver props to open report like alerts
var queryName string
var queryArgsJSON string
var ok bool
if rep.Spec.Resolver != "legacy_metrics" {
return nil, status.Errorf(codes.InvalidArgument, "unsupported report resolver: %s", rep.Spec.Resolver)

Reading around it, the export path looks older than the resolver abstraction: it rebuilds a legacy query proto from query_name and query_args_json rather than going through Resolver.ResolveExport. And of the resolvers, only sql seems to implement ResolveExport; metrics returns not implemented:

func (r *metricsResolver) ResolveExport(ctx context.Context, w io.Writer, opts *runtime.ResolverExportOptions) error {
return errors.New("not implemented")
}

Is data: meant to support export for reports, so this is a gap that has not been filled yet? Or is query: the only supported way to write a report that delivers a file, in which case the docs example may be worth updating?

Happy to help with a PR if it would be useful, though I am not sure yet whether the right shape is routing downloads through ResolveExport or something else.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions