influxdata / influxdata/influxdb-client-python
Empty string in database becomes None value in Python
まだ誰も着手していません。
- 主要言語
- Python
- スター
- 793
- フォーク
- 186
- 平均マージ
- 3時間 2分
- マージ済み PR(30日)
- 1
説明
### 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.
コントリビューションガイド
このリポジトリのコントリビューションガイドは索引されていません
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まず、示されている Flux クエリで Python の再現コードを実行し、期待される _value の値と実際の値を比較します。query_api().query(q) が返されたレコードをどのように解析するかを追跡し、その後、空の文字列が結果内で None になるのではなく "" のまま保持されることを確認します。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- python
- 領域
- database
- issue の種類
- バグ
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 42/100