FANNG1 commented on code in PR #9753:
URL: https://github.com/apache/gravitino/pull/9753#discussion_r2735231515
##########
catalogs/catalog-lakehouse-paimon/src/main/java/org/apache/gravitino/catalog/lakehouse/paimon/GravitinoPaimonTable.java:
##########
@@ -188,6 +199,67 @@ private static void validate(List<String> primaryKeys,
List<String> partitionKey
}
}
+ private static void applyDistribution(Map<String, String> properties,
Distribution distribution) {
+ if (distribution == null || distribution.strategy() ==
Distributions.NONE.strategy()) {
+ return;
+ }
+
+ List<String> bucketKeys = getBucketKeys(distribution);
+ if (!bucketKeys.isEmpty()) {
+ properties.put(BUCKET_KEY, String.join(",", bucketKeys));
+ }
+
+ properties.put(BUCKET_NUM, String.valueOf(distribution.number()));
+ }
+
+ private static List<String> getBucketKeys(Distribution distribution) {
+ return Arrays.stream(distribution.expressions())
+ .map(
+ expression -> {
+ Preconditions.checkArgument(
+ expression instanceof NamedReference.FieldReference,
+ "Paimon bucket keys must be plain column references.");
+ NamedReference.FieldReference reference =
(NamedReference.FieldReference) expression;
+ String[] fieldName = reference.fieldName();
+ Preconditions.checkArgument(
+ fieldName.length == 1, "Paimon bucket keys must be single
columns.");
+ return fieldName[0];
+ })
+ .collect(Collectors.toList());
+ }
+
+ static Distribution getDistribution(Map<String, String> properties) {
+ if (properties == null) {
+ return Distributions.NONE;
+ }
+ String bucketKeys = properties.get(BUCKET_KEY);
+ if (StringUtils.isBlank(bucketKeys)) {
+ return Distributions.NONE;
+ }
+ List<String> bucketKeyList =
+ Arrays.stream(bucketKeys.split(","))
+ .map(String::trim)
+ .filter(StringUtils::isNotEmpty)
Review Comment:
updated
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]