-
Notifications
You must be signed in to change notification settings - Fork 185
FluxTable / FluxRecord can't handle tables with duplicate column labels #500
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hi @pgorczak, thanks for using our client. I will take a look. Regards |
Thank you @bednar :) I just clarified the expected behavior since the problem isn't about measurements but rather how the annotated CSV is parsed into Python objects |
Just for clarification, the problem is caused by Annotated CSV with duplicate column names:
from datetime import datetime
from influxdb_client import WritePrecision, InfluxDBClient, Point
from influxdb_client.client.write_api import SYNCHRONOUS
with InfluxDBClient(url="http://localhost:8086", token="my-token", org="my-org", debug=True) as client:
query_api = client.query_api()
p = Point("my_measurement") \
.tag("location", "Prague") \
.field("result", 25.3) \
.time(datetime.utcnow(), WritePrecision.MS)
write_api = client.write_api(write_options=SYNCHRONOUS)
write_api.write(bucket="my-bucket", record=p)
tables = query_api.query(
'from(bucket:"my-bucket") |> range(start: -10m) |> pivot(rowKey:["_time"], columnKey: ["_field"], valueColumn: "_value")')
for table in tables:
print(table)
for record in table.records:
# process record
print(record.values) |
Hi @pgorczak, the #502 adds possibility to access your data by If you would like to use this fixed version before regular release, please install client via:
What do you think about this solution? Regards |
Sorry for the late response @bednar . I somehow didn't get the notification. Just tried |
Specifications
Code sample to reproduce problem
Make a query for measurements that include a field called result or other labels that occur by default in the annotated CSV response header. Make the field name part of the annotated CSV response header via
pivot
. The annotated CSV returned by the API will have columns with duplicate labels.Expected behavior
Being able to access all data returned by the API as annotated CSV
Actual behavior
Flux CSV parser can't handle duplicate header names. It turns CSV rows into
FluxRecord
s whose internal values are represented as python dicts, meaning values from columns with the same label overwrite each other.See flux_csv_parser.py from line 262 for the logic that collapses a list of columns into a dict based on the column label.
Additional info
No response
The text was updated successfully, but these errors were encountered: