【发布时间】:2020-01-24 15:24:09
【问题描述】:
我正在尝试实现与此 SO 帖子 Spark dataframe save in single file on hdfs location 相同的功能,但我的文件位于 Azure Data Lake Gen2 中,并且我在 Databricks 笔记本中使用 pyspark。
下面是我用来重命名文件的代码sn-p
from py4j.java_gateway import java_import
java_import(spark._jvm, 'org.apache.hadoop.fs.Path')
destpath = "abfss://" + contianer + "@" + storageacct + ".dfs.core.windows.net/"
fs = spark._jvm.org.apache.hadoop.fs.FileSystem.get(spark._jsc.hadoopConfiguration())
file = fs.globStatus(sc._jvm.Path(destpath+'part*'))[0].getPath().getName()
#Rename the file
我在这条线上收到IndexError: list index out of range
file = fs.globStatus(sc._jvm.Path(destpath+'part*'))[0].getPath().getName()
part* 文件确实存在于文件夹中。
1) 这是重命名 databricks(pyspark) 写入 Azure DataLakeGen2 的文件的正确方法,如果不是,我还能如何完成此操作?
【问题讨论】:
标签: apache-spark pyspark databricks azure-data-lake-gen2