Skip to content

Commit babcafc

Browse files
committed
Handle pandas str dtype in COPY
1 parent a9c887d commit babcafc

2 files changed

Lines changed: 19 additions & 1 deletion

File tree

src_cpp/numpy/numpy_type.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ static NumpyNullableType convertNumpyTypeInternal(const std::string& colTypeStr)
8080
return NumpyNullableType::DATETIME_NS;
8181
}
8282
// LCOV_EXCL_STOP
83-
if (colTypeStr == "object" || colTypeStr == "string") {
83+
if (colTypeStr == "object" || colTypeStr == "string" || colTypeStr == "str") {
8484
return NumpyNullableType::OBJECT;
8585
}
8686
UNREACHABLE_CODE;

test/test_scan_pandas.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -441,6 +441,24 @@ def test_copy_from_pandas_object(conn_db_empty: ConnDB) -> None:
441441
assert result.has_next() is False
442442

443443

444+
def test_copy_from_pandas_str_dtype(conn_db_empty: ConnDB) -> None:
445+
conn, _ = conn_db_empty
446+
df = pd.DataFrame(
447+
[
448+
{"id": "a", "name": "x", "n": 1, "v": 1.5},
449+
{"id": "b", "name": "y", "n": 2, "v": None},
450+
]
451+
)
452+
conn.execute(
453+
"CREATE NODE TABLE T(id STRING PRIMARY KEY, name STRING, n INT64, v DOUBLE)"
454+
)
455+
conn.execute("COPY T FROM df")
456+
result = conn.execute("MATCH (t:T) RETURN t.id, t.name, t.n, t.v ORDER BY t.id")
457+
assert result.get_next() == ["a", "x", 1, 1.5]
458+
assert result.get_next() == ["b", "y", 2, None]
459+
assert result.has_next() is False
460+
461+
444462
def test_copy_from_pandas_object_skip(conn_db_empty: ConnDB) -> None:
445463
conn, _ = conn_db_empty
446464
df = pd.DataFrame(

0 commit comments

Comments
 (0)