<?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 Automatic Liquid Clustering and PO in Community Articles</title>
    <link>https://community.databricks.com/t5/community-articles/automatic-liquid-clustering-and-po/m-p/121313#M439</link>
    <description>&lt;P&gt;I spent some time to understand how to use automatic liquid clustering with dlt pipelines. Hope this can help you as well.&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;&lt;A href="https://docs.databricks.com/aws/en/optimizations/predictive-optimization" target="_self"&gt;Enable Predictive Optimization&amp;nbsp;&lt;/A&gt;&lt;/LI&gt;&lt;LI&gt;Use this code:&lt;/LI&gt;&lt;/OL&gt;&lt;LI-CODE lang="python"&gt;# Enabling Automatic Liquid Clustering on a new table
@dlt.table(cluster_by_auto=True)
def tbl_with_auto():
   return spark.range(5)

# Manually choosing a clustering key initially, followed by automatic clustering
@dlt.table(cluster_by_auto=True, cluster_by=["id"])
def tbl_with_auto_and_initial_hint():
   return spark.range(5)&lt;/LI-CODE&gt;&lt;P&gt;or in SQL&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;CREATE OR REPLACE MATERIALIZED VIEW mat_view_name
CLUSTER BY AUTO
AS SELECT * FROM source_table;&lt;/LI-CODE&gt;&lt;P&gt;If you know how to specify initial clustering key with Spark SQL, let me know &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; .&lt;/P&gt;</description>
    <pubDate>Tue, 10 Jun 2025 09:26:00 GMT</pubDate>
    <dc:creator>lucami</dc:creator>
    <dc:date>2025-06-10T09:26:00Z</dc:date>
    <item>
      <title>Automatic Liquid Clustering and PO</title>
      <link>https://community.databricks.com/t5/community-articles/automatic-liquid-clustering-and-po/m-p/121313#M439</link>
      <description>&lt;P&gt;I spent some time to understand how to use automatic liquid clustering with dlt pipelines. Hope this can help you as well.&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;&lt;A href="https://docs.databricks.com/aws/en/optimizations/predictive-optimization" target="_self"&gt;Enable Predictive Optimization&amp;nbsp;&lt;/A&gt;&lt;/LI&gt;&lt;LI&gt;Use this code:&lt;/LI&gt;&lt;/OL&gt;&lt;LI-CODE lang="python"&gt;# Enabling Automatic Liquid Clustering on a new table
@dlt.table(cluster_by_auto=True)
def tbl_with_auto():
   return spark.range(5)

# Manually choosing a clustering key initially, followed by automatic clustering
@dlt.table(cluster_by_auto=True, cluster_by=["id"])
def tbl_with_auto_and_initial_hint():
   return spark.range(5)&lt;/LI-CODE&gt;&lt;P&gt;or in SQL&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;CREATE OR REPLACE MATERIALIZED VIEW mat_view_name
CLUSTER BY AUTO
AS SELECT * FROM source_table;&lt;/LI-CODE&gt;&lt;P&gt;If you know how to specify initial clustering key with Spark SQL, let me know &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; .&lt;/P&gt;</description>
      <pubDate>Tue, 10 Jun 2025 09:26:00 GMT</pubDate>
      <guid>https://community.databricks.com/t5/community-articles/automatic-liquid-clustering-and-po/m-p/121313#M439</guid>
      <dc:creator>lucami</dc:creator>
      <dc:date>2025-06-10T09:26:00Z</dc:date>
    </item>
    <item>
      <title>Re: Automatic Liquid Clustering and PO</title>
      <link>https://community.databricks.com/t5/community-articles/automatic-liquid-clustering-and-po/m-p/121325#M440</link>
      <description>&lt;DIV&gt;&lt;P&gt;&lt;SPAN&gt;Thank you for sharing this! &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Just to add:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;To enable automatic liquid clustering &amp;amp; set clustering columns for an existing table&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;ALTER TABLE&lt;/SPAN&gt; table_name CLUSTER &lt;SPAN class=""&gt;BY&lt;/SPAN&gt; (column1, column2) AUTO;&lt;/P&gt;&lt;/DIV&gt;</description>
      <pubDate>Tue, 10 Jun 2025 11:30:23 GMT</pubDate>
      <guid>https://community.databricks.com/t5/community-articles/automatic-liquid-clustering-and-po/m-p/121325#M440</guid>
      <dc:creator>Addy0_</dc:creator>
      <dc:date>2025-06-10T11:30:23Z</dc:date>
    </item>
    <item>
      <title>Re: Automatic Liquid Clustering and PO</title>
      <link>https://community.databricks.com/t5/community-articles/automatic-liquid-clustering-and-po/m-p/121327#M441</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/123083"&gt;@Addy0_&lt;/a&gt;, thanks for sharing how to set it for existing table. Unfortunately, I think ALTER cannot be used with materialized view and streaming tables defined in dlt pipelines.&lt;/P&gt;&lt;P&gt;I was looking for something similar to&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;@dlt.table(cluster_by_auto=True, cluster_by=["id"])&lt;/LI-CODE&gt;&lt;P&gt;that in sql would look like&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;CREATE MATERIALIZED VIEW tbl_with_auto_and_initial_hint
CLUSTER BY id AUTO AS
SELECT
    id,
    fare_amount
FROM source_table;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;But this code raises syntax error.&lt;/P&gt;</description>
      <pubDate>Tue, 10 Jun 2025 11:51:18 GMT</pubDate>
      <guid>https://community.databricks.com/t5/community-articles/automatic-liquid-clustering-and-po/m-p/121327#M441</guid>
      <dc:creator>lucami</dc:creator>
      <dc:date>2025-06-10T11:51:18Z</dc:date>
    </item>
  </channel>
</rss>

