-
Notifications
You must be signed in to change notification settings - Fork 3k
PoC: API, Core, Spark: Scan API for partition stats #14508
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| /* | ||
| * 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. | ||
| */ | ||
| package org.apache.iceberg; | ||
|
|
||
| /** Interface for partition statistics returned from a {@link PartitionStatisticsScan}. */ | ||
| public interface PartitionStatistics extends StructLike { | ||
|
|
||
| /** Returns the partition of these partition statistics */ | ||
| StructLike partition(); | ||
|
|
||
| /** Returns the spec ID of the partition of these partition statistics */ | ||
| Integer specId(); | ||
|
|
||
| /** Returns the number of data records in the partition */ | ||
| Long dataRecordCount(); | ||
|
|
||
| /** Returns the number of data files in the partition */ | ||
| Integer dataFileCount(); | ||
|
|
||
| /** Returns the total size of data files in bytes in the partition */ | ||
| Long totalDataFileSizeInBytes(); | ||
|
|
||
| /** | ||
| * Returns the number of positional delete records in the partition. Also includes dv record count | ||
| * as per spec | ||
| */ | ||
| Long positionDeleteRecordCount(); | ||
|
|
||
| /** Returns the number of positional delete files in the partition */ | ||
| Integer positionDeleteFileCount(); | ||
|
|
||
| /** Returns the number of equality delete records in the partition */ | ||
| Long equalityDeleteRecordCount(); | ||
|
|
||
| /** Returns the number of equality delete files in the partition */ | ||
| Integer equalityDeleteFileCount(); | ||
|
|
||
| /** Returns the total number of records in the partition */ | ||
| Long totalRecords(); | ||
|
|
||
| /** Returns the timestamp in milliseconds when the partition was last updated */ | ||
| Long lastUpdatedAt(); | ||
|
|
||
| /** Returns the ID of the snapshot that last updated this partition */ | ||
| Long lastUpdatedSnapshotId(); | ||
|
|
||
| /** Returns the number of delete vectors in the partition */ | ||
| Integer dvCount(); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| /* | ||
| * 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. | ||
| */ | ||
| package org.apache.iceberg; | ||
|
|
||
| import org.apache.iceberg.expressions.Expression; | ||
| import org.apache.iceberg.io.CloseableIterable; | ||
|
|
||
| /** API for configuring partition statistics scan. */ | ||
| public interface PartitionStatisticsScan { | ||
|
|
||
| /** | ||
| * Create a new scan from this scan's configuration that will use the given snapshot by ID. | ||
| * | ||
| * @param snapshotId a snapshot ID | ||
| * @return a new scan based on this with the given snapshot ID | ||
| * @throws IllegalArgumentException if the snapshot cannot be found | ||
| */ | ||
| PartitionStatisticsScan useSnapshot(long snapshotId); | ||
|
|
||
| /** | ||
| * Create a new scan from the results of this, where partitions are filtered by the {@link | ||
| * Expression}. | ||
| * | ||
| * @param filter a filter expression | ||
| * @return a new scan based on this with results filtered by the expression | ||
| */ | ||
| PartitionStatisticsScan filter(Expression filter); | ||
|
|
||
| /** | ||
| * Create a new scan from this with the schema as its projection. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe describe what will happen with the
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thank for pointing this out! My initial plan was to always query the 'traditional' partition stats and allow projection for the column-based once when we introduce them later. But it makes sense to project also the existing ones, and then the current design with PartitionStatistics isn't suitable for that. Let me wrap my head around this and come back with a different design that can tackle this too. |
||
| * | ||
| * @param schema a projection schema | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How does the user create the I would prefer something like the
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You're right. Let me add this to the possible follow-up steps in my comment at the top |
||
| * @return a new scan based on this with the given projection | ||
| */ | ||
| PartitionStatisticsScan project(Schema schema); | ||
|
|
||
| /** | ||
| * Scans a partition statistics file belonging to a particular snapshot | ||
| * | ||
| * @return an Iterable of partition statistics | ||
| */ | ||
| CloseableIterable<PartitionStatistics> scan(); | ||
| } | ||
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.
nit: maybe at lease a oneliner javadoc
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.
done