Skip to content

Commit f64bbe2

Browse files
committed
import/export add read_timeout param
1 parent b84140e commit f64bbe2

File tree

2 files changed

+18
-9
lines changed

2 files changed

+18
-9
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.idea

aws_s3--0.0.1.sql

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ CREATE OR REPLACE FUNCTION aws_s3.table_import_from_s3 (
4949
secret_key text default null,
5050
session_token text default null,
5151
endpoint_url text default null,
52-
content_encoding text default null
52+
content_encoding text default null,
53+
read_timeout integer default 60
5354
) RETURNS int
5455
LANGUAGE plpython3u
5556
AS $$
@@ -86,6 +87,7 @@ AS $$
8687
s3 = boto3.resource(
8788
's3',
8889
region_name=region,
90+
config=boto3.session.Config(read_timeout={read_timeout}),
8991
**aws_settings
9092
)
9193

@@ -126,14 +128,15 @@ CREATE OR REPLACE FUNCTION aws_s3.table_import_from_s3(
126128
s3_info aws_commons._s3_uri_1,
127129
credentials aws_commons._aws_credentials_1,
128130
endpoint_url text default null,
129-
content_encoding text default null
131+
content_encoding text default null,
132+
read_timeout integer default 60
130133
) RETURNS INT
131134
LANGUAGE plpython3u
132135
AS $$
133136

134137
plan = plpy.prepare(
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']
138+
'SELECT aws_s3.table_import_from_s3($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12) AS num_rows',
139+
['TEXT', 'TEXT', 'TEXT', 'TEXT', 'TEXT', 'TEXT', 'TEXT', 'TEXT', 'TEXT', 'TEXT', 'TEXT', 'INTEGER']
137140
)
138141
return plan.execute(
139142
[
@@ -146,8 +149,9 @@ AS $$
146149
credentials['access_key'],
147150
credentials['secret_key'],
148151
credentials['session_token'],
149-
endpoint_url,
150-
content_encoding
152+
endpoint_url,
153+
content_encoding,
154+
read_timeout
151155
]
152156
)[0]['num_rows']
153157
$$;
@@ -162,6 +166,7 @@ CREATE OR REPLACE FUNCTION aws_s3.query_export_to_s3(
162166
session_token text default null,
163167
options text default null,
164168
endpoint_url text default null,
169+
read_timeout integer default 60,
165170
OUT rows_uploaded bigint,
166171
OUT files_uploaded bigint,
167172
OUT bytes_uploaded bigint
@@ -199,6 +204,7 @@ AS $$
199204
s3 = boto3.client(
200205
's3',
201206
region_name=region,
207+
config=boto3.session.Config(read_timeout={read_timeout}),
202208
**aws_settings
203209
)
204210

@@ -233,15 +239,16 @@ CREATE OR REPLACE FUNCTION aws_s3.query_export_to_s3(
233239
credentials aws_commons._aws_credentials_1 default null,
234240
options text default null,
235241
endpoint_url text default null,
242+
read_timeout integer default 60,
236243
OUT rows_uploaded bigint,
237244
OUT files_uploaded bigint,
238245
OUT bytes_uploaded bigint
239246
) RETURNS SETOF RECORD
240247
LANGUAGE plpython3u
241248
AS $$
242249
plan = plpy.prepare(
243-
'SELECT * FROM aws_s3.query_export_to_s3($1, $2, $3, $4, $5, $6, $7, $8, $9)',
244-
['TEXT', 'TEXT', 'TEXT', 'TEXT', 'TEXT', 'TEXT', 'TEXT', 'TEXT', 'TEXT']
250+
'SELECT * FROM aws_s3.query_export_to_s3($1, $2, $3, $4, $5, $6, $7, $8, $9, $10)',
251+
['TEXT', 'TEXT', 'TEXT', 'TEXT', 'TEXT', 'TEXT', 'TEXT', 'TEXT', 'TEXT', 'INTEGER']
245252
)
246253
return plan.execute(
247254
[
@@ -253,7 +260,8 @@ AS $$
253260
credentials.get('secret_key') if credentials else None,
254261
credentials.get('session_token') if credentials else None,
255262
options,
256-
endpoint_url
263+
endpoint_url,
264+
read_timeout
257265
]
258266
)
259267
$$;

0 commit comments

Comments
 (0)