From 863d7cf38b30fafe6565d9f97c0dec48c4684723 Mon Sep 17 00:00:00 2001 From: Adam Curtis Date: Mon, 22 Jan 2024 18:57:44 -0500 Subject: [PATCH] feat: example of how to use flight client to pass params to influx 3.0 --- influxdb3/query.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/influxdb3/query.go b/influxdb3/query.go index 01ddf3a..a2628d6 100644 --- a/influxdb3/query.go +++ b/influxdb3/query.go @@ -75,7 +75,7 @@ func (c *Client) initializeQueryClient() error { // - A custom iterator (*QueryIterator). // - An error, if any. func (c *Client) Query(ctx context.Context, query string) (*QueryIterator, error) { - return c.QueryWithOptions(ctx, &DefaultQueryOptions, query) + return c.QueryWithOptions(ctx, &DefaultQueryOptions, query, nil) } // QueryWithOptions Query data from InfluxDB IOx with query options. @@ -87,7 +87,7 @@ func (c *Client) Query(ctx context.Context, query string) (*QueryIterator, error // Returns: // - A custom iterator (*QueryIterator) that can also be used to get raw flightsql reader. // - An error, if any. -func (c *Client) QueryWithOptions(ctx context.Context, options *QueryOptions, query string) (*QueryIterator, error) { +func (c *Client) QueryWithOptions(ctx context.Context, options *QueryOptions, query string, params map[string]interface{}) (*QueryIterator, error) { if options == nil { return nil, fmt.Errorf("options not set") } @@ -112,7 +112,9 @@ func (c *Client) QueryWithOptions(ctx context.Context, options *QueryOptions, qu "sql_query": query, "query_type": strings.ToLower(queryType.String()), } - + if params != nil { + ticketData["params"] = params; + } ticketJSON, err := json.Marshal(ticketData) if err != nil { return nil, fmt.Errorf("serialize: %s", err)