-
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
Conversation
|
examples/scratch/README.md
Outdated
@@ -50,6 +50,9 @@ ice create-table flowers.iris_no_copy --schema-from-parquet=file://iris.parquet | |||
local-mc cp iris.parquet local/bucket1/flowers/iris_no_copy/ | |||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/delete-file/delete to be consistent with ice insert
+ we're not deleting "file" here
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.
s/partition_name/name
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
partition
: values
RESTCatalog catalog, | ||
String namespace, | ||
String tableName, | ||
List<com.altinity.ice.cli.Main.PartitionFilter> partitions) |
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.
supporting dryRun (that would print all matched files) would also be nice
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.
added
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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); |
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.
s/DeletePartition/Delete
@@ -426,6 +428,42 @@ void deleteNamespace( | |||
} | |||
} | |||
|
|||
@CommandLine.Command(name = "delete", description = "Delete Partition(s).") |
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.
@CommandLine.Command(name = "delete", description = "Delete Partition(s).") | |
@CommandLine.Command(name = "delete", description = ""Delete data from catalog.") |
@@ -426,6 +428,42 @@ void deleteNamespace( | |||
} | |||
} | |||
|
|||
@CommandLine.Command(name = "delete", description = "Delete Partition(s).") | |||
void deletePartition( |
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.
s/deletePartition/delete
@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.
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
} | ||
scan = scan.filter(expr); | ||
} | ||
Iterable<FileScanTask> tasks = scan.planFiles(); |
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
filesToDelete.add(task.file()); | ||
} | ||
} catch (Exception e) { | ||
throw e; |
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.
what's the point to
catch (Exception e) {
throw e;
}
?
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.
I thought the try-with-resources require catch block, I was wrong
Delete partitions.
closes: #7