8000 Unicode Decode Error when parsing DataFrame results using query_data_frame method · Issue #517 · influxdata/influxdb-client-python · GitHub
[go: up one dir, main page]

Skip to content
Unicode Decode Error when parsing DataFrame results using query_data_frame method #517
Closed
@bstanway22

Description

@bstanway22

We have a basic query which generates a table of results which is queried using the query_data_frame influxdb-client method.

Example query:

from(bucket: "mybucket") |> range(start: -300s) |> filter(fn: (r) => r["_measurement"] == "data") |> filter(fn: (r) => r["_field"] == "cost") |> filter(fn: (r) => r["app"] == "app1") |> pivot(rowKey: ["_time"], columnKey: ["_field"], valueColumn: "_value") |> group(columns: ["path", "instrument", "eng_units"]) |> top(n: 1, columns: ["_time"]) |> keep(columns: ["cost"]) |> rename(columns: {}) |> yield(name: "tuning")

In a recent update from version 1.32 to 1.33, the query_data_frame method intermittently results in a utf-8 decoding error when the 'read' method of the _StreamReaderToWithAsyncRead method is called. Comparing versions, this appears to be a recent addition to the flux_parser_csv.py module (see image attachment). Running the above query and processing the result in version 1.32 runs fine with no issues.

Here is the output of the traceback, where 'q' is the above query:

[06:59] Ben Stanway UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc2 in position 2047: unexpected end of data 2022-10-12 09:13:13,141 ERROR _handle_get_app_table(209) Unable to generate table. Traceback (most recent call last): File "/home/tango_api/tango_api_venv/lib/python3.7/site-packages/tango_api/influx/influx_connection.py", line 59, in query_async return await c.query_api().query_data_frame(q, data_frame_index=data_frame_index) File "/home/tango_api/tango_api_venv/lib/python3.7/site-packages/influxdb_client/client/query_api_async.py", line 160, in query_data_frame async for dataframe in _generator: File "/home/tango_api/tango_api_venv/lib/python3.7/site-packages/influxdb_client/client/flux_csv_parser.py", line 139, in _parse_flux_response_async async for csv in self._reader: File "/home/tango_api/tango_api_venv/lib/python3.7/site-packages/aiocsv/readers.py", line 37, in __anext__ return await self._parser.__anext__() File "aiocsv/_parser.pyx", line 216, in parser File "/home/tango_api/tango_api_venv/lib/python3.7/site-packages/influxdb_client/client/flux_csv_parser.py", line 389, in read return (await self.response.read(size)).decode(_UTF_8_encoding)

See example of the
Screenshot 2022-10-12 at 11 04 13

Thanks for taking the time to look into this and keep up the great work!

Ben.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0