Lee-W commented on code in PR #45028:
URL: https://github.com/apache/airflow/pull/45028#discussion_r1897131854


##########
airflow/models/asset.py:
##########
@@ -68,6 +80,22 @@ def expand_alias_to_assets(alias_name: str, session: 
Session) -> Iterable[AssetM
     return []
 
 
+def resolve_ref_to_asset(
+    *,
+    name: str | None = None,
+    uri: str | None = None,
+    session: Session,
+) -> AssetModel | None:
+    if name is None and uri is None:
+        raise TypeError("either name or uri is required")
+    stmt = select(AssetModel).where(AssetModel.active.has())
+    if name is not None:
+        stmt = stmt.where(AssetModel.name == name)
+    if uri is not None:
+        stmt = stmt.where(AssetModel.uri == uri)

Review Comment:
   Even though in the current design, it's not possible that both `name` and 
`uri` are not None, should we catch the case that both of them have value? If 
it's changed in the future and we forget to change the function here, it might 
be a bit counterintuitive to debug as the stmt just slightly assigned twice



##########
airflow/models/asset.py:
##########
@@ -68,6 +80,22 @@ def expand_alias_to_assets(alias_name: str, session: 
Session) -> Iterable[AssetM
     return []
 
 
+def resolve_ref_to_asset(
+    *,
+    name: str | None = None,
+    uri: str | None = None,
+    session: Session,
+) -> AssetModel | None:
+    if name is None and uri is None:
+        raise TypeError("either name or uri is required")

Review Comment:
   Not sure if `TypeError` fits the best 🤔 



##########
airflow/models/asset.py:
##########
@@ -68,6 +80,22 @@ def expand_alias_to_assets(alias_name: str, session: 
Session) -> Iterable[AssetM
     return []
 
 
+def resolve_ref_to_asset(
+    *,
+    name: str | None = None,
+    uri: str | None = None,
+    session: Session,
+) -> AssetModel | None:
+    if name is None and uri is None:
+        raise TypeError("either name or uri is required")

Review Comment:
   Not sure if `TypeError` fits the best 🤔 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to