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


##########
providers/mongo/src/airflow/providers/mongo/hooks/mongo.py:
##########
@@ -225,6 +225,39 @@ def get_collection(self, mongo_collection: str, mongo_db: 
str | None = None) ->
 
         return 
mongo_conn.get_database(mongo_db).get_collection(mongo_collection)
 
+    def create_collection(
+        self,
+        mongo_collection: str,
+        mongo_db: str | None = None,
+        create_if_exists: bool = True,
+        **create_kwargs: Any,
+    ) -> MongoCollection:
+        """
+        Create the collection (optionally a time‑series collection) and return 
it.
+
+        
https://pymongo.readthedocs.io/en/stable/api/pymongo/database.html#pymongo.database.Database.create_collection
+
+        :param mongo_collection: Name of the collection.
+        :param mongo_db: Target database; defaults to the schema in the 
connection string.
+        :param create_if_exists: If True and the collection already exists, 
return it instead of raising.
+        :param create_kwargs: Additional keyword arguments forwarded to 
``db.create_collection()``,
+                                  e.g. ``timeseries={...}``, ``capped=True``.
+        """
+        from pymongo.errors import CollectionInvalid

Review Comment:
   I think this might not be an expensive import đŸ¤”  so we probably can move it 
to the top



##########
providers/mongo/src/airflow/providers/mongo/hooks/mongo.py:
##########
@@ -225,6 +225,39 @@ def get_collection(self, mongo_collection: str, mongo_db: 
str | None = None) ->
 
         return 
mongo_conn.get_database(mongo_db).get_collection(mongo_collection)
 
+    def create_collection(
+        self,
+        mongo_collection: str,
+        mongo_db: str | None = None,
+        create_if_exists: bool = True,
+        **create_kwargs: Any,

Review Comment:
   ```suggestion
           **create_kwargs: dict[str, Any],
   ```
   
   nit



##########
providers/mongo/src/airflow/providers/mongo/hooks/mongo.py:
##########
@@ -225,6 +225,39 @@ def get_collection(self, mongo_collection: str, mongo_db: 
str | None = None) ->
 
         return 
mongo_conn.get_database(mongo_db).get_collection(mongo_collection)
 
+    def create_collection(
+        self,
+        mongo_collection: str,
+        mongo_db: str | None = None,
+        create_if_exists: bool = True,

Review Comment:
   ```suggestion
           return_if_exists: bool = True,
   ```
   
   should it be `return_if_exists` instead



-- 
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: commits-unsubscr...@airflow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to