diff --git a/CHANGELOG.md b/CHANGELOG.md index 84320133530..05069d551fb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ 1. [19219](https://github.com/influxdata/influxdb/pull/19219): List buckets via the API now supports after (ID) parameter as an alternative to offset. 1. [19390](https://github.com/influxdata/influxdb/pull/19390): Record last success and failure run times in the Task 1. [19402](https://github.com/influxdata/influxdb/pull/19402): Inject Task's LatestSuccess Timestamp In Flux Extern +1. [19433](https://github.com/influxdata/influxdb/pull/19433): Add option to dump raw query results in CLI ### Bug Fixes diff --git a/cmd/influx/query.go b/cmd/influx/query.go index c2b8b1e56f4..6e3b6f4bdd7 100644 --- a/cmd/influx/query.go +++ b/cmd/influx/query.go @@ -23,6 +23,7 @@ import ( var queryFlags struct { org organization file string + raw bool } func cmdQuery(f *globalFlags, opts genericCLIOpts) *cobra.Command { @@ -34,6 +35,7 @@ func cmdQuery(f *globalFlags, opts genericCLIOpts) *cobra.Command { f.registerFlags(cmd) queryFlags.org.register(cmd, true) cmd.Flags().StringVarP(&queryFlags.file, "file", "f", "", "Path to Flux query file") + cmd.Flags().BoolVarP(&queryFlags.raw, "raw", "r", false, "Display raw query results") return cmd } @@ -123,6 +125,11 @@ func fluxQueryF(cmd *cobra.Command, args []string) error { return err } + if queryFlags.raw { + io.Copy(os.Stdout, resp.Body) + return nil + } + dec := csv.NewMultiResultDecoder(csv.ResultDecoderConfig{}) results, err := dec.Decode(resp.Body) if err != nil { @@ -141,6 +148,8 @@ func fluxQueryF(cmd *cobra.Command, args []string) error { return err } } + // It is safe and appropriate to call Release multiple times and must be + // called before checking the error on the next line. results.Release() return results.Err() }