Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 4777c03

Browse filesBrowse files
nanohannohkuepers
andauthored
feat: Add Decimal to allowed python scalar types (#5367)
Add Decimal to allowed python scalar types Signed-off-by: hkuepers <hanno.kuepers@ratepay.com> Co-authored-by: hkuepers <hanno.kuepers@ratepay.com>
1 parent 648c53d commit 4777c03
Copy full SHA for 4777c03

File tree

Expand file treeCollapse file tree

1 file changed

+7
-2
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+7
-2
lines changed
Open diff view settings
Collapse file

‎sdk/python/feast/type_map.py‎

Copy file name to clipboardExpand all lines: sdk/python/feast/type_map.py
+7-2Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
import decimal
1516
import json
1617
import logging
1718
from collections import defaultdict
@@ -310,7 +311,11 @@ def _type_err(item, dtype):
310311
None,
311312
),
312313
ValueType.FLOAT: ("float_val", lambda x: float(x), None),
313-
ValueType.DOUBLE: ("double_val", lambda x: x, {float, np.float64, int, np.int_}),
314+
ValueType.DOUBLE: (
315+
"double_val",
316+
lambda x: x,
317+
{float, np.float64, int, np.int_, decimal.Decimal},
318+
),
314319
ValueType.STRING: ("string_val", lambda x: str(x), None),
315320
ValueType.BYTES: ("bytes_val", lambda x: x, {bytes}),
316321
ValueType.BOOL: ("bool_val", lambda x: x, {bool, np.bool_, int, np.int_}),
@@ -457,7 +462,7 @@ def _python_value_to_proto_value(
457462
if (sample == 0 or sample == 0.0) and feast_value_type != ValueType.BOOL:
458463
# Numpy convert 0 to int. However, in the feature view definition, the type of column may be a float.
459464
# So, if value is 0, type validation must pass if scalar_types are either int or float.
460-
allowed_types = {np.int64, int, np.float64, float}
465+
allowed_types = {np.int64, int, np.float64, float, decimal.Decimal}
461466
assert type(sample) in allowed_types, (
462467
f"Type `{type(sample)}` not in {allowed_types}"
463468
)

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.