Skip to content

Commit b9ad729

Browse files
Improve object dtype handling with value-based type inference
Enhanced the fix to check actual value types when type_name='object'. This prevents incorrect type inference for mixed-type object columns while still fixing the STRING type issue. Falls back to STRING when value is None or unknown type. Co-authored-by: franciscojavierarceo <4163062+franciscojavierarceo@users.noreply.github.com>
1 parent 7f131c9 commit b9ad729

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

sdk/python/feast/type_map.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,6 @@ def python_type_to_feast_value_type(
144144
"int": ValueType.INT64,
145145
"str": ValueType.STRING,
146146
"string": ValueType.STRING, # pandas.StringDtype
147-
"object": ValueType.STRING, # pandas often uses object dtype for strings
148147
"float": ValueType.DOUBLE,
149148
"bytes": ValueType.BYTES,
150149
"float64": ValueType.DOUBLE,
@@ -170,6 +169,15 @@ def python_type_to_feast_value_type(
170169
"category": ValueType.STRING,
171170
}
172171

172+
# Special handling for pandas 'object' dtype - infer from actual value type
173+
if type_name == "object":
174+
if value is not None:
175+
actual_type = type(value).__name__.lower()
176+
if actual_type in type_map:
177+
return type_map[actual_type]
178+
# Default to STRING for object dtype (pandas commonly uses object for strings)
179+
return ValueType.STRING
180+
173181
if type_name in type_map:
174182
return type_map[type_name]
175183

0 commit comments

Comments
 (0)