From 3148f8a157ce325baf740f753c62218406cb2e18 Mon Sep 17 00:00:00 2001 From: Ankan Ghosh Date: Sun, 14 Jan 2024 23:28:28 +0100 Subject: [PATCH] Add example for optimize procedure - Shows casting timestamp_tz column values to dates - And using value for condition --- docs/src/main/sphinx/connector/delta-lake.md | 1 + docs/src/main/sphinx/connector/optimize.fragment | 10 ++++++++++ docs/src/main/sphinx/sql/alter-table.md | 13 ++++++------- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/docs/src/main/sphinx/connector/delta-lake.md b/docs/src/main/sphinx/connector/delta-lake.md index a77464664f87..e9b5de6ed756 100644 --- a/docs/src/main/sphinx/connector/delta-lake.md +++ b/docs/src/main/sphinx/connector/delta-lake.md @@ -543,6 +543,7 @@ TABLE AS ` syntax. The connector supports the following [](/sql/alter-table) statements. +(delta-lake-alter-table-execute)= #### ALTER TABLE EXECUTE The connector supports the following commands for use with {ref}`ALTER TABLE diff --git a/docs/src/main/sphinx/connector/optimize.fragment b/docs/src/main/sphinx/connector/optimize.fragment index 476b5579892a..67480918f4f7 100644 --- a/docs/src/main/sphinx/connector/optimize.fragment +++ b/docs/src/main/sphinx/connector/optimize.fragment @@ -26,3 +26,13 @@ to filter which partitions are optimized: ALTER TABLE test_partitioned_table EXECUTE optimize WHERE partition_key = 1 ``` + +You can use a more complex `WHERE` clause to narrow down the scope of the +`optimize` procedure. The following example casts the timestamp values to +dates, and uses a comparison to only optimize partitions with data from the year +2022 or newer: + +``` +ALTER TABLE test_table EXECUTE optimize +WHERE CAST(timestamp_tz AS DATE) > DATE '2021-12-31' +``` diff --git a/docs/src/main/sphinx/sql/alter-table.md b/docs/src/main/sphinx/sql/alter-table.md index 08e2a43fbecc..7f456579488d 100644 --- a/docs/src/main/sphinx/sql/alter-table.md +++ b/docs/src/main/sphinx/sql/alter-table.md @@ -51,7 +51,12 @@ parameters. `ALTER TABLE EXECUTE` supports different commands on a per-connector basis. You can use the `=>` operator for passing named parameter values. -The left side is the name of the parameter, the right side is the value being passed: +The left side is the name of the parameter, the right side is the value being passed. + +Collapse files in a table that are over 10 megabytes in size with the `optimize` +procedure from the [Hive](hive-alter-table-execute), [Delta +Lake](delta-lake-alter-table-execute) , and +[Iceberg](iceberg-alter-table-execute) connectors: ``` ALTER TABLE hive.schema.test_table EXECUTE optimize(file_size_threshold => '10MB') @@ -144,12 +149,6 @@ Set table property `x` to its default value in table\`\`people\`\`: ALTER TABLE people SET PROPERTIES x = DEFAULT; ``` -Collapse files in a table that are over 10 megabytes in size, as supported by -the Hive connector: - -``` -ALTER TABLE hive.schema.test_table EXECUTE optimize(file_size_threshold => '10MB') -``` ## See also