Usiel opened a new issue, #40154:
URL: https://github.com/apache/airflow/issues/40154

   ### Apache Airflow version
   
   2.9.1
   
   ### If "Other Airflow 2 version" selected, which one?
   
   _No response_
   
   ### What happened?
   
   Took me a while to find the underlying issue for this one 😓
   
   When creating a DAG with params the ordering does not follow the insertion 
order (as promised by 
https://airflow.apache.org/docs/apache-airflow/stable/core-concepts/params.html),
 but instead params are ordered by the length of their key when MySQL is used:
   
   
![image](https://github.com/apache/airflow/assets/1842905/aabc5dc8-dcf9-4d6c-a164-dc94968a07ab)
   
   This seems to be an issue with MySQL's JSON column, which orders the keys on 
insertion. The Airflow side of things (and SQLAlchemy) does not cause any 
issues with the ordering.
   
   ### What you think should happen instead?
   
   Instead params should be shown in insertion order.
   
   ### How to reproduce
   
   1. Run Airflow with MySQL (I tested 5.7 and 8.0) and the following DAG.
   
   ```
   import datetime
   import json
   from pathlib import Path
   
   from airflow.decorators import dag, task
   from airflow.models import Param
   
   
   @dag(
       dag_id=Path(__file__).stem,
       dag_display_name="Params UI MySQL Bug",
       schedule=None,
       start_date=datetime.datetime(2022, 3, 4),
       default_args={},
       params={
           "____________first": Param(default="3."),
           "_______second": Param(default="2."),
           "________________third": Param(default="4."),
           "_______fourth": Param(default="1."),
       },
   )
   def dag():
       @task(task_display_name="Show used parameters")
       def show_params(**kwargs) -> None:
           params = kwargs["params"]
           print(f"This DAG was triggered with the following 
parameters:\n\n{json.dumps(params, indent=4)}\n")
   
       show_params()
   
   dag()
   ```
   
   2. Trigger the DAG from the UI.
   
   ### Operating System
   
   -
   
   ### Versions of Apache Airflow Providers
   
   _No response_
   
   ### Deployment
   
   Other Docker-based deployment
   
   ### Deployment details
   
   MySQL 5.7 or 8.0
   
   ### Anything else?
   
   **Workaround**: Set `compress_serialized_dags = True` to avoid usage of the 
MySQL JSON column (comes with the drawback of disabled DAG dependencies view).
   
   Maybe related to https://github.com/apache/airflow/issues/35944 (assuming 
some of the people who complained used MySQL).
   
   ### Are you willing to submit PR?
   
   - [ ] Yes I am willing to submit a PR!
   
   ### Code of Conduct
   
   - [X] I agree to follow this project's [Code of 
Conduct](https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md)
   


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