Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Join us at FabCon Vienna from September 15-18, 2025, for the ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM. Get registered

Reply
smpa01
Super User
Super User

clusterBy does not work in dataframe API?

The following works in databricks but not in fabric. It works through DeltaTable API though. But why does it not work through dataframeAPI?

# write load at t - Create the table with clustering enabled from the start
(df.write.format("delta")
         .mode("overwrite")
         .clusterBy("id") # <--- ADD THIS LINE HERE to enable clustering at creation
         .saveAsTable(table_name) # Use the fully qualified name here for consistency
)

# AttributeError: 'DataFrameWriter' object has no attribute 'clusterBy'

DataFrameWriter Doc

 

 

 

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs
1 ACCEPTED SOLUTION
v-prasare
Community Support
Community Support

Hi @smpa01 ,

the .clusterBy() method on DataFrameWriter is not supported because Fabric uses a customized Spark runtime that limits certain APIs to ensure simplicity and compatibility within its managed environment. Unlike Databricks, which offers extended Delta Lake features directly through the PySpark DataFrameWriter, Fabric restricts clustering capabilities to SQL DDL and the DeltaTable API

 

 

Thanks,

Prashanth Are

MS Fabric community support

View solution in original post

1 REPLY 1
v-prasare
Community Support
Community Support

Hi @smpa01 ,

the .clusterBy() method on DataFrameWriter is not supported because Fabric uses a customized Spark runtime that limits certain APIs to ensure simplicity and compatibility within its managed environment. Unlike Databricks, which offers extended Delta Lake features directly through the PySpark DataFrameWriter, Fabric restricts clustering capabilities to SQL DDL and the DeltaTable API

 

 

Thanks,

Prashanth Are

MS Fabric community support

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June FBC25 Carousel

Fabric Monthly Update - June 2025

Check out the June 2025 Fabric update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.