FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

fix: Improve trino to feast type mapping with (real,varchar,timestamp,decimal) by cutoutsy · Pull Request #5691 · feast-dev/feast · GitHub

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (1) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,37 @@ def trino_to_feast_value_type(trino_type_as_str: str) -> ValueType:
"integer": ValueType.INT32,
"bigint": ValueType.INT64,
"double": ValueType.DOUBLE,
"decimal": ValueType.FLOAT,
"decimal32": ValueType.FLOAT,
"decimal64": ValueType.DOUBLE,
"timestamp": ValueType.UNIX_TIMESTAMP,
"char": ValueType.STRING,
"varchar": ValueType.STRING,
"boolean": ValueType.BOOL,
"real": ValueType.FLOAT,
}
return type_map[trino_type_as_str.lower()]
_trino_type_as_str: str = trino_type_as_str
trino_type_as_str = trino_type_as_str.lower()

if trino_type_as_str.startswith("decimal"):
search_precision = re.search(
Comment thread
shuchu marked this conversation as resolved.
r"^decimal\((\d+)(?>,\s?\d+)?\)$", trino_type_as_str
)
if search_precision:
precision = int(search_precision.group(1))
if precision > 32:
trino_type_as_str = "decimal64"
else:
trino_type_as_str = "decimal32"

elif trino_type_as_str.startswith("timestamp"):
trino_type_as_str = "timestamp"

elif trino_type_as_str.startswith("varchar"):
trino_type_as_str = "varchar"

if trino_type_as_str not in type_map:
raise ValueError(f"Trino type not supported by feast {_trino_type_as_str}")
return type_map[trino_type_as_str]


def pa_to_trino_value_type(pa_type_as_str: str) -> str:
Expand Down
Loading

Back | FazBrowse Home | New Git URL