|
12 | 12 | # See the License for the specific language governing permissions and |
13 | 13 | # limitations under the License. |
14 | 14 |
|
| 15 | +import decimal |
15 | 16 | import json |
16 | 17 | import logging |
17 | 18 | from collections import defaultdict |
@@ -310,7 +311,11 @@ def _type_err(item, dtype): |
310 | 311 | None, |
311 | 312 | ), |
312 | 313 | 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 | + ), |
314 | 319 | ValueType.STRING: ("string_val", lambda x: str(x), None), |
315 | 320 | ValueType.BYTES: ("bytes_val", lambda x: x, {bytes}), |
316 | 321 | ValueType.BOOL: ("bool_val", lambda x: x, {bool, np.bool_, int, np.int_}), |
@@ -457,7 +462,7 @@ def _python_value_to_proto_value( |
457 | 462 | if (sample == 0 or sample == 0.0) and feast_value_type != ValueType.BOOL: |
458 | 463 | # Numpy convert 0 to int. However, in the feature view definition, the type of column may be a float. |
459 | 464 | # 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} |
461 | 466 | assert type(sample) in allowed_types, ( |
462 | 467 | f"Type `{type(sample)}` not in {allowed_types}" |
463 | 468 | ) |
|
0 commit comments