[AIRFLOW-4879] add poll_interval and schema to PrestoHook#5515
[AIRFLOW-4879] add poll_interval and schema to PrestoHook#5515eladkal wants to merge 4 commits intoapache:masterfrom eladkal:4879
Conversation
|
Travis is sad. Can you look at this? |
|
@mik-Iaj I'm aware yet I'm not sure how to fix this. can you give some pointers to why |
Adding poll_interval and schema to PrestoHook. poll_interval - int - how often to ask the Presto REST interface for a progress update, defaults to a second schema - string - defaults to ``default` https://github.com/dropbox/PyHive/blob/master/pyhive/presto.py#L75
airflow/hooks/presto_hook.py
Outdated
|
|
||
| def __init__(self, *args, **kwargs): | ||
| super().__init__(*args, **kwargs) | ||
| self.poll_interval = kwargs.pop("poll_interval") |
There was a problem hiding this comment.
Is there a reason why you need to use *args and **kwargs here? It seems to me that normal parameters will also work here.
There was a problem hiding this comment.
Yes. This can be set from the Connection, however if you want to overwrite the defaults in the constructor you must pull it from kwargs. This is how it's done in other db hooks:
https://github.com/apache/airflow/blob/master/airflow/hooks/mysql_hook.py#L48
https://github.com/apache/airflow/blob/master/airflow/hooks/mssql_hook.py#L36
Would you be more comfortable with specifying the parameters like:
https://github.com/apache/airflow/blob/master/airflow/contrib/hooks/sqoop_hook.py#L57
There was a problem hiding this comment.
@mik-laj let me know what do you think so I'll continue with the approach which will be accepted.
There was a problem hiding this comment.
I prefer a list of parameters because it provides better IDE support. args kwargs should only be used if another solution cannot be used. I would be happy if you would add type annotations too.
This reverts commit 78e500e.
|
Issues with rebasing. |
Make sure you have checked all steps below.
Jira
Description
Added support for
poll_intervalandschemaAdded docs to the hook
Future work:
passwordis deprecated https://github.com/dropbox/PyHive/blob/master/pyhive/presto.py#L100Currently Airflow bypass this by passing
passwordtorequests_kwargs.We should stop doing that and align the hook with PyHive.
Since this is a breaking change I'll do that in a separated PR later to include this in Airflow 2.0
Tests
Added tests for connection and improved existing tests (some code was taken from another unmerged PR #2206
This is the first time that I'm writing tests so go easy on me :)