Skip to content

Commit 034951a

Browse files
author
Robert Engel
committed
Add MANIFEST option to CopyCommand
1 parent 175c5a6 commit 034951a

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

redshift_sqlalchemy/dialect.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,14 +241,15 @@ def __init__(self, schema_name, table_name, data_location, access_key, secret_ke
241241
self: An instance of CopyCommand
242242
schema_name - Schema associated with the table_name
243243
table_name: The table to copy the data into
244-
data_location The Amazon S3 location from where to copy
244+
data_location The Amazon S3 location from where to copy - or a manifest file if 'manifest' option is used
245245
access_key - AWS Access Key (required)
246246
secret_key - AWS Secret Key (required)
247247
session_token - AWS STS Session Token (optional)
248248
options - Set of optional parameters to modify the COPY sql
249249
delimiter - File delimiter; defaults to ','
250250
ignore_header - Integer value of number of lines to skip at the start of each file
251251
null - Optional string value denoting what to interpret as a NULL value from the file
252+
manifest - Boolean value denoting whether data_location is a manifest file; defaults to False
252253
empty_as_null - Boolean value denoting whether to load VARCHAR fields with
253254
empty values as NULL instead of empty string; defaults to True
254255
blanks_as_null - Boolean value denoting whether to load VARCHAR fields with
@@ -275,6 +276,7 @@ def visit_copy_command(element, compiler, **kw):
275276
DELIMITER '%(delimiter)s'
276277
IGNOREHEADER %(ignore_header)s
277278
%(null)s
279+
%(manifest)s
278280
%(empty_as_null)s
279281
%(blanks_as_null)s;
280282
""" % \
@@ -287,6 +289,7 @@ def visit_copy_command(element, compiler, **kw):
287289
'null': ("NULL '%s'" % element.options.get('null')) if element.options.get('null') else '',
288290
'delimiter': element.options.get('delimiter', ','),
289291
'ignore_header': element.options.get('ignore_header', 0),
292+
'manifest': 'MANIFEST' if bool(element.options.get('manifest', False)) else '',
290293
'empty_as_null': 'EMPTYASNULL' if bool(element.options.get('empty_as_null', True)) else '',
291294
'blanks_as_null': 'BLANKSASNULL' if bool(element.options.get('blanks_as_null', True)) else ''}
292295

0 commit comments

Comments
 (0)