sabz90 commented on code in PR #74182:
URL: https://github.com/apache/airflow/pull/74182#discussion_r4203765757


##########
airflow-core/src/airflow/migrations/versions/0142_3_4_0_preserve_dagrun_conf_json_text.py:
##########
@@ -0,0 +1,61 @@
+#
+# 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.
+
+"""
+Preserve DagRun.conf JSON number representation on PostgreSQL.
+
+Revision ID: a2c4e6f8091b
+Revises: 90e4d18ccadf
+Create Date: 2026-10-03 10:00:00.000000
+
+"""
+
+from __future__ import annotations
+
+from alembic import op
+from sqlalchemy.dialects import postgresql
+
+revision = "a2c4e6f8091b"
+down_revision = "90e4d18ccadf"
+branch_labels = None
+depends_on = None
+airflow_version = "3.4.0"
+
+
+def upgrade():
+    """Use textual PostgreSQL JSON instead of canonicalizing JSONB."""
+    if op.get_bind().dialect.name == "postgresql":
+        op.alter_column(
+            "dag_run",
+            "conf",
+            existing_type=postgresql.JSONB(),
+            type_=postgresql.JSON(),
+            postgresql_using="conf::json",

Review Comment:
   Confirmed: `ALTER COLUMN ... TYPE json USING conf::json` rewrites the table, 
not just the catalog. In a PostgreSQL 16 probe with 50,000 rows, 
`pg_relation_filenode` changed from 16385 to 16393. I removed the migration and 
all persistence/exponent changes entirely. The focused replacement #74392 only 
optimizes task-start transport.



##########
task-sdk/src/airflow/sdk/api/datamodels/_generated.py:
##########
@@ -819,7 +819,7 @@ class DagRun(BaseModel):
     clear_number: Annotated[int | None, Field(title="Clear Number")] = 0
     run_type: DagRunType
     state: DagRunState
-    conf: Annotated[dict[str, Any] | None, Field(title="Conf")] = None
+    conf: Annotated[dict[str, Any] | str | None, Field(title="Conf")] = None

Review Comment:
   Agreed. I split the work rather than reopening this PR. #74392 addresses 
only #74025 memory amplification: it keeps the existing JSONB storage and 
transports a raw text projection through a dedicated task-start field. Exponent 
persistence remains separate in #74023/#74093, and generic large integers 
remain separate in #73712/#73783.



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