Skip to content
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

[core] Support add partition for paimon #4323

Merged
merged 21 commits into from
Oct 16, 2024

Conversation

xuzifu666
Copy link
Member

@xuzifu666 xuzifu666 commented Oct 14, 2024

Purpose

Currently paimon can not support add partition, due to add partition not need commit transaction,so make hms sync to achieve it.

Linked issue: close #xxx

Tests

API and Format

Documentation

@@ -273,6 +273,17 @@ default void invalidateTable(Identifier identifier) {}
void dropPartition(Identifier identifier, Map<String, String> partitions)
throws TableNotExistException, PartitionNotExistException;

/**
* Create a partition for the specify table.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

specified

@@ -310,6 +310,27 @@ private Map<String, String> convertToProperties(Database database) {
return properties;
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

* @throws PartitionNotExistException if the partition does not exist
*/
void createPartition(Identifier identifier, Map<String, String> partitions)
throws TableNotExistException, PartitionNotExistException;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When throw PartitionNotExistException?

Identifier identifier = toIdentifier(tablePath);
catalog.createPartition(identifier, partitionSpec.getPartitionSpec());
} else {
throw new UnsupportedOperationException();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

message?

} catch (Catalog.TableNotExistException e) {
throw new CatalogException(e);
} catch (Catalog.PartitionNotExistException e) {
throw new RuntimeException(e);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why throw RuntimeException?

TableSchema tableSchema = getDataTableSchema(identifier);
if (!tableSchema.partitionKeys().isEmpty()
&& new CoreOptions(tableSchema.options()).partitionedTableInMetastore()) {
try {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a warn log if tableSchema.partitionKeys().isEmpty() or tableSchema.options()).partitionedTableInMetastore() is false?

@xuzifu666 xuzifu666 changed the title [flink] Support add partition for FlinkSQL [WIP][flink] Support add partition for FlinkSQL Oct 15, 2024
@xuzifu666 xuzifu666 changed the title [WIP][flink] Support add partition for FlinkSQL [core] Support add partition with SQL Oct 15, 2024
@xuzifu666 xuzifu666 changed the title [core] Support add partition with SQL [WIP][core] Support add partition with SQL Oct 15, 2024
@xuzifu666 xuzifu666 changed the title [WIP][core] Support add partition with SQL [WIP][core] Support add partition for paimon Oct 15, 2024
catalog = ((CachingCatalog) catalog).wrapped();
}

if (catalog instanceof HiveCatalog) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why need to check HiveCatalog?

}
}
try {
if (catalog instanceof CachingCatalog) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why need to check CachingCatalog?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image Here catalog is CachingCatalog which wraped HiveCatalog, so handle it as CacheingCatalog firstly. @JingsongLi


if (catalog instanceof HiveCatalog) {
Identifier identifier = toIdentifier(tablePath);
catalog.createPartition(identifier, partitionSpec.getPartitionSpec());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just invoke this?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Had move the logic to AbstractCatalog, so Catalog API not contains createPartition API.

throws TableNotExistException {
TableSchema tableSchema = getDataTableSchema(identifier);
if (!tableSchema.partitionKeys().isEmpty()
&& new CoreOptions(tableSchema.options()).partitionedTableInMetastore()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

throw Unsupport exception if it is not partitioned table in metastore.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Copy link
Contributor

@JingsongLi JingsongLi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you should use MetastoreClient to add partition. The implementation can be in AbstractCatalog.

@JingsongLi JingsongLi changed the title [WIP][core] Support add partition for paimon [core] Support add partition for paimon Oct 15, 2024
@xuzifu666
Copy link
Member Author

I think you should use MetastoreClient to add partition. The implementation can be in AbstractCatalog.

I think you should use MetastoreClient to add partition. The implementation can be in AbstractCatalog.

Yes, move to AbstractCatalog maybe better, would change as it. Thanks @JingsongLi

@xuzifu666 xuzifu666 closed this Oct 15, 2024
@xuzifu666 xuzifu666 reopened this Oct 15, 2024
Copy link
Contributor

@JingsongLi JingsongLi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

@JingsongLi JingsongLi merged commit cc3ed7f into apache:master Oct 16, 2024
23 of 24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants