Last active
August 26, 2025 03:25
-
-
Save jeanmidevacc/1d60e57c82ff4a5505e174e6d225f8b0 to your computer and use it in GitHub Desktop.
Sample of code to build and write on liquid clustered table
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Add a create stement example | |
| # build a table | |
| query = """ | |
| CREATE TABLE IF NOT EXISTS name_of_the_table ( | |
| column_1 DATE, | |
| column_2 INT, | |
| p_dateid INT NOT NULL | |
| ) | |
| USING DELTA | |
| CLUSTER BY (p_dateid); # you could also set CLUSTER BY AUTO , if you wanto let databrciks handle the rest | |
| """ | |
| # Add an insert into table , replace cmd | |
| query = """ | |
| INSERT INTO TABLE name_of_the_table | |
| SELECT * FROM data_to_add | |
| REPLACE WHERE p_dateid BETWEEN {start_dateid} AND {end_dateid} | |
| """ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment