粘贴 Spark Scala 脚本来检查 S3 中是否存在文件?
Glue Spark Scala Script to check if file exist in S3?
我是编写 AWS Glue 脚本的新手,我想检查是否有一种方法可以使用 Spark/Scala?
检查 S3 存储桶中是否已存在密钥、文件或路径名
谢谢!
是的,您可以使用像 this 这样的库来检查文件是否存在于 S3 中。您必须将 jar 上传到 S3,以便您可以在 Glue 作业中将其作为外部库引用。
另一种方法是像这样使用 Filesystem.Get 方法:
var sc = new SparkContext()
if(FileSystem.get(URI.create("s3://s3bucket/"), sc.hadoopConfiguration).exists(new Path("s3://s3bucket/")))
{
println("File exists")
}
我是编写 AWS Glue 脚本的新手,我想检查是否有一种方法可以使用 Spark/Scala?
检查 S3 存储桶中是否已存在密钥、文件或路径名谢谢!
是的,您可以使用像 this 这样的库来检查文件是否存在于 S3 中。您必须将 jar 上传到 S3,以便您可以在 Glue 作业中将其作为外部库引用。
另一种方法是像这样使用 Filesystem.Get 方法:
var sc = new SparkContext()
if(FileSystem.get(URI.create("s3://s3bucket/"), sc.hadoopConfiguration).exists(new Path("s3://s3bucket/")))
{
println("File exists")
}