Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Snowflake – Rebuild Table With Clustering

I understand when clustering is enabled Snowflake will run a background task to automatically cluster your records. There are situations where I want to rebuild an entire table or populate a new table with an insert into select statement. When I do this I find that the new table is built unclustered even when I have predefined the clustering. It seems wasteful to load the table first, then rearrange it.

Is there anyway to convince snowflake to use the clustering i’ve defined when rebuilding a table or loading a new table?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

You can use ORDER BY that matches CLUSTER BY to have the data clustered at the same time its ingested:

create or replace table delete_test_cluster
cluster by (a, b)
as
select *
from (select 1 a, 2 b)
order by a, b
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading