ashb commented on code in PR #57866:
URL: https://github.com/apache/airflow/pull/57866#discussion_r2495249526


##########
airflow-core/src/airflow/migrations/versions/0049_3_0_0_remove_pickled_data_from_xcom_table.py:
##########
@@ -114,12 +114,20 @@ def upgrade():
 
     # Update the values from nan to nan string
     if dialect == "postgresql":
-        # Replace standalone NaN tokens only (not NaN inside string values)
-        # Use regex with word boundaries to match only standalone NaN tokens
+        # Replace NaN in JSON value positions (after :, , or [)
+        # This explicitly matches JSON structure, not relying on word 
boundaries
         conn.execute(
             text("""
                 UPDATE xcom
-                SET value = convert_to(regexp_replace(convert_from(value, 
'UTF8'), '\\bNaN\\b', '"nan"'), 'UTF8')
+                SET value = convert_to(
+                    regexp_replace(
+                        convert_from(value, 'UTF8'),
+                        '([:,\\[])\\s*NaN\\s*([,}\\]])',
+                        '\\1"nan"\\2',

Review Comment:
   why `nan` and not `NaN` here in the replacement?



##########
airflow-core/src/airflow/migrations/versions/0049_3_0_0_remove_pickled_data_from_xcom_table.py:
##########
@@ -114,12 +114,20 @@ def upgrade():
 
     # Update the values from nan to nan string
     if dialect == "postgresql":
-        # Replace standalone NaN tokens only (not NaN inside string values)
-        # Use regex with word boundaries to match only standalone NaN tokens
+        # Replace NaN in JSON value positions (after :, , or [)
+        # This explicitly matches JSON structure, not relying on word 
boundaries
         conn.execute(
             text("""
                 UPDATE xcom
-                SET value = convert_to(regexp_replace(convert_from(value, 
'UTF8'), '\\bNaN\\b', '"nan"'), 'UTF8')
+                SET value = convert_to(
+                    regexp_replace(
+                        convert_from(value, 'UTF8'),
+                        '([:,\\[])\\s*NaN\\s*([,}\\]])',
+                        '\\1"nan"\\2',

Review Comment:
   nit: why `nan` and not `NaN` here in the replacement?



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