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

[#6361] feat(paimon):Support specifying primary keys during create paimon table by flink #6362

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

hdygxsj
Copy link
Contributor

@hdygxsj hdygxsj commented Jan 23, 2025

What changes were proposed in this pull request?

Support specifying primary keys during create paimon table by flink

Why are the changes needed?

Fix: #6361

Does this PR introduce any user-facing change?

None

How was this patch tested?

Add testCreateTableWithPrimaryKey case in org.apache.gravitino.flink.connector.integration.test.FlinkCommonIT

@hdygxsj hdygxsj closed this Jan 23, 2025
@hdygxsj hdygxsj reopened this Jan 24, 2025
server/build.gradle.kts Outdated Show resolved Hide resolved
if (primaryColumns == null) {
return new Index[0];
}
String[][] primaryFiled =
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
String[][] primaryFiled =
String[][] primaryField =

@@ -521,6 +552,11 @@ protected CatalogBaseTable toFlinkTable(Table table) {
.column(column.name(), column.nullable() ? flinkType.nullable() : flinkType.notNull())
.withComment(column.comment());
}
Index[] indices = table.index();
if (indices != null && indices.length == 1) {
Copy link
Contributor

Choose a reason for hiding this comment

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

So .... this means the primary key always has a SINGLE column, right?

Copy link
Contributor Author

@hdygxsj hdygxsj Jan 26, 2025

Choose a reason for hiding this comment

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

No. this means that only one primary key is supported. The Index object also stores field information and there can be multiple fields.
image

try {
catalog().asTableCatalog().createTable(identifier, columns, comment, properties, partitions);

Index[] indices = getGrivatinoIndeics(resolvedTable);
Copy link
Contributor

Choose a reason for hiding this comment

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

use getGrivatinoIndices?

if (primaryKeyList.isEmpty()) {
return;
}
Preconditions.checkArgument(
Copy link
Contributor

Choose a reason for hiding this comment

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

could you add the check for the size of filednames too?

Map<String, String> flinkTableProperties =
propertiesConverter.toFlinkTableProperties(table.properties());
List<String> partitionKeys = partitionConverter.toFlinkPartitionKeys(table.partitioning());
return CatalogTable.of(builder.build(), table.comment(), partitionKeys, flinkTableProperties);
}

private static void handleFlinkPrimaryKey(
Copy link
Contributor

Choose a reason for hiding this comment

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

could you use String getFlinkPrimaryKey(Table table) to return the primary field name, builder could use field name to build primary key.

@FANNG1
Copy link
Contributor

FANNG1 commented Jan 27, 2025

LGTM except minior comments

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.

[Subtask] Support specifying primary keys during create paimon table by flink
3 participants