This is an automated email from the ASF dual-hosted git repository.
jiangtian pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/tsfile.git
The following commit(s) were added to refs/heads/develop by this push:
new bd810610d Fix invalid DataFrame column name validation before
lowercasing. (#735)
bd810610d is described below
commit bd810610d5de674ccc2853da9ca36b98aa73fee9
Author: Hongzhi Gao <[email protected]>
AuthorDate: Wed Mar 4 09:36:55 2026 +0800
Fix invalid DataFrame column name validation before lowercasing. (#735)
* fix readme logo
* fix readme logo
* fix readme badge
* Fix invalid DataFrame column name validation before lowercasing
---
python/tests/test_dataframe.py | 7 +++++++
python/tsfile/tsfile_table_writer.py | 2 ++
2 files changed, 9 insertions(+)
diff --git a/python/tests/test_dataframe.py b/python/tests/test_dataframe.py
index de49bc1ca..c8c543dfb 100644
--- a/python/tests/test_dataframe.py
+++ b/python/tests/test_dataframe.py
@@ -26,6 +26,7 @@ from tsfile import ColumnSchema, TableSchema, TSDataType,
TIME_COLUMN
from tsfile import TsFileTableWriter, ColumnCategory
from tsfile import to_dataframe
from tsfile.exceptions import ColumnNotExistError, TypeMismatchError
+from tsfile.tsfile_table_writer import validate_dataframe_for_tsfile
def convert_to_nullable_types(df):
@@ -318,3 +319,9 @@ def test_write_dataframe_empty():
finally:
if os.path.exists(tsfile_path):
os.remove(tsfile_path)
+
+
+def test_validate_dataframe_none_column_name():
+ df = pd.DataFrame([[1, 2]], columns=[None, "value"])
+ with pytest.raises(ValueError, match="Column name cannot be None or
empty"):
+ validate_dataframe_for_tsfile(df)
diff --git a/python/tsfile/tsfile_table_writer.py
b/python/tsfile/tsfile_table_writer.py
index 0346fd522..499b5843f 100644
--- a/python/tsfile/tsfile_table_writer.py
+++ b/python/tsfile/tsfile_table_writer.py
@@ -34,6 +34,8 @@ def validate_dataframe_for_tsfile(df: pd.DataFrame) -> None:
seen = set()
duplicates = []
for c in columns:
+ if c is None or (isinstance(c, str) and len(c) == 0):
+ raise ValueError("Column name cannot be None or empty")
lower = c.lower()
if lower in seen:
duplicates.append(c)