Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,19 @@ It may be useful to have some <tt>GRANT</tt> commands or similar run here when l
table, the changes will be reverted and the backup table restored if post actions fail.</p>
</td>
</tr>
<tr>
<td><tt>extracopyoptions</tt></td>
<td>No</td>
<td>No default</td>
<td>
<p>A list extra options to append to the Redshift <tt>COPY</tt> command when loading data, e.g. <tt>TRUNCATECOLUMNS</tt>
or <TT>MAXERROR n</tt> (see the <a href="http://docs.aws.amazon.com/redshift/latest/dg/r_COPY.html#r_COPY-syntax-overview-optional-parameters">Redshift docs</a>
for other options).</p>

<p>Note that since these options are appended to the end of the <tt>COPY</tt> command, only options that make sense
at the end of the command can be used, but that should cover most possible use cases.</p>
</td>
</tr>
</table>

## Additional configuration options
Expand Down
6 changes: 6 additions & 0 deletions src/main/scala/com/databricks/spark/redshift/Parameters.scala
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,12 @@ private[redshift] object Parameters {
*/
def useStagingTable: Boolean = parameters("usestagingtable").toBoolean

/**
* Extra options to pass to the Redshift COPY command (e.g. "MAXERROR 100").
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pass -> append

*
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

extra blank line

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed on merge.

*/
def extraCopyOptions: String = parameters.get("extracopyoptions").getOrElse("")

/**
* List of semi-colon separated SQL statements to run after successful write operations.
* This can be useful for running GRANT operations to make your new tables readable to other
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ private[redshift] class RedshiftWriter(
val credsString: String = AWSCredentialsUtils.getRedshiftCredentialsString(creds)
val fixedUrl = Utils.fixS3Url(manifestUrl)
s"COPY ${params.table.get} FROM '$fixedUrl' CREDENTIALS '$credsString' FORMAT AS " +
"AVRO 'auto' DATEFORMAT 'YYYY-MM-DD HH:MI:SS' manifest"
"AVRO 'auto' DATEFORMAT 'YYYY-MM-DD HH:MI:SS' manifest ${params.extraCopyOptions}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whoops, just realized that this isn't going to be interpolated properly due to a missing s at the start of this string. Will hotfix now. Missed this because the integration tests didn't run for this third-party PR :(

}

/**
Expand Down