uranusjr commented on code in PR #28907:
URL: https://github.com/apache/airflow/pull/28907#discussion_r1070960445
##########
airflow/jobs/scheduler_job.py:
##########
@@ -1632,7 +1633,9 @@ def _orphan_unreferenced_datasets(self, session: Session
= NEW_SESSION) -> None:
func.count(TaskOutletDatasetReference.dag_id) == 0,
)
)
+ .all()
Review Comment:
This may be a bit resource-intensive. We could do this instead:
```python
def set_orphaned(dataset: DatasetModel) -> int:
self.log.info("Orphaning unreferenced dataset '%s'", dataset.uri)
dataset.is_orphaned = expression.true()
return 1
updated_count = sum(set_orphaned(dataset) for dataset in
orphaned_dataset_query)
Stats.gauge("dataset.orphaned", updated_count)
```
--
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]