Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature qubole hook support headers #15615

Merged
merged 4 commits into from
May 4, 2021
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions airflow/providers/qubole/CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,15 @@
Changelog
---------

1.0.3
.....

Features
~~~~~~~~

* ``Feature add support for include_headers in get_results (#15598)``


1.0.2
.....

Expand Down
6 changes: 4 additions & 2 deletions airflow/providers/qubole/hooks/qubole.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,8 @@ def kill(self, ti):
self.cmd.cancel()

# pylint: disable=consider-using-with
def get_results(self, ti=None, fp=None, inline: bool = True, delim=None, fetch: bool = True) -> str:
def get_results(self, ti=None, fp=None, inline: bool = True, delim=None, fetch: bool = True,
include_headers: bool = False) -> str:
"""
Get results (or just s3 locations) of a command from Qubole and save into a file

Expand All @@ -225,7 +226,8 @@ def get_results(self, ti=None, fp=None, inline: bool = True, delim=None, fetch:
cmd_id = ti.xcom_pull(key="qbol_cmd_id", task_ids=self.task_id)
self.cmd = self.cls.find(cmd_id)

self.cmd.get_results(fp, inline, delim, fetch) # type: ignore[attr-defined]
self.cmd.get_results(fp, inline, delim, fetch,
arguments=[include_headers]) # type: ignore[attr-defined]
fp.flush()
fp.close()
return fp.name
Expand Down
2 changes: 1 addition & 1 deletion airflow/providers/qubole/hooks/qubole_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def get_query_results(self) -> Optional[str]:
cmd_id = self.cmd.id
self.log.info("command id: %d", cmd_id)
query_result_buffer = StringIO()
self.cmd.get_results(fp=query_result_buffer, inline=True, delim=COL_DELIM)
self.cmd.get_results(fp=query_result_buffer, inline=True, delim=COL_DELIM, arguments=[True])
query_result = query_result_buffer.getvalue()
query_result_buffer.close()
return query_result
Expand Down
5 changes: 3 additions & 2 deletions airflow/providers/qubole/operators/qubole.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,9 +250,10 @@ def on_kill(self, ti=None) -> None:
else:
self.get_hook().kill(ti)

def get_results(self, ti=None, fp=None, inline: bool = True, delim=None, fetch: bool = True) -> str:
def get_results(self, ti=None, fp=None, inline: bool = True, delim=None, fetch: bool = True,
include_headers: bool = False) -> str:
"""get_results from Qubole"""
return self.get_hook().get_results(ti, fp, inline, delim, fetch)
return self.get_hook().get_results(ti, fp, inline, delim, fetch, include_headers)

def get_log(self, ti) -> None:
"""get_log from Qubole"""
Expand Down
1 change: 1 addition & 0 deletions airflow/providers/qubole/provider.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ description: |
`Qubole <https://www.qubole.com/>`__

versions:
- 1.0.3
- 1.0.2
- 1.0.1
- 1.0.0
Expand Down