tirkarthi opened a new pull request, #39918:
URL: https://github.com/apache/airflow/pull/39918
closes: #39527
related: #39527
This PR is like POC of the approach. The main point is to return the
renderer information for the template field to UI and let react syntax
highlighter module use the info to apply appropriate language syntax
highlighting. There are four changes
1. To get the renderers the task needs to be retrieved from dagbag which in
turn needs the existing session attached to be passed to get_dag or else the
new session created will commit and cause the one attached to task_instance
during serialization to become stale.
2. Earlier the rendered_fields will return only the value and now it will
return {"value": value, "renderer": renderer} which though defined as a
dictionary without structure might break scripts using it.
3. Since configuration.query.query which is also a rendered field previously
it was not returned in API but visible in the legacy page. Such nested paths
are also now returned in the API.
4. Rendered template fields should be rendered as it is and not converted to
camelcase which is also fixed here by excluding nested keys when
rendered_fields key is present in response.
Thoughts welcome on the change and possible approaches.
Before PR :
```
"rendered_fields": {
"configuration": {
"query": {
"query": "INSERT INTO `mylong_table_name`\n (id,\n
name,\n age)\nSELECT id,\n name,\n age\nFROM
users;"
}
},
"project_id": 1
},
```
With PR :
```
"rendered_fields": {
"configuration": {
"renderer": "json",
"value": {
"query": {
"query": "INSERT INTO `mylong_table_name`\n (id,\n
name,\n age)\nSELECT id,\n name,\n age\nFROM
users;"
}
}
},
"configuration.query.query": {
"renderer": "sql",
"value": "INSERT INTO `mylong_table_name`\n (id,\n
name,\n age)\nSELECT id,\n name,\n age\nFROM
users;"
},
"project_id": {
"renderer": null,
"value": 1
}
},
```
Screenshot :

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