Taragolis commented on code in PR #38160:
URL: https://github.com/apache/airflow/pull/38160#discussion_r1525382366


##########
airflow/migrations/versions/0137_2_9_0_change_taskinstance_priority_weight_type.py:
##########
@@ -0,0 +1,48 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+"""change taskinstance priority weight type
+
+Revision ID: 263b514b6e30
+Revises: ab34f260b71c
+Create Date: 2024-03-14 22:45:45.481394
+
+"""
+
+import sqlalchemy as sa
+from alembic import op
+
+
+# revision identifiers, used by Alembic.
+revision = '263b514b6e30'
+down_revision = 'ab34f260b71c'
+branch_labels = None
+depends_on = None
+airflow_version = '2.9.0'
+
+
+def upgrade():
+    """Apply change taskinstance priority weight type"""
+    with op.batch_alter_table("task_instance") as batch_op:
+        batch_op.alter_column("priority_weight", existing_type=sa.INTEGER(), 
type_=sa.Float())
+
+
+def downgrade():
+    """Unapply change taskinstance priority weight type"""
+    with op.batch_alter_table("task_instance") as batch_op:
+        batch_op.alter_column("priority_weight", existing_type=sa.Float(), 
type_=sa.INTEGER())

Review Comment:
   In case of overflow int32 (MySQL/Postgres) and presumably int64 in SQLite it 
will raise an error
   
   Example of Postgres error
   ```console
     File 
"/usr/local/lib/python3.8/site-packages/sqlalchemy/engine/default.py", line 
736, in do_execute
       cursor.execute(statement, parameters)
   sqlalchemy.exc.DataError: (psycopg2.errors.NumericValueOutOfRange) integer 
out of range
   
   [SQL: ALTER TABLE task_instance ALTER COLUMN priority_weight TYPE INTEGER ]
   (Background on this error at: https://sqlalche.me/e/14/9h9h)
   ```



-- 
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]

Reply via email to