Skip to content

fix: Serialize UUID and TimeUuid entity keys - #7032

Open
MohammadHijjawi97 wants to merge 1 commit into
feast-dev:masterfrom
MohammadHijjawi97:fix-uuid-entity-key-serialization
Open

MohammadHijjawi97 wants to merge 1 commit into
feast-dev:masterfrom
MohammadHijjawi97:fix-uuid-entity-key-serialization

Conversation

@MohammadHijjawi97

Copy link
Copy Markdown
Contributor

What this PR does / why we need it:

An entity whose join key is a Uuid or TimeUuid can be applied, but materializing its feature view fails, because _serialize_val in key_encoding_utils.py only handles string, bytes, int32, int64 and unix timestamp values. The features never reach the online store, so they cannot be served. This affects every online store that builds its keys with serialize_entity_key (SQLite, Redis, DynamoDB, ...).

Reproduction (local provider, FileSource, SQLite online store):

session = Entity(name="session", join_keys=["session_id"], value_type=ValueType.UUID)
fv = FeatureView(
    name="fv",
    entities=[session],
    schema=[Field(name="session_id", dtype=Uuid), Field(name="score", dtype=Float32)],
    source=FileSource(path="s.parquet", timestamp_field="event_timestamp"),
    ttl=timedelta(days=1),
)
store.apply([session, fv])
store.materialize(now - timedelta(days=1), now)
store.get_online_features(
    features=["fv:score"], entity_rows=[{"session_id": u1}, {"session_id": str(u2)}]
).to_dict()

Before:

  File ".../feast/infra/online_stores/sqlite.py", line 332, in online_write_batch
    entity_key_bin = serialize_entity_key(
  File ".../feast/infra/key_encoding_utils.py", line 181, in serialize_entity_key
    val_bytes, value_type = _serialize_val(
ValueError: Value type not supported for feast feature store: uuid_val: "8b97f8f4-af3b-40e2-9b57-d2c02d0a6687"

After:

{'session_id': [UUID('0d41a235-...'), UUID('e1f8e126-...')], 'score': [1.0, 2.0]}

(same result with a TimeUuid entity)

The fix encodes uuid_val and time_uuid_val as their UTF-8 string with the UUID / TIME_UUID value type tags, the same way string keys are encoded, and _deserialize_value decodes them back so deserialize_entity_key round-trips. Existing key types are encoded exactly as before. This covers the Python serialization path.

Which issue(s) this PR fixes:

No existing issue; found while using a UUID join key.

Checks

  • I've made sure the tests are passing.
  • My commits are signed off (git commit -s)
  • My PR title follows conventional commits format

Testing Strategy

  • Unit tests
  • Integration tests
  • Manual tests
  • Testing is not required for this change

Added test_serialize_deserialize_uuid_entity (Uuid and TimeUuid) to sdk/python/tests/unit/infra/test_key_encoding_utils.py; both cases fail without the change and pass with it (16/16 in that file). ruff check, ruff format --check and mypy on the changed module pass.

Misc

An entity whose join key is a Uuid or TimeUuid could be applied, but
materializing it failed in serialize_entity_key with "Value type not
supported for feast feature store", so its features never reached the
online store and could not be served.

Encode uuid_val and time_uuid_val as their UTF-8 string with the UUID and
TIME_UUID value type tags, and decode them back in deserialize_entity_key.

Signed-off-by: Mohammad Hijjawi <mohammad.hijjawi1997@gmail.com>
@MohammadHijjawi97
MohammadHijjawi97 requested a review from a team as a code owner October 17, 2026 23:55
@codecov-commenter

codecov-commenter commented Oct 17, 2026 •

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 75.00000% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 50.99%. Comparing base (c9b9d72) to head (d6bff50).

Files with missing lines Patch % Lines
sdk/python/feast/infra/key_encoding_utils.py 75.00% 0 Missing and 2 partials ⚠️
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.
Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #7032   +/-   ##
=======================================
  Coverage   50.98%   50.99%           
=======================================
  Files         455      455           
  Lines       56964    56972    +8     
  Branches     8313     8317    +4     
=======================================
+ Hits        29044    29053    +9     
  Misses      25935    25935           
+ Partials     1985     1984    -1     
Flag Coverage Δ
go-feature-server 30.58% <ø> (ø)
python-unit 52.45% <75.00%> (+<0.01%) ⬆️
Files with missing lines Coverage Δ
sdk/python/feast/infra/key_encoding_utils.py 80.89% <75.00%> (+1.02%) ⬆️

... and 1 file with indirect coverage changes


Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c9b9d72...d6bff50. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants