Skip to content
Open
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
4 changes: 4 additions & 0 deletions sdk/python/feast/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,8 @@ def _convert_arrow_fv_to_proto(
) -> List[Tuple[EntityKeyProto, Dict[str, ValueProto], datetime, Optional[datetime]]]:
# Avoid ChunkedArrays which guarantees `zero_copy_only` available.
if isinstance(table, pyarrow.Table):
if table.num_rows == 0:
return []
Comment on lines +434 to +435

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Add the required DCO sign-off

The commit message has no Signed-off-by: trailer, so this commit does not satisfy the repository's DCO requirement and may be rejected by the DCO check. Recreate the commit with a sign-off before merging.

AGENTS.md reference: AGENTS.md:L96-L96

Useful? React with 👍 / 👎.

table = table.to_batches()[0]

if feature_view.batch_source is None:
Expand Down Expand Up @@ -489,6 +491,8 @@ def _convert_arrow_odfv_to_proto(
) -> List[Tuple[EntityKeyProto, Dict[str, ValueProto], datetime, Optional[datetime]]]:
# Avoid ChunkedArrays which guarantees `zero_copy_only` available.
if isinstance(table, pyarrow.Table):
if table.num_rows == 0:
return []
table = table.to_batches()[0]

columns = [
Expand Down
16 changes: 15 additions & 1 deletion sdk/python/tests/unit/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,18 @@
from datetime import datetime, timezone
from unittest.mock import MagicMock

import pyarrow as pa

from feast.protos.feast.serving.ServingService_pb2 import (
FieldStatus,
GetOnlineFeaturesResponse,
)
from feast.protos.feast.types.Value_pb2 import Value as ValueProto
from feast.utils import _populate_response_from_feature_data
from feast.utils import (
_convert_arrow_fv_to_proto,
_convert_arrow_odfv_to_proto,
_populate_response_from_feature_data,
)


def _make_table(name="test_fv"):
Expand All @@ -26,6 +32,14 @@ def _make_table(name="test_fv"):
return table


def test_convert_empty_arrow_table_to_proto_returns_no_rows():
"""A zero-row Arrow Table has no record batches and is a valid empty write."""
table = pa.table({"unused": pa.array([], type=pa.string())})

assert _convert_arrow_fv_to_proto(table, MagicMock(), {}) == []
assert _convert_arrow_odfv_to_proto(table, MagicMock(), {}) == []


class TestPopulateResponseFromFeatureData:
"""Tests for _populate_response_from_feature_data function."""

Expand Down
Loading