@@ -76,36 +76,11 @@ def to_df(
7676 validation_reference (optional): The validation to apply against the retrieved dataframe.
7777 timeout (optional): The query timeout if applicable.
7878 """
79- features_df = self ._to_df_internal (timeout = timeout )
80-
81- if self .on_demand_feature_views :
82- # TODO(adchia): Fix requirement to specify dependent feature views in feature_refs
83- for odfv in self .on_demand_feature_views :
84- if odfv .mode not in {"pandas" , "substrait" }:
85- raise Exception (
86- f'OnDemandFeatureView mode "{ odfv .mode } " not supported for offline processing.'
87- )
88- features_df = features_df .join (
89- odfv .get_transformed_features_df (
90- features_df ,
91- self .full_feature_names ,
92- )
93- )
94-
95- if validation_reference :
96- if not flags_helper .is_test ():
97- warnings .warn (
98- "Dataset validation is an experimental feature. "
99- "This API is unstable and it could and most probably will be changed in the future. "
100- "We do not guarantee that future changes will maintain backward compatibility." ,
101- RuntimeWarning ,
102- )
103-
104- validation_result = validation_reference .profile .validate (features_df )
105- if not validation_result .is_success :
106- raise ValidationFailed (validation_result )
107-
108- return features_df
79+ return (
80+ self .to_arrow (validation_reference = validation_reference , timeout = timeout )
81+ .to_pandas ()
82+ .reset_index (drop = True )
83+ )
10984
11085 def to_arrow (
11186 self ,
@@ -122,23 +97,20 @@ def to_arrow(
12297 validation_reference (optional): The validation to apply against the retrieved dataframe.
12398 timeout (optional): The query timeout if applicable.
12499 """
125- if not self .on_demand_feature_views and not validation_reference :
126- return self ._to_arrow_internal (timeout = timeout )
127-
128- features_df = self ._to_df_internal (timeout = timeout )
100+ features_table = self ._to_arrow_internal (timeout = timeout )
129101 if self .on_demand_feature_views :
130102 for odfv in self .on_demand_feature_views :
131- if odfv .mode not in {"pandas" , "substrait" }:
132- raise Exception (
133- f'OnDemandFeatureView mode "{ odfv .mode } " not supported for offline processing.'
134- )
135- features_df = features_df .join (
136- odfv .get_transformed_features_df (
137- features_df ,
138- self .full_feature_names ,
139- )
103+ transformed_arrow = odfv .transform_arrow (
104+ features_table , self .full_feature_names
140105 )
141106
107+ for col in transformed_arrow .column_names :
108+ if col .startswith ("__index" ):
109+ continue
110+ features_table = features_table .append_column (
111+ col , transformed_arrow [col ]
112+ )
113+
142114 if validation_reference :
143115 if not flags_helper .is_test ():
144116 warnings .warn (
@@ -148,11 +120,13 @@ def to_arrow(
148120 RuntimeWarning ,
149121 )
150122
151- validation_result = validation_reference .profile .validate (features_df )
123+ validation_result = validation_reference .profile .validate (
124+ features_table .to_pandas ()
125+ )
152126 if not validation_result .is_success :
153127 raise ValidationFailed (validation_result )
154128
155- return pyarrow . Table . from_pandas ( features_df )
129+ return features_table
156130
157131 def to_sql (self ) -> str :
158132 """
0 commit comments