Skip to content

Commit af20fe4

Browse files
raashish1601haoxu0
andauthored
fix: Convert PdfBytes values to protos like ImageBytes (#6968)
PDF_BYTES was missing from PYTHON_SCALAR_VALUE_TYPE_TO_PROTO_VALUE, so python_values_to_proto_values raised "Unsupported data type" for a PdfBytes field, and a feature view with one could not be materialized or written to the online store. Signed-off-by: Raashish Aggarwal <[email protected]> Co-authored-by: Hao Xu <[email protected]>
1 parent 20bc993 commit af20fe4

2 files changed

Lines changed: 10 additions & 0 deletions

File tree

‎sdk/python/feast/type_map.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -705,6 +705,7 @@ def _type_err(item, dtype):
705705
),
706706
ValueType.STRING: ("string_val", lambda x: str(x), None),
707707
ValueType.BYTES: ("bytes_val", lambda x: x, {bytes}),
708+
ValueType.PDF_BYTES: ("bytes_val", lambda x: x, {bytes}),
708709
ValueType.IMAGE_BYTES: ("bytes_val", lambda x: x, {bytes}),
709710
ValueType.BOOL: ("bool_val", lambda x: x, {bool, np.bool_, int, np.int_}),
710711
ValueType.UUID: ("uuid_val", lambda x: str(x), {str, uuid_module.UUID}),

‎sdk/python/tests/unit/test_type_map.py‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,15 @@ def test_python_values_to_proto_values_bytes_to_list(values, value_type, expecte
166166
assert converted == expected
167167

168168

169+
@pytest.mark.parametrize(
170+
"value_type", [ValueType.BYTES, ValueType.PDF_BYTES, ValueType.IMAGE_BYTES]
171+
)
172+
def test_python_values_to_proto_values_binary(value_type):
173+
protos = python_values_to_proto_values([b"%PDF-1.3", None], value_type)
174+
assert feast_value_type_to_python_type(protos[0]) == b"%PDF-1.3"
175+
assert feast_value_type_to_python_type(protos[1]) is None
176+
177+
169178
def test_python_values_to_proto_values_bytes_to_list_not_supported():
170179
with pytest.raises(TypeError):
171180
_ = python_values_to_proto_values([b"[]"], ValueType.BYTES_LIST)

0 commit comments

Comments
 (0)