pvary commented on code in PR #13853:
URL: https://github.com/apache/iceberg/pull/13853#discussion_r2282490097


##########
docs/docs/flink-table-maintenance.md:
##########
@@ -0,0 +1,318 @@
+---
+title: "Flink Table Maintenance "
+---
+<!--
+ - Licensed to the Apache Software Foundation (ASF) under one or more
+ - contributor license agreements.  See the NOTICE file distributed with
+ - this work for additional information regarding copyright ownership.
+ - The ASF licenses this file to You under the Apache License, Version 2.0
+ - (the "License"); you may not use this file except in compliance with
+ - the License.  You may obtain a copy of the License at
+ -
+ -   http://www.apache.org/licenses/LICENSE-2.0
+ -
+ - Unless required by applicable law or agreed to in writing, software
+ - distributed under the License is distributed on an "AS IS" BASIS,
+ - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ - See the License for the specific language governing permissions and
+ - limitations under the License.
+ -->
+
+# Flink Table Maintenance 
+
+## Overview
+
+In **Apache Iceberg** deployments within **Flink streaming environments**, 
implementing automated table maintenance operations—including `snapshot 
expiration`, `small file compaction`, and `orphan file cleanup`—is critical for 
optimal performance and storage efficiency.
+
+Traditionally, these maintenance operations were exclusively accessible 
through **Iceberg Spark Actions**, necessitating the deployment and management 
of dedicated Spark clusters. This dependency on **Spark infrastructure** solely 
for table optimization introduces significant **architectural complexity** and 
**operational overhead**.
+
+The `TableMaintenance` API in **Apache Iceberg** empowers **Flink jobs** to 
execute maintenance tasks **natively**, either embedded within existing 
streaming pipelines or deployed as standalone Flink jobs. This eliminates 
dependencies on external systems, thereby **streamlining architecture**, 
**reducing operational costs**, and **enhancing automation capabilities**.
+
+## Supported Features (Flink)
+
+- ExpireSnapshots: removes old snapshots and their files. Internally uses 
`cleanExpiredFiles(true)` when committing, so expired metadata/files are 
cleaned up automatically.
+- RewriteDataFiles: compacts small files to optimize file sizes. Supports 
partial progress commits and limiting maximum rewritten bytes per run.
+
+Example usage:
+```java
+// Snapshot expiration
+.add(ExpireSnapshots.builder()
+    .maxSnapshotAge(Duration.ofDays(7))
+    .retainLast(10)
+    .deleteBatchSize(1000))
+
+// Continuous file optimization
+.add(RewriteDataFiles.builder()
+    .targetFileSizeBytes(256 * 1024 * 1024)
+    .minFileSizeBytes(32 * 1024 * 1024)
+    .partialProgressEnabled(true)
+    .partialProgressMaxCommits(5))
+```
+
+## Quick Start
+
+The following example demonstrates the implementation of automated maintenance 
for an Iceberg table within a Flink environment.
+
+```java
+StreamExecutionEnvironment env = 
StreamExecutionEnvironment.getExecutionEnvironment();
+TableLoader tableLoader = TableLoader.fromHadoopTable("path/to/table");
+
+Map<String, String> jdbcProps = new HashMap<>();
+jdbcProps.put("jdbc.user", "flink");
+jdbcProps.put("jdbc.password", "flinkpw");
+
+// JdbcLockFactory Example
+TriggerLockFactory lockFactory = new JdbcLockFactory(
+    "jdbc:postgresql://localhost:5432/iceberg", // JDBC URL
+    "catalog.db.table",                         // Lock ID (unique identifier)
+    jdbcProps                                   // JDBC connection properties
+);

Review Comment:
   At this point, as a user, I don't understand what is the role of the 
`TriggerLockFactory`. We need to describe it somewhere



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org
For additional commands, e-mail: issues-h...@iceberg.apache.org

Reply via email to