uranusjr commented on code in PR #34418:
URL: https://github.com/apache/airflow/pull/34418#discussion_r1360237642
##########
airflow/datasets/manager.py:
##########
@@ -44,6 +45,13 @@ class DatasetManager(LoggingMixin):
def __init__(self, **kwargs):
super().__init__(**kwargs)
+ def create_datasets(self, dataset_models: list[DatasetModel], session:
Session) -> None:
+ """Create new datasets."""
+ for dataset_model in dataset_models:
+ session.add(dataset_model)
+ self.notify_dataset_created(dataset=Dataset(uri=dataset_model.uri,
extra=dataset_model.extra))
+ session.flush() # this is required to ensure each dataset has its PK
loaded
Review Comment:
This called the hook before the database is flushed (i.e. before the rows
can actually appear in the database), while the changed hook is called after
flushing. I feel this should be more consistent.
--
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]