atul-astronomer opened a new issue, #71271:
URL: https://github.com/apache/airflow/issues/71271
### Under which category would you file this issue?
Providers
### Apache Airflow version
3.2-7-alpha4, 3.3-2
### What happened and how to reproduce it?
```typescript
Task failed with exception
ProgrammingError: the query has 0 placeholders but 3 parameters were passed
File
"/usr/local/lib/python3.13/site-packages/airflow/sdk/execution_time/task_runner.py",
line 1287 in run
File
"/usr/local/lib/python3.13/site-packages/airflow/sdk/execution_time/task_runner.py",
line 1745 in _execute_task
File
"/usr/local/lib/python3.13/site-packages/airflow/sdk/bases/operator.py", line
443 in wrapper
File "/usr/local/lib/python3.13/site-packages/airflow/sdk/bases/sensor.py",
line 225 in execute
File "/usr/local/lib/python3.13/site-packages/airflow/sdk/bases/sensor.py",
line 205 in execute
File
"/usr/local/lib/python3.13/site-packages/airflow/providers/common/sql/sensors/sql.py",
line 101 in poke
File
"/usr/local/lib/python3.13/site-packages/airflow/providers/common/sql/hooks/sql.py",
line 678 in get_records
File
"/usr/local/lib/python3.13/site-packages/airflow/providers/common/sql/hooks/sql.py",
line 818 in run
File
"/usr/local/lib/python3.13/site-packages/airflow/providers/common/sql/hooks/sql.py",
line 867 in _run_command
File "/usr/local/lib/python3.13/site-packages/psycopg/cursor.py", line 117
in execute
```
Airflow 3.2 upgraded SQLAlchemy from 1.4 to 2.0. The Postgres hook picks its
database driver based on that SQLAlchemy version — so from 3.2 onward it uses
psycopg3 instead of psycopg2.
psycopg3 is stricter. Our DAG passes 3 parameters to a query that has no
placeholders for them:
sql="SELECT * FROM checkt WHERE state='Abia'", # no placeholders
parameters=["state", "temp", "date"], # but 3 params passed
psycopg2 ignored this; psycopg3 rejects it.
Knock-on effect: the sensor has soft_fail=True, which should make it skip.
But soft_fail only handles timeouts — a database error isn't covered, so the
task fails outright. The DAG never reaches the timeout where it would have
skipped.
Any Postgres connection will do:
from airflow.providers.common.sql.sensors.sql import SqlSensor
SqlSensor(
task_id="probe",
conn_id="my_postgres",
sql="SELECT * FROM t WHERE state='x'", # zero placeholders
parameters=["a", "b", "c"], # parameters still passed
through
soft_fail=True, poke_interval=11, timeout=33,
)
- Airflow 3.1.x (SQLAlchemy 1.4): query executes, sensor polls to timeout,
task is skipped.
- Airflow 3.2+ (SQLAlchemy 2.0): ProgrammingError on the first poke, task
fails.
### What you think should happen instead?
_No response_
### Operating System
Linux
### Deployment
None
### Apache Airflow Provider(s)
_No response_
### Versions of Apache Airflow Providers
_No response_
### Official Helm Chart version
Not Applicable
### Kubernetes Version
_No response_
### Helm Chart configuration
_No response_
### Docker Image customizations
_No response_
### Anything else?
_No response_
### 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]