Skip to content

Commit e2813cb

Browse files
authored
Make search attribute type more lenient when parsing (#1332)
1 parent 5779a29 commit e2813cb

1 file changed

Lines changed: 10 additions & 7 deletions

File tree

temporalio/common.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -378,19 +378,22 @@ def for_keyword_list(name: str) -> SearchAttributeKey[Sequence[str]]:
378378

379379
@staticmethod
380380
def _from_metadata_type(name: str, metadata_type: str) -> SearchAttributeKey | None:
381-
if metadata_type == "Text":
381+
# The type metadata is usually in PascalCase (e.g. "KeywordList")
382+
# but in rare cases may be in SCREAMING_SNAKE_CASE (e.g.
383+
# "INDEXED_VALUE_TYPE_KEYWORD_LIST").
384+
if metadata_type in ("Text", "INDEXED_VALUE_TYPE_TEXT"):
382385
return SearchAttributeKey.for_text(name)
383-
elif metadata_type == "Keyword":
386+
elif metadata_type in ("Keyword", "INDEXED_VALUE_TYPE_KEYWORD"):
384387
return SearchAttributeKey.for_keyword(name)
385-
elif metadata_type == "Int":
388+
elif metadata_type in ("Int", "INDEXED_VALUE_TYPE_INT"):
386389
return SearchAttributeKey.for_int(name)
387-
elif metadata_type == "Double":
390+
elif metadata_type in ("Double", "INDEXED_VALUE_TYPE_DOUBLE"):
388391
return SearchAttributeKey.for_float(name)
389-
elif metadata_type == "Bool":
392+
elif metadata_type in ("Bool", "INDEXED_VALUE_TYPE_BOOL"):
390393
return SearchAttributeKey.for_bool(name)
391-
elif metadata_type == "Datetime":
394+
elif metadata_type in ("Datetime", "INDEXED_VALUE_TYPE_DATETIME"):
392395
return SearchAttributeKey.for_datetime(name)
393-
elif metadata_type == "KeywordList":
396+
elif metadata_type in ("KeywordList", "INDEXED_VALUE_TYPE_KEYWORD_LIST"):
394397
return SearchAttributeKey.for_keyword_list(name)
395398
return None
396399

0 commit comments

Comments
 (0)