<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic microsoft fabric notebook - saving a parquet file in lakehouse with desired name in Data Engineering</title>
    <link>https://community.fabric.microsoft.com/t5/Data-Engineering/microsoft-fabric-notebook-saving-a-parquet-file-in-lakehouse/m-p/4278157#M5122</link>
    <description>&lt;P&gt;I'm working in Microsoft Fabric and trying to save a PySpark DataFrame as a Parquet file with a specific filename in a Lakehouse. However, the default .write.parquet() method in PySpark creates files with a part-*.parquet naming convention, which doesn’t allow me to specify a custom file name. is there a method to do this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Code in notebook -&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;output_path = f"abfss://&amp;lt;lakehouse_name&amp;gt;@&amp;lt;target_workspace_id&amp;gt;.dfs.core.windows.net/Files/metaData/parquet_metadata"&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;SPAN&gt;#Coalesce the DataFrame into a single partition and save as a single Parquet file to the target Lakehouse&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;metadata_df&lt;/SPAN&gt;&lt;SPAN&gt;.coalesce(&lt;/SPAN&gt;&lt;SPAN&gt;1&lt;/SPAN&gt;&lt;SPAN&gt;).write.mode(&lt;/SPAN&gt;&lt;SPAN&gt;"overwrite"&lt;/SPAN&gt;&lt;SPAN&gt;).parquet(&lt;/SPAN&gt;&lt;SPAN&gt;output_path&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
    <pubDate>Mon, 11 Nov 2024 11:20:37 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2024-11-11T11:20:37Z</dc:date>
    <item>
      <title>microsoft fabric notebook - saving a parquet file in lakehouse with desired name</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/microsoft-fabric-notebook-saving-a-parquet-file-in-lakehouse/m-p/4278157#M5122</link>
      <description>&lt;P&gt;I'm working in Microsoft Fabric and trying to save a PySpark DataFrame as a Parquet file with a specific filename in a Lakehouse. However, the default .write.parquet() method in PySpark creates files with a part-*.parquet naming convention, which doesn’t allow me to specify a custom file name. is there a method to do this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Code in notebook -&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;output_path = f"abfss://&amp;lt;lakehouse_name&amp;gt;@&amp;lt;target_workspace_id&amp;gt;.dfs.core.windows.net/Files/metaData/parquet_metadata"&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;SPAN&gt;#Coalesce the DataFrame into a single partition and save as a single Parquet file to the target Lakehouse&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;metadata_df&lt;/SPAN&gt;&lt;SPAN&gt;.coalesce(&lt;/SPAN&gt;&lt;SPAN&gt;1&lt;/SPAN&gt;&lt;SPAN&gt;).write.mode(&lt;/SPAN&gt;&lt;SPAN&gt;"overwrite"&lt;/SPAN&gt;&lt;SPAN&gt;).parquet(&lt;/SPAN&gt;&lt;SPAN&gt;output_path&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Mon, 11 Nov 2024 11:20:37 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/microsoft-fabric-notebook-saving-a-parquet-file-in-lakehouse/m-p/4278157#M5122</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-11-11T11:20:37Z</dc:date>
    </item>
    <item>
      <title>Re: microsoft fabric notebook - saving a parquet file in lakehouse with desired name</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/microsoft-fabric-notebook-saving-a-parquet-file-in-lakehouse/m-p/4278188#M5123</link>
      <description>&lt;P&gt;By default, pyspark outputs its parquet files in a folder structure - even if you coalesce them.&lt;BR /&gt;If you're really interested in a single .parquet file, you can use Pandas to output the file.&lt;/P&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;LI-CODE lang="python"&gt;df.toPandas().to_parquet('/lakehouse/default/Files/datafile.parquet')&lt;/LI-CODE&gt;&lt;P&gt;Usual caveats about using Pandas in notebooks apply - you'll be executing this code on a single node not clustered.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 11 Nov 2024 11:40:47 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/microsoft-fabric-notebook-saving-a-parquet-file-in-lakehouse/m-p/4278188#M5123</guid>
      <dc:creator>spencer_sa</dc:creator>
      <dc:date>2024-11-11T11:40:47Z</dc:date>
    </item>
    <item>
      <title>Re: microsoft fabric notebook - saving a parquet file in lakehouse with desired name</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/microsoft-fabric-notebook-saving-a-parquet-file-in-lakehouse/m-p/4279035#M5130</link>
      <description>&lt;P&gt;Hi&amp;nbsp;Anonymous&lt;/LI-USER&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The name of the underlying&amp;nbsp;&lt;SPAN&gt;parquet file is generated automatically. We cannot specify a custom name when saving it. I guess the prefix part ensures that the file name is always unique.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;You can click '...' next to the file name to rename the file. But if you save a dataframe to overwrite the parquet file next time, it will generate a new underlying parquet file again with another prefix part. So I think it is not meaningful to rename it unless you&amp;nbsp;&lt;SPAN&gt;will never modify this file.&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regardless of the underlying file name which has the prefix part, you can still use the root folder name, which is also the custom file name you specified, to query data from the parquet file. It acts like you are querying data from a single file without bothering how its underlying files are like.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;BR /&gt;Jing&lt;BR /&gt;&lt;EM&gt;If this post helps, please Accept it as Solution to help other members find it. Appreciate your Kudos! &lt;/EM&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Nov 2024 03:14:42 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/microsoft-fabric-notebook-saving-a-parquet-file-in-lakehouse/m-p/4279035#M5130</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-11-12T03:14:42Z</dc:date>
    </item>
    <item>
      <title>Re: microsoft fabric notebook - saving a parquet file in lakehouse with desired name</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/microsoft-fabric-notebook-saving-a-parquet-file-in-lakehouse/m-p/4279234#M5132</link>
      <description>&lt;P&gt;thanks&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="679603" data-lia-user-login="spencer_sa" class="lia-mention lia-mention-user"&gt;spencer_sa&lt;/a&gt;&amp;nbsp;, i was able to save the spark df as a pandas df and then use the abfss path to save the parquet file to target LH with desired name.&lt;/P&gt;</description>
      <pubDate>Tue, 12 Nov 2024 06:28:03 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/microsoft-fabric-notebook-saving-a-parquet-file-in-lakehouse/m-p/4279234#M5132</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-11-12T06:28:03Z</dc:date>
    </item>
  </channel>
</rss>

