jnh5y commented on code in PR #24073:
URL: https://github.com/apache/flink/pull/24073#discussion_r1452481931


##########
flink-table/flink-table-common/src/main/java/org/apache/flink/table/catalog/CatalogTable.java:
##########
@@ -144,4 +167,76 @@ default Map<String, String> toProperties() {
     default Optional<Long> getSnapshot() {
         return Optional.empty();
     }
+
+    /** Returns the distribution of the table if the {@code DISTRIBUTED} 
clause is defined. */
+    default Optional<TableDistribution> getDistribution() {
+        return Optional.empty();
+    }
+
+    /** Distribution specification. */
+    @PublicEvolving
+    class TableDistribution {
+
+        private final Kind kind;
+        private final @Nullable Integer bucketCount;
+        private final List<String> bucketKeys;
+
+        @PublicEvolving
+        public TableDistribution(
+                Kind kind, @Nullable Integer bucketCount, List<String> 
bucketKeys) {
+            this.kind = kind;
+            this.bucketCount = bucketCount;
+            this.bucketKeys = bucketKeys;
+        }
+
+        /** Connector-dependent distribution with a declared number of 
buckets. */
+        public static TableDistribution ofUnknown(int bucketCount) {
+            return new TableDistribution(Kind.UNKNOWN, bucketCount, 
Collections.emptyList());
+        }
+
+        /** Hash distribution over on the given keys among the declared number 
of buckets. */
+        public static TableDistribution ofHash(
+                List<String> bucketKeys, @Nullable Integer bucketCount) {
+            return new TableDistribution(Kind.HASH, bucketCount, bucketKeys);
+        }
+
+        /** Range distribution over on the given keys among the declared 
number of buckets. */
+        public static TableDistribution ofRange(
+                List<String> bucketKeys, @Nullable Integer bucketCount) {
+            return new TableDistribution(Kind.RANGE, bucketCount, bucketKeys);
+        }
+
+        @Override
+        public boolean equals(Object o) {
+            if (this == o) return true;
+            if (o == null || getClass() != o.getClass()) return false;
+            TableDistribution that = (TableDistribution) o;
+            return kind == that.kind && Objects.equals(bucketCount, 
that.bucketCount)
+                    && Objects.equals(bucketKeys, that.bucketKeys);
+        }
+
+        @Override
+        public int hashCode() {
+            return Objects.hash(kind, bucketCount, bucketKeys);
+        }
+
+        @PublicEvolving
+        public enum Kind {
+            UNKNOWN,

Review Comment:
   From the FLIP, when a distribution kind is not specified, the connector 
decides.  



-- 
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: issues-unsubscr...@flink.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to