You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2022/06/21 16:06:54 UTC

[GitHub] [airflow] tm-drtina opened a new pull request, #24585: Fix migration 0080_2_0_2 - Replace null values before setting column not null

tm-drtina opened a new pull request, #24585:
URL: https://github.com/apache/airflow/pull/24585

   Partially reverts change from #20962 where update to NULL values was dropped.
   Default only applies to INSERTs and UPDATEs or newly added columns (at least in postgres), so if the column contained NULLs before, the migration fails.
   
   closes: #24566 
   
   ---
   **^ Add meaningful description above**
   
   Read the **[Pull Request Guidelines](https://github.com/apache/airflow/blob/main/CONTRIBUTING.rst#pull-request-guidelines)** for more information.
   In case of fundamental code change, Airflow Improvement Proposal ([AIP](https://cwiki.apache.org/confluence/display/AIRFLOW/Airflow+Improvements+Proposals)) is needed.
   In case of a new dependency, check compliance with the [ASF 3rd Party License Policy](https://www.apache.org/legal/resolved.html#category-x).
   In case of backwards incompatible changes please leave a note in a newsfragement file, named `{pr_number}.significant.rst`, in [newsfragments](https://github.com/apache/airflow/tree/main/newsfragments).
   


-- 
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-unsubscribe@airflow.apache.org

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


[GitHub] [airflow] tm-drtina commented on a diff in pull request #24585: Fix migration 0080_2_0_2 - Replace null values before setting column not null

Posted by GitBox <gi...@apache.org>.
tm-drtina commented on code in PR #24585:
URL: https://github.com/apache/airflow/pull/24585#discussion_r903506718


##########
airflow/migrations/versions/0080_2_0_2_change_default_pool_slots_to_1.py:
##########
@@ -35,8 +35,24 @@
 airflow_version = '2.0.2'
 
 
+# Minimal required schema
+task_instance = sa.table(
+    'task_instance',
+    sa.column('pool_slots', sa.Integer),
+)
+
+
 def upgrade():
     """Change default ``pool_slots`` to ``1`` and make pool_slots not nullable"""
+    connection = op.get_bind()
+    sessionmaker = sa.orm.sessionmaker()
+    session = sessionmaker(bind=connection)
+
+    session.query(task_instance) \
+        .filter(task_instance.c.pool_slots.is_(None)) \
+        .update({task_instance.c.pool_slots: 1}, synchronize_session=False)
+    session.commit()

Review Comment:
   Updated in https://github.com/apache/airflow/pull/24585/commits/f7091f70290196d0f6f7622b056dc831209e891d
   (and also rebased to latest main, so CI is happy)



-- 
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-unsubscribe@airflow.apache.org

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


[GitHub] [airflow] potiuk commented on pull request #24585: Fix migration 0080_2_0_2 - Replace null values before setting column not null

Posted by GitBox <gi...@apache.org>.
potiuk commented on PR #24585:
URL: https://github.com/apache/airflow/pull/24585#issuecomment-1164208123

   I re-run to rebuild because we updated big set of dependency changes yesterday (FAB 4.1.1) and second build failed due to constraints there.


-- 
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-unsubscribe@airflow.apache.org

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


[GitHub] [airflow] uranusjr commented on pull request #24585: Fix migration 0080_2_0_2 - Replace null values before setting column not null

Posted by GitBox <gi...@apache.org>.
uranusjr commented on PR #24585:
URL: https://github.com/apache/airflow/pull/24585#issuecomment-1163897270

   It’s not you, GitHub was having issues.


-- 
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-unsubscribe@airflow.apache.org

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


[GitHub] [airflow] tm-drtina commented on pull request #24585: Fix migration 0080_2_0_2 - Replace null values before setting column not null

Posted by GitBox <gi...@apache.org>.
tm-drtina commented on PR #24585:
URL: https://github.com/apache/airflow/pull/24585#issuecomment-1163069595

   Maybe I misunderstood the message, but I though I had to rebase the PR. Anyway the pull of python image failed due to unauthenticated access.
   > error pulling image configuration: unauthorized: unauthenticated: User cannot be authenticated with the token provided.
   > There was an error pulling the image 3.7. Failing.
   > There was an error when pulling CI image: Image Python 3.7


-- 
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-unsubscribe@airflow.apache.org

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


[GitHub] [airflow] uranusjr commented on a diff in pull request #24585: Fix migration 0080_2_0_2 - Replace null values before setting column not null

Posted by GitBox <gi...@apache.org>.
uranusjr commented on code in PR #24585:
URL: https://github.com/apache/airflow/pull/24585#discussion_r903409776


##########
airflow/migrations/versions/0080_2_0_2_change_default_pool_slots_to_1.py:
##########
@@ -35,8 +35,24 @@
 airflow_version = '2.0.2'
 
 
+# Minimal required schema
+task_instance = sa.table(
+    'task_instance',
+    sa.column('pool_slots', sa.Integer),
+)
+
+
 def upgrade():
     """Change default ``pool_slots`` to ``1`` and make pool_slots not nullable"""
+    connection = op.get_bind()
+    sessionmaker = sa.orm.sessionmaker()
+    session = sessionmaker(bind=connection)
+
+    session.query(task_instance) \
+        .filter(task_instance.c.pool_slots.is_(None)) \
+        .update({task_instance.c.pool_slots: 1}, synchronize_session=False)
+    session.commit()

Review Comment:
   It’s much easier to just write SQL here
   
   ```suggestion
       op.get_bind("UPDATE task_instance SET pool_slots = 1 WHERE pool_slots IS NULL")
   ```



-- 
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-unsubscribe@airflow.apache.org

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


[GitHub] [airflow] uranusjr commented on a diff in pull request #24585: Fix migration 0080_2_0_2 - Replace null values before setting column not null

Posted by GitBox <gi...@apache.org>.
uranusjr commented on code in PR #24585:
URL: https://github.com/apache/airflow/pull/24585#discussion_r903501192


##########
airflow/migrations/versions/0080_2_0_2_change_default_pool_slots_to_1.py:
##########
@@ -35,8 +35,24 @@
 airflow_version = '2.0.2'
 
 
+# Minimal required schema
+task_instance = sa.table(
+    'task_instance',
+    sa.column('pool_slots', sa.Integer),
+)
+
+
 def upgrade():
     """Change default ``pool_slots`` to ``1`` and make pool_slots not nullable"""
+    connection = op.get_bind()
+    sessionmaker = sa.orm.sessionmaker()
+    session = sessionmaker(bind=connection)
+
+    session.query(task_instance) \
+        .filter(task_instance.c.pool_slots.is_(None)) \
+        .update({task_instance.c.pool_slots: 1}, synchronize_session=False)
+    session.commit()

Review Comment:
   Oh yeah it’s `execute`, sorry for the typo.



-- 
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-unsubscribe@airflow.apache.org

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


[GitHub] [airflow] github-actions[bot] commented on pull request #24585: Fix migration 0080_2_0_2 - Replace null values before setting column not null

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on PR #24585:
URL: https://github.com/apache/airflow/pull/24585#issuecomment-1162867812

   The PR most likely needs to run full matrix of tests because it modifies parts of the core of Airflow. However, committers might decide to merge it quickly and take the risk. If they don't merge it quickly - please rebase it to the latest main at your convenience, or amend the last commit of the PR, and push it with --force-with-lease.


-- 
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-unsubscribe@airflow.apache.org

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


[GitHub] [airflow] boring-cyborg[bot] commented on pull request #24585: Fix migration 0080_2_0_2 - Replace null values before setting column not null

Posted by GitBox <gi...@apache.org>.
boring-cyborg[bot] commented on PR #24585:
URL: https://github.com/apache/airflow/pull/24585#issuecomment-1161960004

   Congratulations on your first Pull Request and welcome to the Apache Airflow community! If you have any issues or are unsure about any anything please check our Contribution Guide (https://github.com/apache/airflow/blob/main/CONTRIBUTING.rst)
   Here are some useful points:
   - Pay attention to the quality of your code (flake8, mypy and type annotations). Our [pre-commits]( https://github.com/apache/airflow/blob/main/STATIC_CODE_CHECKS.rst#prerequisites-for-pre-commit-hooks) will help you with that.
   - In case of a new feature add useful documentation (in docstrings or in `docs/` directory). Adding a new operator? Check this short [guide](https://github.com/apache/airflow/blob/main/docs/apache-airflow/howto/custom-operator.rst) Consider adding an example DAG that shows how users should use it.
   - Consider using [Breeze environment](https://github.com/apache/airflow/blob/main/BREEZE.rst) for testing locally, it’s a heavy docker but it ships with a working Airflow and a lot of integrations.
   - Be patient and persistent. It might take some time to get a review or get the final approval from Committers.
   - Please follow [ASF Code of Conduct](https://www.apache.org/foundation/policies/conduct) for all communication including (but not limited to) comments on Pull Requests, Mailing list and Slack.
   - Be sure to read the [Airflow Coding style]( https://github.com/apache/airflow/blob/main/CONTRIBUTING.rst#coding-style-and-best-practices).
   Apache Airflow is a community-driven project and together we are making it better 🚀.
   In case of doubts contact the developers at:
   Mailing List: dev@airflow.apache.org
   Slack: https://s.apache.org/airflow-slack
   


-- 
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-unsubscribe@airflow.apache.org

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


[GitHub] [airflow] tm-drtina commented on a diff in pull request #24585: Fix migration 0080_2_0_2 - Replace null values before setting column not null

Posted by GitBox <gi...@apache.org>.
tm-drtina commented on code in PR #24585:
URL: https://github.com/apache/airflow/pull/24585#discussion_r903463995


##########
airflow/migrations/versions/0080_2_0_2_change_default_pool_slots_to_1.py:
##########
@@ -35,8 +35,24 @@
 airflow_version = '2.0.2'
 
 
+# Minimal required schema
+task_instance = sa.table(
+    'task_instance',
+    sa.column('pool_slots', sa.Integer),
+)
+
+
 def upgrade():
     """Change default ``pool_slots`` to ``1`` and make pool_slots not nullable"""
+    connection = op.get_bind()
+    sessionmaker = sa.orm.sessionmaker()
+    session = sessionmaker(bind=connection)
+
+    session.query(task_instance) \
+        .filter(task_instance.c.pool_slots.is_(None)) \
+        .update({task_instance.c.pool_slots: 1}, synchronize_session=False)
+    session.commit()

Review Comment:
   I wanted to get back to old version and don't write raw SQL, but this is probably simple enough case.
   Also I don't see `get_bind` with parameters in the docs, did you mean `execute`?
   ```suggestion
       op.execute("UPDATE task_instance SET pool_slots = 1 WHERE pool_slots IS NULL")
   ```



-- 
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-unsubscribe@airflow.apache.org

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


[GitHub] [airflow] uranusjr merged pull request #24585: Fix migration 0080_2_0_2 - Replace null values before setting column not null

Posted by GitBox <gi...@apache.org>.
uranusjr merged PR #24585:
URL: https://github.com/apache/airflow/pull/24585


-- 
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-unsubscribe@airflow.apache.org

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


[GitHub] [airflow] boring-cyborg[bot] commented on pull request #24585: Fix migration 0080_2_0_2 - Replace null values before setting column not null

Posted by GitBox <gi...@apache.org>.
boring-cyborg[bot] commented on PR #24585:
URL: https://github.com/apache/airflow/pull/24585#issuecomment-1169449720

   Awesome work, congrats on your first merged pull request!
   


-- 
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-unsubscribe@airflow.apache.org

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