Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 22, 2026

What this PR does / why we need it:

Adds Set as a feature type to store collections of unique values, eliminating the need to manually deduplicate lists or convert back from maps.

Changes

  • Protobuf: Added 8 SET type variants (INT32_SET, INT64_SET, STRING_SET, BYTES_SET, BOOL_SET, FLOAT_SET, DOUBLE_SET, UNIX_TIMESTAMP_SET) with corresponding message types. Compiled with protobuf version 4.25.1 and mypy-protobuf 3.3.0 to match CI environment requirements.
  • Python SDK:
    • New Set class in types.py following the same pattern as Array
    • Bidirectional type conversions in type_map.py with automatic deduplication
    • Added SetType union and enum values in value_type.py
  • Tests:
    • Unit tests for type creation, round-trip conversions, and duplicate removal in test_types.py and test_type_map.py
    • Comprehensive On Demand Feature View test in test_on_demand_python_transformation.py validating Set types with automatic deduplication, list-to-set conversion, and online feature retrieval
  • Docs: Updated type-system.md with set types table and usage examples

Usage

from feast.types import Set, String, Int32
from feast import Field

# Sets automatically deduplicate
Field(name="visited_pages", dtype=Set(String))
Field(name="unique_categories", dtype=Set(Int32))

# Input: {1, 2, 3, 2, 1} → Stored: {1, 2, 3}

All primitive types except Map support set variants.

Misc

Protobuf changes are backward compatible. Existing LIST and MAP types are unaffected. Generated protobuf files use protobuf 4.25.1 and mypy-protobuf 3.3.0, matching the versions specified in CI requirements to ensure consistency across environments.

Original prompt

This section details on the original issue you should resolve

<issue_title>Add set as feature type</issue_title>
<issue_description>Is your feature request related to a problem? Please describe.
Support for set features as feast feature types is missing.

Describe the solution you'd like
Add support for set type features in feast.

Describe alternatives you've considered
We have considered storing set features as list or maps but then burden is on calling client to covert back.
</issue_description>

<agent_instructions>please add this to the feast types and update the docs</agent_instructions>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 4 commits January 22, 2026 01:57
Co-authored-by: franciscojavierarceo <4163062+franciscojavierarceo@users.noreply.github.com>
Co-authored-by: franciscojavierarceo <4163062+franciscojavierarceo@users.noreply.github.com>
Co-authored-by: franciscojavierarceo <4163062+franciscojavierarceo@users.noreply.github.com>
Co-authored-by: franciscojavierarceo <4163062+franciscojavierarceo@users.noreply.github.com>
Copilot AI changed the title [WIP] Add support for set as feature type in feast feat: Add Set as feature type Jan 22, 2026
Copy link
Member

@franciscojavierarceo franciscojavierarceo left a comment

Choose a reason for hiding this comment

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

@copilot we should not update the protobuf version

Co-authored-by: franciscojavierarceo <4163062+franciscojavierarceo@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Jan 22, 2026

@copilot we should not update the protobuf version

Fixed! Reverted all generated protobuf files and recompiled with protobuf version 4.25.0 instead of 6.31.1. The set types are now properly generated without updating the protobuf version. See commit e11795d.

_ = Array(Array(String))


def test_set_feast_type():

Choose a reason for hiding this comment

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

@copilot can we add a test for it in the On Demand Feature Views test for the set type?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added comprehensive Set type test in test_on_demand_python_transformation.py. The test verifies:

  • Set types in On Demand Feature Views with both Python mode transformations
  • Automatic deduplication when creating sets from data with duplicates
  • Conversion from lists to sets (e.g., ["Boston", "Boston", "Seattle"]{"Boston", "Seattle"})
  • Online feature retrieval returning native Python sets
  • Type validation for Set[String] and Set[Int64]

See commit ba4c68e.


DESCRIPTOR: google.protobuf.descriptor.FileDescriptor

@typing_extensions.final

Choose a reason for hiding this comment

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

@copilot why do we need this typing extension?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This typing_extensions pattern was already present in the original file before my changes. The conditional import (lines 11-14) provides backward compatibility - it uses the built-in typing module for Python 3.8+ and falls back to the typing_extensions package for older versions.

The only change from my recompilation is the addition of the @typing_extensions.final decorator (line 18), which was generated by mypy-protobuf 3.5.0. This decorator marks the class as final (cannot be subclassed) for better type safety.

If this pattern is causing issues, I can investigate using a different mypy-protobuf version that doesn't add these decorators.

Choose a reason for hiding this comment

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

@copilot please revert all changes with the @typing_extensions.final decorator, it shouldn't be necessary. probably there's skew between your local development environment and the CI. Check the Makefile.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed all @typing_extensions.final decorators. The issue was using mypy-protobuf 3.5.0 instead of 3.3.0 (which matches the CI requirements). Reverted all proto files and recompiled with the correct versions: protobuf 4.25.1 and mypy-protobuf 3.3.0. The Set types are preserved and no @typing_extensions.final decorators remain. See commit 105b399.

Co-authored-by: franciscojavierarceo <4163062+franciscojavierarceo@users.noreply.github.com>
Co-authored-by: franciscojavierarceo <4163062+franciscojavierarceo@users.noreply.github.com>
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.

Add set as feature type

2 participants