Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Handle unknown postgres source types gracefully #3634

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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