Skip to content

Commit 5576e2b

Browse files
committed
Merge remote-tracking branch 'upstream/master'
2 parents fd844fa + f76192a commit 5576e2b

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

aws_s3--0.0.1.sql

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ CREATE OR REPLACE FUNCTION aws_s3.table_import_from_s3 (
4848
access_key text default null,
4949
secret_key text default null,
5050
session_token text default null,
51-
endpoint_url text default null
51+
endpoint_url text default null,
52+
content_encoding text default null
5253
) RETURNS int
5354
LANGUAGE plpython3u
5455
AS $$
@@ -90,10 +91,10 @@ AS $$
9091

9192
obj = s3.Object(bucket, file_path)
9293
response = obj.get()
93-
content_encoding = response.get('ContentEncoding')
94-
body = response['Body']
94+
content_encoding = content_encoding or response.get('ContentEncoding')
9595
user_content_encoding = response.get('x-amz-meta-content-encoding')
96-
96+
body = response['Body']
97+
9798
with tempfile.NamedTemporaryFile() as fd:
9899
if (content_encoding and content_encoding.lower() == 'gzip') or (user_content_encoding and user_content_encoding.lower() == 'gzip'):
99100
with gzip.GzipFile(fileobj=body) as gzipfile:
@@ -124,14 +125,15 @@ CREATE OR REPLACE FUNCTION aws_s3.table_import_from_s3(
124125
options text,
125126
s3_info aws_commons._s3_uri_1,
126127
credentials aws_commons._aws_credentials_1,
127-
endpoint_url text default null
128+
endpoint_url text default null,
129+
content_encoding text default null
128130
) RETURNS INT
129131
LANGUAGE plpython3u
130132
AS $$
131133

132134
plan = plpy.prepare(
133-
'SELECT aws_s3.table_import_from_s3($1, $2, $3, $4, $5, $6, $7, $8, $9) AS num_rows',
134-
['TEXT', 'TEXT', 'TEXT', 'TEXT', 'TEXT', 'TEXT', 'TEXT', 'TEXT', 'TEXT', 'TEXT']
135+
'SELECT aws_s3.table_import_from_s3($1, $2, $3, $4, $5, $6, $7, $8, $9, $10) AS num_rows',
136+
['TEXT', 'TEXT', 'TEXT', 'TEXT', 'TEXT', 'TEXT', 'TEXT', 'TEXT', 'TEXT', 'TEXT', 'TEXT']
135137
)
136138
return plan.execute(
137139
[
@@ -144,7 +146,8 @@ AS $$
144146
credentials['access_key'],
145147
credentials['secret_key'],
146148
credentials['session_token'],
147-
endpoint_url
149+
endpoint_url,
150+
content_encoding
148151
]
149152
)[0]['num_rows']
150153
$$;

0 commit comments

Comments
 (0)