@@ -48,7 +48,8 @@ CREATE OR REPLACE FUNCTION aws_s3.table_import_from_s3 (
48
48
access_key text default null ,
49
49
secret_key text default null ,
50
50
session_token text default null ,
51
- endpoint_url text default null
51
+ endpoint_url text default null ,
52
+ content_encoding text default null
52
53
) RETURNS int
53
54
LANGUAGE plpython3u
54
55
AS $$
@@ -90,10 +91,10 @@ AS $$
90
91
91
92
obj = s3 .Object (bucket, file_path)
92
93
response = obj .get ()
93
- content_encoding = response .get (' ContentEncoding' )
94
- body = response[' Body' ]
94
+ content_encoding = content_encoding or response .get (' ContentEncoding' )
95
95
user_content_encoding = response .get (' x-amz-meta-content-encoding' )
96
-
96
+ body = response[' Body' ]
97
+
97
98
with tempfile .NamedTemporaryFile () as fd:
98
99
if (content_encoding and content_encoding .lower () == ' gzip' ) or (user_content_encoding and user_content_encoding .lower () == ' gzip' ):
99
100
with gzip .GzipFile (fileobj= body) as gzipfile:
@@ -124,14 +125,15 @@ CREATE OR REPLACE FUNCTION aws_s3.table_import_from_s3(
124
125
options text ,
125
126
s3_info aws_commons ._s3_uri_1 ,
126
127
credentials aws_commons ._aws_credentials_1 ,
127
- endpoint_url text default null
128
+ endpoint_url text default null ,
129
+ content_encoding text default null
128
130
) RETURNS INT
129
131
LANGUAGE plpython3u
130
132
AS $$
131
133
132
134
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 ' ]
135
137
)
136
138
return plan .execute (
137
139
[
@@ -144,7 +146,8 @@ AS $$
144
146
credentials[' access_key' ],
145
147
credentials[' secret_key' ],
146
148
credentials[' session_token' ],
147
- endpoint_url
149
+ endpoint_url,
150
+ content_encoding
148
151
]
149
152
)[0 ][' num_rows' ]
150
153
$$;
0 commit comments