You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2022/01/03 14:47:27 UTC
[GitHub] [airflow] sushi30 opened a new issue #20633: Trino hook `run` does not fail for bad query
sushi30 opened a new issue #20633:
URL: https://github.com/apache/airflow/issues/20633
### Apache Airflow Provider(s)
trino
### Versions of Apache Airflow Providers
Due to https://github.com/trinodb/trino-python-client/issues/95, trino hook does not capture error when using the `run` command.
### Apache Airflow version
2.2.2
### Operating System
Centos 7
### Deployment
Official Apache Airflow Helm Chart
### Deployment details
_No response_
### What happened
_No response_
### What you expected to happen
Trino hook should fail when query fails.
### How to reproduce
Just use the trino hook with a nonsense query like:
```sql
select aaaaa
```
### Anything else
As a workaround I implemented this custom hook:
```python
from airflow.providers.trino.hooks.trino import TrinoHook as BaseTrinoHook
class TrinoHook(BaseTrinoHook):
def run(self, hql, autocommit: bool = False, parameters: Optional[dict] = None) -> None:
"""Due to issue https://github.com/trinodb/trino-python-client/issues/95 trino-python-client does not
capture errors unless using fetchall. This hook is a workaround until this is fixed."""
sql = [hql] if isinstance(hql, str) else hql
sql = [self._strip_sql(s) for s in sql]
with closing(self.get_conn()) as conn:
if self.supports_autocommit:
self.set_autocommit(conn, autocommit)
with closing(conn.cursor()) as cur:
for sql_statement in sql:
self._run_command(cur, sql_statement, parameters)
cur.fetchone()
```
### 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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] potiuk commented on issue #20633: Trino hook `run` does not fail for bad query
Posted by GitBox <gi...@apache.org>.
potiuk commented on issue #20633:
URL: https://github.com/apache/airflow/issues/20633#issuecomment-1004189969
I guess there is nothing we can do now - we just should wait until trino will fix it. Having a workoround here - people can implement it too, so just closing this issue.
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] potiuk closed issue #20633: Trino hook `run` does not fail for bad query
Posted by GitBox <gi...@apache.org>.
potiuk closed issue #20633:
URL: https://github.com/apache/airflow/issues/20633
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org