Skip to content

Commit

Permalink
fix: Handle unknown postgres source types gracefully (feast-dev#3634)
Browse files Browse the repository at this point in the history
Handle more pg types gracefully

Signed-off-by: Mark Snidal <mark.snidal@gmail.com>
  • Loading branch information
msnidal committed Sep 5, 2023
1 parent 0b3fa13 commit d7041f4
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions sdk/python/feast/type_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -873,13 +873,26 @@ def feast_value_type_to_pa(


def pg_type_code_to_pg_type(code: int) -> str:
return {
""" Map the postgres type code a Feast type string
Rather than raise an exception on an unknown type, we return the
string representation of the type code. This way rather than raising
an exception on unknown types, Feast will just skip the problem columns.
Note that json and jsonb are not supported but this shows up in the
log as a warning. Since postgres allows custom types we return an unknown for those cases.
See: https://jdbc.postgresql.org/documentation/publicapi/index.html?constant-values.html
"""
PG_TYPE_MAP = {
16: "boolean",
17: "bytea",
20: "bigint",
21: "smallint",
23: "integer",
25: "text",
114: "json",
199: "json[]",
700: "real",
701: "double precision",
1000: "boolean[]",
Expand All @@ -905,7 +918,11 @@ def pg_type_code_to_pg_type(code: int) -> str:
1700: "numeric",
2950: "uuid",
2951: "uuid[]",
}[code]
3802: "jsonb",
3807: "jsonb[]",
}

return PG_TYPE_MAP.get(code, "unknown")


def pg_type_code_to_arrow(code: int) -> str:
Expand Down

0 comments on commit d7041f4

Please sign in to comment.