ice: Added support for deleting partitions#26
Conversation
|
| ice insert flowers.iris_no_copy --no-copy s3://bucket1/flowers/iris_no_copy/iris.parquet | ||
|
|
||
| # delete partition | ||
| ice delete-file --namespace=nyc --table=taxismay15 --partition='[{"partition_name": "tpep_pickup_datetime", "value": "2025-01-01T00:00:00"}]' |
There was a problem hiding this comment.
s/delete-file/delete to be consistent with ice insert + we're not deleting "file" here
| for (com.altinity.ice.cli.Main.PartitionFilter pf : partitions) { | ||
| org.apache.iceberg.expressions.Expression e = | ||
| org.apache.iceberg.expressions.Expressions.equal(pf.partitionName(), pf.value()); | ||
| expr = (expr == null) ? e : org.apache.iceberg.expressions.Expressions.and(expr, e); |
There was a problem hiding this comment.
shouldn't this be "or" instead of "and"? I think it's time to add tests
| @CommandLine.Option( | ||
| names = {"--partition"}, | ||
| description = | ||
| "JSON array of partition filters: [{\"partition_name\": \"vendorId\", \"value\": 5}]. " |
There was a problem hiding this comment.
it would be nice if there was a way to provide a list of values without having to repeat partition name
There was a problem hiding this comment.
partition: values
| RESTCatalog catalog, | ||
| String namespace, | ||
| String tableName, | ||
| List<com.altinity.ice.cli.Main.PartitionFilter> partitions) |
There was a problem hiding this comment.
supporting dryRun (that would print all matched files) would also be nice
| void deletePartition( | ||
| @CommandLine.Option(names = "--namespace", description = "Namespace name", required = true) | ||
| String namespace, | ||
| @CommandLine.Option(names = "--table", description = "Table name", required = true) |
There was a problem hiding this comment.
specifying ns & table via --namespace & --table is inconsistent with the rest of the commands: ice insert, describe, etc. all expect ns.table as an arg.
…idate ice CLI commands.
…fied Integration test to start admin server and use etcdcatalog
| private Server adminServer; | ||
|
|
||
| @SuppressWarnings("rawtypes") | ||
| private final GenericContainer etcd = |
There was a problem hiding this comment.
lets move RESTCatalogIT to a separate PR. There are still a few things to iron out here:
- doesn't looks like we really need etcd here. in-memory sqlite should be enough
- redundant icebergConfig in https://github.com/Altinity/ice/pull/26/files#diff-ca269f882cb860088e50c407fa428d338e81103552eedf6376bcca8768fbab18R76-R84
- Thread.sleep(5000);
- not sure how https://github.com/Altinity/ice/pull/26/files#diff-ca269f882cb860088e50c407fa428d338e81103552eedf6376bcca8768fbab18R124-R126 can possibly work considering that we're not starting minio here
- adminServer is not needed
| } | ||
| TableIdentifier tableId = TableIdentifier.parse(name); | ||
|
|
||
| DeletePartition.run(catalog, tableId, partitions, dryRun); |
| } | ||
| } | ||
|
|
||
| @CommandLine.Command(name = "delete", description = "Delete Partition(s).") |
There was a problem hiding this comment.
| @CommandLine.Command(name = "delete", description = "Delete Partition(s).") | |
| @CommandLine.Command(name = "delete", description = ""Delete data from catalog.") |
| } | ||
|
|
||
| @CommandLine.Command(name = "delete", description = "Delete Partition(s).") | ||
| void deletePartition( |
| @CommandLine.Option( | ||
| names = "--dry-run", | ||
| description = "Log files that would be deleted without actually deleting them") | ||
| boolean dryRun) |
There was a problem hiding this comment.
might be worth it to have it true be default considering the nature of the operation
| } | ||
| scan = scan.filter(expr); | ||
| } | ||
| Iterable<FileScanTask> tasks = scan.planFiles(); |
There was a problem hiding this comment.
scan.planFiles returns CloseableIterable which is supposed to be closed
| for (FileScanTask task : tasks) { | ||
| filesToDelete.add(task.file()); | ||
| } | ||
| tasks.close(); |
There was a problem hiding this comment.
what if tasks.next() throws?
| filesToDelete.add(task.file()); | ||
| } | ||
| } catch (Exception e) { | ||
| logger.error("Error getting files to delete: {}", e.getMessage()); |
There was a problem hiding this comment.
| filesToDelete.add(task.file()); | ||
| } | ||
| } catch (Exception e) { | ||
| throw e; |
There was a problem hiding this comment.
what's the point to
catch (Exception e) {
throw e;
}
?
There was a problem hiding this comment.
I thought the try-with-resources require catch block, I was wrong

Delete partitions.
closes: #7