<p>以下是在DataRicks上将文件从一个文件夹移动到另一个文件夹的步骤:</p>
<p><strong>将Azure Data Lake存储Gen1装载到databricks工作区:</strong></p>
<pre><code>configs = {"<prefix>.oauth2.access.token.provider.type": "ClientCredential",
"<prefix>.oauth2.client.id": "<application-id>",
"<prefix>.oauth2.credential": dbutils.secrets.get(scope = "<scope-name>", key = "<key-name-for-service-credential>"),
"<prefix>.oauth2.refresh.url": "https://login.microsoftonline.com/<directory-id>/oauth2/token"}
# Optionally, you can add <directory-name> to the source URI of your mount point.
dbutils.fs.mount(
source = "adl://<storage-resource>.azuredatalakestore.net/<directory-name>",
mount_point = "/mnt/<mount-name>",
extra_configs = configs)
</code></pre>
<p><a href="https://i.stack.imgur.com/uOXBH.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/uOXBH.png" alt="enter image description here"/></a></p>
<p><strong>参考:</strong><a href="https://docs.microsoft.com/en-us/azure/databricks/data/data-sources/azure/azure-datalake# mount-azure-data-lake-storage-gen1-resource-using-a-service-principal-and-oauth-20" rel="nofollow noreferrer">Mount Azure Data Lake Storage Gen1 resource using a service principal and OAuth 2.0</a></p>
<p><strong>使用<code>%fs</code>命令移动文件</strong></p>
<pre><code>%fs mv dbfs:/mnt/adlsgen1/test/mapreduce.txt dbfs:/mnt/adlsgen1/test1/mapreduce.txt
</code></pre>
<p><a href="https://i.stack.imgur.com/StzBV.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/StzBV.png" alt="enter image description here"/></a></p>
<p><strong>使用<code>dbutils</code>命令移动文件:</strong></p>
<pre><code>dbutils.fs.mv('dbfs:/mnt/adlsgen1/test/data.csv', 'dbfs:/mnt/adlsgen1/test1/dataone.csv')
</code></pre>
<p><a href="https://i.stack.imgur.com/O4veF.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/O4veF.png" alt="enter image description here"/></a></p>