Skip to content

Commit

Permalink
Merge pull request databricks#110 from nanflasted/ych_tries_fixing_ma…
Browse files Browse the repository at this point in the history
…nifest_s3a

make manifest file path use s3a/n scheme
  • Loading branch information
jsleight authored Sep 21, 2022
2 parents a675a3c + f0d98f6 commit a51b440
Showing 1 changed file with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -319,13 +319,17 @@ private[redshift] class RedshiftWriter(
}
}
// It's possible that tempDir contains AWS access keys. We shouldn't save those credentials to
// S3, so let's first sanitize `tempdir` and make sure that it uses the s3:// scheme:
val sanitizedTempDir = Utils.fixS3Url(
Utils.removeCredentialsFromURI(URI.create(tempDir)).toString).stripSuffix("/")
// S3, so let's first sanitize `tempdir`
val sanitizedTempDir = Utils.removeCredentialsFromURI(URI.create(tempDir)).toString.stripSuffix("/")
// For file paths inside the manifest file, they are required to have s3:// scheme, so make sure
// that it is the case
val schemeFixedTempDir = Utils.fixS3Url(sanitizedTempDir).stripSuffix("/")
val manifestEntries = filesToLoad.map { file =>
s"""{"url":"$sanitizedTempDir/$file", "mandatory":true}"""
s"""{"url":"$schemeFixedTempDir/$file", "mandatory":true}"""
}
val manifest = s"""{"entries": [${manifestEntries.mkString(",\n")}]}"""
// For the path to the manifest file itself it is required to have the original s3a/s3n scheme
// so don't used the fixed URL here
val manifestPath = sanitizedTempDir + "/manifest.json"
val fsDataOut = fs.create(new Path(manifestPath))
try {
Expand Down

0 comments on commit a51b440

Please sign in to comment.