-
Notifications
You must be signed in to change notification settings - Fork 1.2k
fix: Fix STRING type handling in on-demand feature views with RequestSource #5657
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Added 'object' dtype mapping to STRING in type_map.py since pandas uses object dtype for string columns by default. Added test case to verify STRING type inputs work with RequestSource. Co-authored-by: franciscojavierarceo <[email protected]>
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 <[email protected]>
Copilot
AI
changed the title
[WIP] Fix ondemand feature view apply failure for STRING inputs
Fix STRING type handling in on-demand feature views with RequestSource
Oct 11, 2025
Copilot finished work on behalf of
franciscojavierarceo
October 11, 2025 18:34
|
@copilot unit tests are failing |
Moved object dtype special handling after array type checks to prevent intercepting numpy arrays with object dtype. Added check to exclude lists/arrays from object dtype value-based inference. This fixes unit test failures where arrays with object dtype were incorrectly mapped to STRING instead of being processed as arrays. Co-authored-by: franciscojavierarceo <[email protected]>
Copilot finished work on behalf of
franciscojavierarceo
October 12, 2025 00:04
|
@copilot unit tests are still failing |
The object dtype check was returning STRING early even when the value was an array/list, preventing the array handling logic from running. Moved the array check to the outer condition so arrays with object dtype fall through to the list/array handling code which correctly returns STRING_LIST. Co-authored-by: franciscojavierarceo <[email protected]>
Fixed in commit 4a540eb. The issue was that when |
Copilot finished work on behalf of
franciscojavierarceo
October 12, 2025 01:52
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Fixed an issue where on-demand feature views with STRING type inputs from RequestSource would fail during
apply()withValueError: Value with native type object cannot be converted into Feast value type.Root Cause
When pandas creates DataFrames with string values, it uses
objectdtype by default. Thepython_type_to_feast_value_type()function didn't handleobjectdtype, causing type inference to fail.Solution
Added intelligent handling for pandas
objectdtype intype_map.py:type_name='object'Changes
python_type_to_feast_value_type()intype_map.pywith object dtype handlingtest_on_demand_string_features()test caseTesting
✅ User's exact example
✅ Original issue example
✅ Mixed types (String and Int64)
✅ String concatenation
✅ Feature inference without schema
✅ Edge cases (int/float/None values with object dtype)
✅ Existing pd.StringDtype() functionality
✅ Numpy arrays with object dtype (with and without type_name)
✅ Lists with object items
No breaking changes - all existing code continues to work.
Original prompt
This section details on the original issue you should resolve
<issue_title>Ondemand Feature with STRING type input fails on apply</issue_title>
<issue_description>## Expected Behavior
New on demand feature view created.
Current Behavior
Attempting to apply a feature view with STRING type field fails with an exception below.
Steps to reproduce
Attempt to apply the feature view below.
Specifications
Possible Solution
Running the apply on debug mode shows that the input column is of type
objectinstead ofstring.When the column is explicitly type cast to
stringwith the line below in thetransformmethod, the apply successfully passes.df["input_1"]=df["input_1"].astype("string")One solution would be to ensure that the input source attempts to type cast to defined type and raise an exception if it cannot be type cast.</issue_description>
<agent_instructions>The user is failing to execute an on demand transform with this code example:
from feast import Field, RequestSource, on_demand_feature_view
from feast.types import String
import pandas as pd
Define a request data source for request-time features
input_request = RequestSource(
name="vals_to_add",
schema=[
Field(name="val_to_add", dtype=String),
Field(name="val_to_add_2", dtype=String),
],
)
Use input data and feature view features to create new features in Pandas mode
@on_demand_feature_view.on_demand_feature_view(
sources=[input_request],
schema=[
Field(name="conv_rate_plus_val1", dtype=String),
Field(name="conv_rate_plus_val2", dtype=String),
],
mode="pandas",
)
def transformed_conv_rate(features_df: pd.DataFrame) -> pd.DataFrame:
df = pd.DataFrame()
df["conv_rate_plus_val1"] = features_df["val_to_add"]
df["conv_rate_plus_val2"] = features_df["val_to_add_2"]
return df
if name == "main":
STORE.apply([input_request, transformed_conv_rate])
Please review the on demand transformation code when doing this and add a test to test_on_demand_feature_view.py to ensure this issue doesn't appear again.</agent_instructions>
Comments on the Issue (you are @copilot in this section)
@franciscojavierarceo did you try following this example:https://docs.feast.dev/reference/beta-on-demand-feature-view#example-1-on-demand-transformation-on-read-using-pandas-mode
Also, you have an extra
on_demand_feature_viewafter the decorator.Fixes #5641
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.