Closed zenzxjul closed 10 months ago
The issue arose from inpecting Quix's new InfluxDB 2.0 connector that uses query_data_frame()
.
int(np.nan) causes the error. For temporary fix, replace the function.
import numpy as np
import influxdb_client.client.flux_csv_parser
from influxdb_client.client.util.date_utils import get_date_helper
from influxdb_client.client.flux_csv_parser import FluxSerializationMode
class FluxCsvParser(influxdb_client.client.flux_csv_parser.FluxCsvParser):
def _to_value(self, str_val, column):
if str_val == '' or str_val is None:
default_value = column.default_value
if default_value == '' or default_value is None:
if self._serialization_mode is FluxSerializationMode.dataFrame:
return self._to_value(np.nan, column)
return None
return self._to_value(default_value, column)
if "string" == column.data_type:
return str_val
if "boolean" == column.data_type:
return "true" == str_val
if "unsignedLong" == column.data_type or "long" == column.data_type:
if str_val is np.nan:
return int(0)
return int(str_val)
if "double" == column.data_type:
if str_val is np.nan:
return float(0)
return float(str_val)
if "base64Binary" == column.data_type:
return base64.b64decode(str_val)
if "dateTime:RFC3339" == column.data_type or "dateTime:RFC3339Nano" == column.data_type:
return get_date_helper().parse_date(str_val)
if "duration" == column.data_type:
# todo better type ?
return int(str_val)
influxdb_client.client.flux_csv_parser.FluxCsvParser._to_value = FluxCsvParser._to_value
@mkmark thanks for your temp fix, we will add this to our backlog or
@mkmark, @zenzxjul is this something you would be willing to help with? All PR is welcome and we will be happy to review your submission.
Specifications
Code sample to reproduce problem
Expected behavior
Print the head of the table like:
Actual behavior
Additional info
Minimal csv data to reproduce: