@@ -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
5354LANGUAGE plpython3u
5455AS $$
@@ -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
129131LANGUAGE plpython3u
130132AS $$
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