hussein-awala commented on issue #56561:
URL: https://github.com/apache/airflow/issues/56561#issuecomment-3393129334

   I did some debugging and here is what I found. The XCom value lose the key 
orders in the DB:
   ```sql
   select * from xcom where task_id='create' and key='return_value';
   
   dag_run_id | task_id | map_index |     key      | dag_id |                  
run_id                  |          value           |           timestamp        
   
   
------------+---------+-----------+--------------+--------+------------------------------------------+--------------------------+-------------------------------
             8 | create  |        -1 | return_value | d1     | 
manual__2025-10-11T09:43:25.379548+00:00 | {"A": 3, "B": 2, "C": 1} | 
2025-10-11 09:43:26.917442+00
   (1 row)
   ```
   
   Why?
   It's because we store the value as a `JSON` for all the DBs except for 
PostgreSQL where we use `JSONB`:
   ```python
   value = Column(JSON().with_variant(postgresql.JSONB, "postgresql"))
   ```
   
   - `JSON` keeps insertion order of keys (the exact string representation) — 
slower to query, faster to insert.
   - `JSONB` reorders keys arbitrarily and removes duplicates during storage — 
faster to query, slower to insert.


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