Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions python/tests/test_dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
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):
Expand Down Expand Up @@ -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)
2 changes: 2 additions & 0 deletions python/tsfile/tsfile_table_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down