Skip to content

Commit a7c6440

Browse files
committed
Handle all-empty tags
1 parent c6334f8 commit a7c6440

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

influxdb/_dataframe_client.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,10 @@ def _convert_dataframe_to_lines(self,
291291

292292
# join tags, but leave out None values
293293
tags = tag_df.apply(
294-
lambda r: ',' + ','.join(r.dropna()), axis=1)
294+
lambda r: ','.join(r.dropna()), axis=1)
295+
296+
# prepend comma
297+
tags = tags.apply(lambda v: ',' + v if v else '')
295298

296299
del tag_df
297300
else:

influxdb/tests/dataframe_client_test.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,8 +206,9 @@ def test_write_points_from_dataframe_with_tag_escaped(self):
206206
['red,green', "2", 2, r'cold\fire'], # comma, backslash
207207
['some', "2", 2, ''], # skip empty
208208
['some', "2", 2, None], # skip None
209+
['', "2", 2, None], # all tags empty
209210
],
210-
index=pd.period_range(now, freq='H', periods=4),
211+
index=pd.period_range(now, freq='H', periods=5),
211212
columns=["tag_one", "column_one", "column_two", "tag_three"]
212213
)
213214

@@ -224,6 +225,9 @@ def test_write_points_from_dataframe_with_tag_escaped(self):
224225
b"foo,tag_one=some "
225226
b"column_one=\"2\",column_two=2i "
226227
b"10800000000000\n"
228+
b"foo "
229+
b"column_one=\"2\",column_two=2i "
230+
b"14400000000000\n"
227231
)
228232

229233
with requests_mock.Mocker() as m:

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy