-
Notifications
You must be signed in to change notification settings - Fork 13.3k
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
[FLINK-11518] [table] Add partition related catalog APIs and implement them in GenericInMemoryCatalog #8222
Conversation
…ement them in GenericInMemoryCatalog
Thanks a lot for your contribution to the Apache Flink project. I'm the @flinkbot. I help the community Review Progress
Please see the Pull Request Review Guide for a full explanation of the review process. The Bot is tracking the review progress through labels. Labels are applied according to the order of the review items. For consensus, approval by a Flink committer of PMC member is required Bot commandsThe @flinkbot bot supports the following commands:
|
...e/flink-table-api-java/src/main/java/org/apache/flink/table/catalog/GenericCatalogTable.java
Outdated
Show resolved
Hide resolved
...e/flink-table-api-java/src/main/java/org/apache/flink/table/catalog/GenericCatalogTable.java
Outdated
Show resolved
Hide resolved
flink-table/flink-table-common/src/main/java/org/apache/flink/table/catalog/CatalogTable.java
Outdated
Show resolved
Hide resolved
flink-table/flink-table-common/src/main/java/org/apache/flink/table/catalog/CatalogTable.java
Outdated
Show resolved
Hide resolved
...link-table-api-java/src/main/java/org/apache/flink/table/catalog/GenericInMemoryCatalog.java
Show resolved
Hide resolved
.../src/main/java/org/apache/flink/table/catalog/exceptions/PartitionAlreadyExistException.java
Outdated
Show resolved
Hide resolved
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.
The pull request looks good to me. I only have some doubts, as I'm not familiar with Hive and catalog.
flink-table/flink-table-common/src/main/java/org/apache/flink/table/catalog/CatalogTable.java
Outdated
Show resolved
Hide resolved
...-table/flink-table-common/src/main/java/org/apache/flink/table/catalog/CatalogPartition.java
Show resolved
Hide resolved
...-table/flink-table-common/src/main/java/org/apache/flink/table/catalog/CatalogPartition.java
Outdated
Show resolved
Hide resolved
* Get the partition keys of the table. This will be an empty set if the table is not partitioned. | ||
* @return partition keys of the table. | ||
*/ | ||
LinkedHashSet<String> getPartitionKeys() throws TableNotPartitionedException; |
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 find that Hive doesn't allow partitioned keys in table schema, do we have this restriction?
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 don't really understand the question. What do you mean restriction? Can you elaborate?
You are right that Hive's Table uses a separate field dedicated for partition keys.
...ink-table-api-java/src/main/java/org/apache/flink/table/catalog/GenericCatalogPartition.java
Outdated
Show resolved
Hide resolved
...ink-table-api-java/src/main/java/org/apache/flink/table/catalog/GenericCatalogPartition.java
Outdated
Show resolved
Hide resolved
...-table/flink-table-common/src/main/java/org/apache/flink/table/catalog/CatalogPartition.java
Outdated
Show resolved
Hide resolved
flink-table/flink-table-common/src/main/java/org/apache/flink/table/catalog/CatalogTable.java
Show resolved
Hide resolved
...k-table/flink-table-common/src/main/java/org/apache/flink/table/catalog/ReadableCatalog.java
Outdated
Show resolved
Hide resolved
...k-table/flink-table-common/src/main/java/org/apache/flink/table/catalog/ReadableCatalog.java
Outdated
Show resolved
Hide resolved
...k-table/flink-table-common/src/main/java/org/apache/flink/table/catalog/ReadableCatalog.java
Outdated
Show resolved
Hide resolved
.../src/main/java/org/apache/flink/table/catalog/exceptions/PartitionAlreadyExistException.java
Outdated
Show resolved
Hide resolved
...on/src/main/java/org/apache/flink/table/catalog/exceptions/TableNotPartitionedException.java
Outdated
Show resolved
Hide resolved
...-table/flink-table-common/src/main/java/org/apache/flink/table/catalog/CatalogPartition.java
Outdated
Show resolved
Hide resolved
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.
Looks good overall. Some suggestions for consideration.
…xception, and update catalog APIs
...le/flink-table-common/src/main/java/org/apache/flink/table/catalog/CatalogPartitionSpec.java
Outdated
Show resolved
Hide resolved
Thanks for your reivew @JingsongLi @wuchong @xuefuz @zjffdu . To summarize major feedbacks I've addressed:
@KurtYoung Would be great to have you take a look and merge this PR if everything looks good |
@flinkbot attention @KurtYoung |
...e/flink-table-api-java/src/main/java/org/apache/flink/table/catalog/GenericCatalogTable.java
Outdated
Show resolved
Hide resolved
* @throws PartitionNotExistException thrown if the partition is not partitioned | ||
* @throws CatalogException in case of any runtime exception | ||
*/ | ||
CatalogPartition getPartition(ObjectPath tablePath, CatalogPartitionSpec partitionSpec) |
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.
This functionality can be covered by "listPartitions"?
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.
not really. PartitionSpec in listPartition can be a partial spec to indicate a subset of all partitions in the table, while it must be a full spec in getPartition to represent a single partition.
E.g., say we have a table with partition keys(k1, k2) and 2 partitions (k1=a, k2=b) and (k1=a, k2=c), listPartitions(tablePath, (k1=a))
returns both partitions, and of course as an extreme case, listPartitions(tablePath, (k1=a, k2=b))
returns a list with the first partition as the only element inside. getPartition
requires a full spec not partial ones, e.g. you can pass (k1=a, k2=b), but not just (k1=a) in which case it throws exception
* @throws PartitionAlreadyExistsException thrown if the target partition already exists | ||
* @throws CatalogException in case of any runtime exception | ||
*/ | ||
void createPartition(ObjectPath tablePath, CatalogPartitionSpec partitionSpec, CatalogPartition partition, boolean ignoreIfExists) |
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.
Can you explain more about this interface? In which case this API would be invoked. I mean, does there exists some partition-only operations? My feeling is most operations to partition is through table.
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.
An example from a SQL perspective is "ALTER TABLE ADD PARTITION". Operations on partitions will be using and only using table as an identifier to locate the partition, and that's why this API includes tablePath.
LGTM, will merge this after travis |
…t them in GenericInMemoryCatalog This closes apache#8222
What is the purpose of the change
This PR adds support for partition related operations to Catalog APIs
Brief change log
Verifying this change
This change added tests and can be verified as follows:
Does this pull request potentially affect one of the following parts:
@Public(Evolving)
: (yes)Documentation