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

[AIRFLOW-3419] S3_hook.select_key is broken on Python3 #4970

Merged
merged 1 commit into from
Mar 27, 2019
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion airflow/hooks/S3_hook.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ def select_key(self, key, bucket_name=None,
InputSerialization=input_serialization,
OutputSerialization=output_serialization)

return ''.join(event['Records']['Payload']
return ''.join(event['Records']['Payload'].decode('utf-8')
for event in response['Payload']
if 'Records' in event)

Expand Down
2 changes: 1 addition & 1 deletion tests/hooks/test_s3_hook.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ def test_read_key(self):
@mock.patch('airflow.contrib.hooks.aws_hook.AwsHook.get_client_type')
def test_select_key(self, mock_get_client_type):
mock_get_client_type.return_value.select_object_content.return_value = \
{'Payload': [{'Records': {'Payload': u'Contént'}}]}
{'Payload': [{'Records': {'Payload': b'Cont\xC3\xA9nt'}}]}
hook = S3Hook(aws_conn_id=None)
self.assertEqual(hook.select_key('my_key', 'mybucket'), u'Contént')

Expand Down