Empty string in database becomes None value in Python
还没有人认领这个 Issue。
评估
调研方向
首先使用所示的 Flux 查询运行 Python 复现代码,并比较预期的 _value 值和实际的 _value 值。跟踪 query_api().query(q) 如何解析返回的记录,然后验证空字符串在结果中仍保持为 "",而不是变成 None。
由索引模型根据 Issue 内容生成。
描述
Specifications
- Client Version: 1.34.0
- InfluxDB Version: 2.6.1
- Platform: Linux
Code sample to reproduce problem
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
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.
- 主要语言
- Python
- 星标
- 792
- 派生
- 186
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 没有贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
influxdata/influxdb-client-python 的其他 Issue
-
Pandas outputs warning when calling dataframe.append in flux_csv_parser._prepare_data_frame可能已有人在做 @dave-cz 于 409 天前认领。 未关闭bug
难度 2/5 1-3 小时 新手友好度 68/100
influxdata/influxdb-client-python#613 · 7 条评论 ·
-
ApiClient.__del__ triggers shutdown-time exception in influxdb-client 1.50.0可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭bug
难度 3/5 1-2 天 新手友好度 65/100
-
难度 3/5 1-2 天 新手友好度 45/100
influxdata/influxdb-client-python#694 · 6 个 reaction ·
-
bug
难度 3/5 1-2 天 新手友好度 30/100
influxdata/influxdb-client-python#693 · 2 条评论 · 1 个 reaction ·
-
难度 4/5 3-5 天 新手友好度 35/100
查看 influxdata/influxdb-client-python 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 68/100
KalicoCrew/kalico#1012 ·
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 82/100
esphome/esphome.io#7657 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 62/100
VNG-Realisatie/gemma-zaken#2658 ·
-
难度 1/5 1 小时以内 新手友好度 75/100
维护者通常 1 天内回复
-
comp/gateway comp/plugins duplicate P3 type/bug
难度 2/5 1-3 小时 新手友好度 82/100
NousResearch/hermes-agent#137019 ·
维护者通常 1 天内回复