Skip to content

Commit 62db435

Browse files
nikolauspschuetzntkathole
authored andcommitted
fix: Map Postgres real to FLOAT instead of DOUBLE
Postgres real is a single-precision float4 column, but pg_type_to_feast_value_type mapped real to ValueType.DOUBLE (and real[] to DOUBLE_LIST), silently widening the inferred schema to float64. The mssql, oracle, and trino type maps in the same module all map real to FLOAT; only Postgres diverged. Map real to FLOAT and real[] to FLOAT_LIST to match. Signed-off-by: Nikolaus Schuetz <nikolauspschuetz@gmail.com>
1 parent d269946 commit 62db435

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

sdk/python/feast/type_map.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2047,7 +2047,7 @@ def pg_type_to_feast_value_type(type_str: str) -> ValueType:
20472047
"bigint": ValueType.INT64,
20482048
"smallint": ValueType.INT32,
20492049
"integer": ValueType.INT32,
2050-
"real": ValueType.DOUBLE,
2050+
"real": ValueType.FLOAT,
20512051
"double precision": ValueType.DOUBLE,
20522052
"boolean[]": ValueType.BOOL_LIST,
20532053
"bytea[]": ValueType.BYTES_LIST,
@@ -2058,7 +2058,7 @@ def pg_type_to_feast_value_type(type_str: str) -> ValueType:
20582058
"text[]": ValueType.STRING_LIST,
20592059
"character[]": ValueType.STRING_LIST,
20602060
"bigint[]": ValueType.INT64_LIST,
2061-
"real[]": ValueType.DOUBLE_LIST,
2061+
"real[]": ValueType.FLOAT_LIST,
20622062
"double precision[]": ValueType.DOUBLE_LIST,
20632063
"character": ValueType.STRING,
20642064
"character varying": ValueType.STRING,

sdk/python/tests/unit/test_type_map.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -541,6 +541,11 @@ def test_pg_type_to_feast_value_type_json_array(self):
541541
assert pg_type_to_feast_value_type("json[]") == ValueType.MAP_LIST
542542
assert pg_type_to_feast_value_type("jsonb[]") == ValueType.MAP_LIST
543543

544+
def test_pg_type_to_feast_value_type_real(self):
545+
"""Postgres real is single-precision (float4), so it maps to FLOAT, not DOUBLE."""
546+
assert pg_type_to_feast_value_type("real") == ValueType.FLOAT
547+
assert pg_type_to_feast_value_type("real[]") == ValueType.FLOAT_LIST
548+
544549
def test_snowflake_variant_to_map(self):
545550
"""Test that Snowflake VARIANT/OBJECT types convert to ValueType.MAP."""
546551
assert snowflake_type_to_feast_value_type("VARIANT") == ValueType.MAP

0 commit comments

Comments
 (0)