Skip to content

Commit 1d831f5

Browse files
msnidaljames-crabtree-sp
authored andcommitted
fix: Handle unknown postgres source types gracefully (feast-dev#3634)
Handle more pg types gracefully Signed-off-by: Mark Snidal <mark.snidal@gmail.com>
1 parent 5330094 commit 1d831f5

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

sdk/python/feast/type_map.py

+19-2
Original file line numberDiff line numberDiff line change
@@ -873,13 +873,26 @@ def feast_value_type_to_pa(
873873

874874

875875
def pg_type_code_to_pg_type(code: int) -> str:
876-
return {
876+
""" Map the postgres type code a Feast type string
877+
878+
Rather than raise an exception on an unknown type, we return the
879+
string representation of the type code. This way rather than raising
880+
an exception on unknown types, Feast will just skip the problem columns.
881+
882+
Note that json and jsonb are not supported but this shows up in the
883+
log as a warning. Since postgres allows custom types we return an unknown for those cases.
884+
885+
See: https://jdbc.postgresql.org/documentation/publicapi/index.html?constant-values.html
886+
"""
887+
PG_TYPE_MAP = {
877888
16: "boolean",
878889
17: "bytea",
879890
20: "bigint",
880891
21: "smallint",
881892
23: "integer",
882893
25: "text",
894+
114: "json",
895+
199: "json[]",
883896
700: "real",
884897
701: "double precision",
885898
1000: "boolean[]",
@@ -905,7 +918,11 @@ def pg_type_code_to_pg_type(code: int) -> str:
905918
1700: "numeric",
906919
2950: "uuid",
907920
2951: "uuid[]",
908-
}[code]
921+
3802: "jsonb",
922+
3807: "jsonb[]",
923+
}
924+
925+
return PG_TYPE_MAP.get(code, "unknown")
909926

910927

911928
def pg_type_code_to_arrow(code: int) -> str:

0 commit comments

Comments
 (0)