influxdata / influxdata/influxdb-client-python
Empty string in database becomes None value in Python
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- Python
- Star
- 793
- Fork
- 186
- Merge trung bình
- 3 giờ 2 phút
- Pull request đã merge (30 ngày)
- 1
Mô tả
### Specifications
* Client Version: 1.34.0
* InfluxDB Version: 2.6.1
* Platform: Linux
### Code sample to reproduce problem
```python
import influxdb_client
with influxdb_client.InfluxDBClient(
org = ...,
token = ...,
url = ...,
) as client:
q = f"""
from(bucket: ...)
//|> filter(fn: (r) => exists r._value)
//|> filter(fn: (r) => r._value != "")
|> last()
"""
res = [
record_it.values
for table_it in client.query_api().query(q)
for record_it in table_it.records
]
print(res)
```
### Expected behavior
[{'result': '_result', 'table': 0, '_time': datetime.datetime(2023, 3, 2, 18, 47, 7, 547036, tzinfo=tzutc()), '_value': ''}]
### Actual behavior
[{'result': '_result', 'table': 0, '_time': datetime.datetime(2023, 3, 2, 18, 47, 7, 547036, tzinfo=tzutc()), '_value': None}]
### Additional info
[`last()` function](https://docs.influxdata.com/flux/v0.x/stdlib/universe/last/):
> If \[`_value`\] column is null in the last record, last() returns the previous record with a non-null value.
My last record with a non-null `_value` has the empty string for `_value`.
So far, the row is correctly identified.
But by the time I read `_value` from the result returned in Python, the record does not hold the empty string `""` but `None`.
I verified that the value of `_value` is really the empty string in the database and not `None` by experimenting with filters (see commented code).
I find it more intuitive to leave the empty string as empty string in Python.
Hướng dẫn đóng góp
Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Bắt đầu bằng cách chạy bản tái hiện Python với truy vấn Flux được hiển thị và so sánh các giá trị _value mong đợi với giá trị thực tế. Theo dõi cách query_api().query(q) phân tích bản ghi được trả về, sau đó xác minh rằng một chuỗi rỗng vẫn là "" thay vì trở thành None trong kết quả.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- python
- Lĩnh vực
- database
- Loại issue
- Lỗi
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 42/100