uranusjr commented on code in PR #77494:
URL: https://github.com/apache/airflow/pull/77494#discussion_r4672739541
##########
airflow-core/src/airflow/utils/db.py:
##########
@@ -1926,21 +1914,10 @@ def __str__(self) -> str:
counter = "item" if (length := len(self)) == 1 else "items"
return f"LazySelectSequence([{length} {counter}])"
- def __getstate__(self) -> Any:
- # We don't want to go to the trouble of serializing SQLAlchemy objects.
- # Converting the statement into a SQL string is the best we can get.
- # The literal_binds compile argument inlines all the values into the
SQL
- # string to simplify cross-process commuinication as much as possible.
- # Theoratically we can do the same for count(), but I think it should
be
- # performant enough to calculate only that eagerly.
- s1 = str(self._select_asc.compile(self._session.get_bind(),
compile_kwargs={"literal_binds": True}))
- s2 = str(self._select_desc.compile(self._session.get_bind(),
compile_kwargs={"literal_binds": True}))
- return (s1, s2, len(self))
-
- def __setstate__(self, state: Any) -> None:
- s1, s2, self._len = state
- self._select_asc = self._rebuild_select(text(s1))
- self._select_desc = self._rebuild_select(text(s2))
+ __hash__ = None # type: ignore[assignment] # Disable hashing.
+
+ def __reduce__(self) -> NoReturn: # Disable pickling.
Review Comment:
I don’t feel a test should be added. Whether this is pickable or not is not
particularly meaningful to users, you just can’t do what you can’t do. A test
would be worthwhile if we want to guarentee this _can_ be pickled—that would be
a feature—but not pickable is not.
--
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]