-
Notifications
You must be signed in to change notification settings - Fork 2
ice: Added support for deleting partitions #26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
34 commits
Select commit
Hold shift + click to select a range
e93e775
ice: Added support for positional delete file.
subkanthi 7b976f6
ice: Added support to delete file with partition name and value.
subkanthi 732804a
Merge branch 'master' of github.com:Altinity/ice into 7-ice-support-d…
subkanthi 615b430
ice: Added support to delete file with partition name and value.
subkanthi 40838b4
ice: Fix formatting errors.
subkanthi 539d889
ice: Remove wildcard imports
subkanthi 40a313a
ice: Fix formatting.
subkanthi 25ac38e
Merge branch 'master' of github.com:Altinity/ice into 7-ice-support-d…
subkanthi d8ca2ee
ice: Renamed DeleteFile to DeletePartition, Added --dry-run option.
subkanthi 7aa2075
ice: DeletePartition , add support to delete a list of values.
subkanthi 84247ec
Added Integration test to start rest catalog server with shutdown
subkanthi 0f16095
Merged conflicts from main.
subkanthi dd5ee85
Merged conflicts from main.
subkanthi 00dae46
Merged conflicts from main.
subkanthi c14da54
Merged conflicts from main.
subkanthi 13e0751
Fixed imports
subkanthi 2e5795a
revert devbox.json changes.
subkanthi c720c83
Merge branch 'master' of github.com:Altinity/ice into 7-ice-support-d…
subkanthi 4f93ceb
Added RESTCatalogIT integration test to start ice rest server and val…
subkanthi 86c0e7f
Reverted back change to shutDown token.
subkanthi 2396bc1
formatting changes.
subkanthi cabb5a4
Merge branch 'master' of github.com:Altinity/ice into 7-ice-support-d…
subkanthi 7f7f1a8
Modified deletePartition to use namespace.tablename as argument. Modi…
subkanthi b75d4af
Added insert command to RESTCatalogIT
subkanthi ede4b82
Merge branch 'master' of github.com:Altinity/ice into 7-ice-support-d…
subkanthi 3b4ae26
Addressed PR review comments.
subkanthi 12ab306
Reverted back removal of private
subkanthi bce53f2
Removed yaml files added for Integration test.
subkanthi 271c864
reverted back private change to Main
subkanthi a474855
Updated README.md with example
subkanthi 9f5a8be
Removed wildcard imports, replaced Iterable with CloseableIterable an…
subkanthi 344b0b3
Add try/catch to close CloseableIterable.
subkanthi 23c389a
Remove logging line before throwing exception.
subkanthi ee0c915
Removed catch block.
subkanthi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
81 changes: 81 additions & 0 deletions
81
ice/src/main/java/com/altinity/ice/cli/internal/cmd/Delete.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
/* | ||
* Copyright (c) 2025 Altinity Inc and/or its affiliates. All rights reserved. | ||
* | ||
* Licensed 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 | ||
*/ | ||
package com.altinity.ice.cli.internal.cmd; | ||
|
||
import java.io.IOException; | ||
import java.net.URISyntaxException; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
import org.apache.iceberg.DataFile; | ||
import org.apache.iceberg.FileScanTask; | ||
import org.apache.iceberg.RewriteFiles; | ||
import org.apache.iceberg.Table; | ||
import org.apache.iceberg.TableScan; | ||
import org.apache.iceberg.catalog.TableIdentifier; | ||
import org.apache.iceberg.io.CloseableIterable; | ||
import org.apache.iceberg.rest.RESTCatalog; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
public final class Delete { | ||
|
||
private static final Logger logger = LoggerFactory.getLogger(Delete.class); | ||
|
||
private Delete() {} | ||
|
||
public static void run( | ||
RESTCatalog catalog, | ||
TableIdentifier tableId, | ||
List<com.altinity.ice.cli.Main.PartitionFilter> partitions, | ||
boolean dryRun) | ||
throws IOException, URISyntaxException { | ||
|
||
Table table = catalog.loadTable(tableId); | ||
TableScan scan = table.newScan(); | ||
if (partitions != null && !partitions.isEmpty()) { | ||
org.apache.iceberg.expressions.Expression expr = null; | ||
for (com.altinity.ice.cli.Main.PartitionFilter pf : partitions) { | ||
org.apache.iceberg.expressions.Expression e = null; | ||
for (Object value : pf.values()) { | ||
org.apache.iceberg.expressions.Expression valueExpr = | ||
org.apache.iceberg.expressions.Expressions.equal(pf.name(), value); | ||
e = (e == null) ? valueExpr : org.apache.iceberg.expressions.Expressions.or(e, valueExpr); | ||
} | ||
expr = (expr == null) ? e : org.apache.iceberg.expressions.Expressions.and(expr, e); | ||
} | ||
scan = scan.filter(expr); | ||
} | ||
List<DataFile> filesToDelete = new ArrayList<>(); | ||
|
||
try (CloseableIterable<FileScanTask> tasks = scan.planFiles()) { | ||
for (FileScanTask task : tasks) { | ||
filesToDelete.add(task.file()); | ||
} | ||
} | ||
|
||
if (!filesToDelete.isEmpty()) { | ||
if (dryRun) { | ||
logger.info("Dry run: The following files would be deleted:"); | ||
for (DataFile file : filesToDelete) { | ||
logger.info(" {}", file.path()); | ||
} | ||
} else { | ||
RewriteFiles rewrite = table.newRewrite(); | ||
for (DataFile deleteFile : filesToDelete) { | ||
rewrite.deleteFile(deleteFile); | ||
} | ||
rewrite.commit(); | ||
logger.info("Partition(s) deleted."); | ||
} | ||
} else { | ||
logger.info("No files found for the partition(s)."); | ||
} | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
might be worth it to have it true be default considering the nature of the operation