Skip to content

Flux Script parse failed because of missing value with pivot function #628

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

Closed
supernet29 opened this issue Jan 11, 2024 · 1 comment
Closed
Labels
bug Something isn't working duplicate This issue or pull request already exists
Milestone

Comments

@supernet29
Copy link

Specifications

  • Client Version: 1.39.0
  • InfluxDB Version: v2.7.4
  • Platform: Mac OS Sonoma

Code sample to reproduce problem

param = {
        "_start": start_dt,
        "_stop": start_dt + delta
}
query = f''' from(bucket: "{bucket}") |> range(start: _start, stop: _stop) |> filter(fn: (r) => r["_measurement"] == "pet_raw_signal") |> filter(fn: (r) => r["pet_name"] == "{pet_name}" or r["pet_id"] == "{pet_id}") |> pivot(rowKey:["_time"], columnKey: ["_field"], valueColumn: "_value")'''
result = query_api.query_data_frame(query, params=param)

when output file contains empty value(N/A) it makes exception.

Expected behavior

I want to get dataframe like pivot table

Actual behavior

It produce following Exception

Traceback (most recent call last):
  File "/Users/woochankim/Project/AI/download_sensor_data/main.py", line 35, in <module>
    result = query_api.query_data_frame(query, params=param)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/woochankim/Project/AI/download_sensor_data/.venv/lib/python3.11/site-packages/influxdb_client/client/query_api.py", line 254, in query_data_frame
    return self._to_data_frames(_generator)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/woochankim/Project/AI/download_sensor_data/.venv/lib/python3.11/site-packages/influxdb_client/client/_base.py", line 318, in _to_data_frames
    _dataFrames = list(_generator)
                  ^^^^^^^^^^^^^^^^
  File "/Users/woochankim/Project/AI/download_sensor_data/.venv/lib/python3.11/site-packages/influxdb_client/client/flux_csv_parser.py", line 115, in generator
    for val in parser._parse_flux_response():
  File "/Users/woochankim/Project/AI/download_sensor_data/.venv/lib/python3.11/site-packages/influxdb_client/client/flux_csv_parser.py", line 126, in _parse_flux_response
    for val in self._parse_flux_response_row(metadata, csv):
  File "/Users/woochankim/Project/AI/download_sensor_data/.venv/lib/python3.11/site-packages/influxdb_client/client/flux_csv_parser.py", line 228, in _parse_flux_response_row
    flux_record = self.parse_record(metadata.table_index - 1, metadata.table, csv)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/woochankim/Project/AI/download_sensor_data/.venv/lib/python3.11/site-packages/influxdb_client/client/flux_csv_parser.py", line 265, in parse_record
    record.values[column_name] = self._to_value(str_val, fluxColumn)
                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/woochankim/Project/AI/download_sensor_data/.venv/lib/python3.11/site-packages/influxdb_client/client/flux_csv_parser.py", line 277, in _to_value
    return self._to_value(np.nan, column)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/woochankim/Project/AI/download_sensor_data/.venv/lib/python3.11/site-packages/influxdb_client/client/flux_csv_parser.py", line 288, in _to_value
    return int(str_val)
           ^^^^^^^^^^^^
ValueError: cannot convert float NaN to integer

Additional info

No response

@supernet29 supernet29 added the bug Something isn't working label Jan 11, 2024
@bednar bednar added the duplicate This issue or pull request already exists label Jan 12, 2024
@bednar
Copy link
Contributor

bednar commented Jan 12, 2024

This is duplicate of #621

@bednar bednar closed this as completed Jan 12, 2024
@bednar bednar added this to the 1.40.0 milestone Jan 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

2 participants