Airflow's session.query() produces a SQL query with syntax error to get last task execution date-time

Possible short answer:

Check the syntax of the SQL query generated by Airflow's session.query() method, as it may contain an error that affects the retrieval of the last task execution date-time. You may also need to review the schema of the underlying database and the configuration of the Airflow DAG and tasks to ensure that the relevant information is accessible and valid.

Related articles:

Debugging Airflow's session.query() Syntax Errors for Last Task Execution Time
When working with Apache Airflow, it is not uncommon to encounter syntax errors when attempting to retrieve information from the metadata database using a session.query() command. One specific use-case where syntax errors can occur is when attempting to retrieve the last execution time for a particular task.

Solving Airflow's session.query() SQL Syntax Issues for Accurate Task DateTime Results
Airflow is an open-source platform to programmatically author, schedule, and monitor workflows. It is widely used to manage data pipelines, ETL jobs, and scheduled tasks in various industries. Airflow uses a SQL database to store task metadata, schedule information, and execution details. It also uses the SQLAlchemy library to interact with the database using Python code.

, $, or ^`.
Tips and Tricks for Troubleshooting Airflow's session.query() SQL Errors for Task Execution Time