Skip to content

Commit 15a4009

Browse files
authored
Fix for current postgres 12.* and s3 (chimpler#11)
Use plpython3u instead of plpythonu
1 parent 6f798c9 commit 15a4009

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

aws_s3--0.0.1.sql

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ CREATE OR REPLACE FUNCTION aws_commons.create_s3_uri(
1919
s3_key text,
2020
aws_region text
2121
) RETURNS aws_commons._s3_uri_1
22-
LANGUAGE plpythonu IMMUTABLE
22+
LANGUAGE plpython3u IMMUTABLE
2323
AS $$
2424
return (s3_bucket, s3_key, aws_region)
2525
$$;
@@ -33,7 +33,7 @@ CREATE OR REPLACE FUNCTION aws_commons.create_aws_credentials(
3333
secret_key text,
3434
session_token text
3535
) RETURNS aws_commons._aws_credentials_1
36-
LANGUAGE plpythonu IMMUTABLE
36+
LANGUAGE plpython3u IMMUTABLE
3737
AS $$
3838
return (access_key, secret_key, session_token)
3939
$$;
@@ -49,7 +49,7 @@ CREATE OR REPLACE FUNCTION aws_s3.table_import_from_s3 (
4949
secret_key text,
5050
session_token text
5151
) RETURNS int
52-
LANGUAGE plpythonu
52+
LANGUAGE plpython3u
5353
AS $$
5454
def cache_import(module_name):
5555
module_cache = SD.get('__modules__', {})
@@ -82,10 +82,10 @@ AS $$
8282
)
8383

8484
response = s3.head_object(Bucket=bucket, Key=file_path)
85-
content_encoding = response.get('ContentEncoding')
85+
content_encoding = response.get('ContentType')
8686

8787
with tempfile.NamedTemporaryFile() as fd:
88-
if content_encoding and content_encoding.lower() == 'gzip':
88+
if content_encoding and content_encoding.lower() == 'application/gzip':
8989
with tempfile.NamedTemporaryFile() as gzfd:
9090
s3.download_fileobj(bucket, file_path, gzfd)
9191
gzfd.flush()
@@ -117,7 +117,7 @@ CREATE OR REPLACE FUNCTION aws_s3.table_import_from_s3 (
117117
session_token text,
118118
endpoint_url text
119119
) RETURNS int
120-
LANGUAGE plpythonu
120+
LANGUAGE plpython3u
121121
AS $$
122122
def cache_import(module_name):
123123
module_cache = SD.get('__modules__', {})
@@ -182,7 +182,7 @@ CREATE OR REPLACE FUNCTION aws_s3.table_import_from_s3(
182182
s3_info aws_commons._s3_uri_1,
183183
credentials aws_commons._aws_credentials_1
184184
) RETURNS INT
185-
LANGUAGE plpythonu
185+
LANGUAGE plpython3u
186186
AS $$
187187
plan = plpy.prepare(
188188
'SELECT aws_s3.table_import_from_s3($1, $2, $3, $4, $5, $6, $7, $8, $9) AS num_rows',
@@ -211,7 +211,7 @@ CREATE OR REPLACE FUNCTION aws_s3.table_import_from_s3(
211211
credentials aws_commons._aws_credentials_1,
212212
endpoint_url text
213213
) RETURNS INT
214-
LANGUAGE plpythonu
214+
LANGUAGE plpython3u
215215
AS $$
216216
plan = plpy.prepare(
217217
'SELECT aws_s3.table_import_from_s3($1, $2, $3, $4, $5, $6, $7, $8, $9) AS num_rows',

0 commit comments

Comments
 (0)