uranusjr commented on a change in pull request #21658:
URL: https://github.com/apache/airflow/pull/21658#discussion_r809737949
##########
File path: airflow/models/pool.py
##########
@@ -84,6 +84,18 @@ def get_default_pool(session: Session = NEW_SESSION):
"""
return Pool.get_pool(Pool.DEFAULT_POOL_NAME, session=session)
+ @staticmethod
+ @provide_session
+ def is_default_pool(id: str, session: Session = NEW_SESSION):
+ """
+ Check id if is the default_pool.
+
+ :param id: pool id
+ :param session: SQLAlchemy ORM Session
+ :return: True if id is default_pool, otherwise False
+ """
+ return session.query(Pool).filter(Pool.id == id, Pool.pool ==
Pool.DEFAULT_POOL_NAME).count() > 0
Review comment:
Better to use `func.count()` instead; `Query.count()` generates a
subquery and can be less efficient (depending on the database backend).
--
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]