使用spark to absolute path写入Google云端存储

问题描述 投票:0回答:1

我正在尝试将火花数据帧写入谷歌云存储。这个数据框有一些更新,所以我需要一个分区策略。所以我需要将它写入GCS中的确切文件。

我创建了如下火花会话

        .config("fs.gs.impl", "com.google.cloud.hadoop.fs.gcs.GoogleHadoopFileSystem")\
        .config("fs.AbstractFileSystem.gs.impl", "com.google.cloud.hadoop.fs.gcs.GoogleHadoopFS")\
        .config("fs.gs.project.id", project_id)\
        .config("fs.gs.auth.service.account.enable", "true")\
        .config("fs.gs.auth.service.account.project.id",project_id)\
        .config("fs.gs.auth.service.account.private.key.id",private_key_id)\
        .config("fs.gs.auth.service.account.private.key",private_key)\
        .config("fs.gs.auth.service.account.client.email",client_email)\
        .config("fs.gs.auth.service.account.email",client_email)\
        .config("fs.gs.auth.service.account.client.id",client_id)\
        .config("fs.gs.auth.service.account.auth.uri",auth_uri)\
        .config("fs.gs.auth.service.account.token.uri",token_uri)\
        .config("fs.gs.auth.service.account.auth.provider.x509.cert.url",auth_provider_x509_cert_url)\
        .config("fs.gs.auth.service.account.client_x509_cert_url",client_x509_cert_url)\
        .config("spark.sql.avro.compression.codec", "deflate")\
        .config("spark.sql.avro.deflate.level", "5")\
        .getOrCreate())

我正在使用GCS编写

df.write.format(file_format).save('gs://'+bucket_name+path+'/'+table_name+'/file_name.avro')

现在我看到用GCP编写的文件正在路径中

gs://bucket_name/table_name/file_name.avro/--auto指定名称 - .avro

我期待的是像hadoop一样写的文件和数据文件的最终结果

GS://bucket_name/table_name/file_name.avro

任何人都能帮我实现这个目标吗?

python apache-spark pyspark google-cloud-storage
1个回答
0
投票

它看起来像标准Spark库的限制。 Maybe this answer will help

您还可以使用Cloud Storage Connector with Apache Spark检查Spark中与Google云端存储交互的其他方式。

© www.soinside.com 2019 - 2024. All rights reserved.