ZENOTME commented on code in PR #1473:
URL: https://github.com/apache/paimon-rust/pull/1473#discussion_r4642839057


##########
crates/paimon/src/table/bucket_router.rs:
##########
@@ -188,6 +220,51 @@ impl BucketRouter {
     }
 }
 
+impl BucketRouter {
+    /// Construct an owned router for a fixed-bucket or postpone-bucket schema.
+    ///
+    /// Postpone routing uses the configured default until an explicit plan is
+    /// supplied. Without either, routing an unknown input partition fails.
+    pub fn new(schema: &TableSchema) -> Result<Self> {
+        let options = CoreOptions::new(schema.options());
+        let total_buckets = options.bucket();
+        let inner = match total_buckets {
+            n if n > 0 && !options.is_format_table() => {
+                BucketRouterInner::Fixed(FixedBucketRouter::new(schema, n)?)
+            }
+            POSTPONE_BUCKET => 
BucketRouterInner::Postpone(PostponeBucketRouter::new(schema)?),
+            _ => {
+                return Err(crate::Error::Unsupported {
+                    message:
+                        "Bucket routing requires a Paimon fixed-bucket or 
postpone-bucket table"
+                            .into(),
+                })
+            }
+        };
+        Ok(Self { inner })
+    }
+
+    /// Replace postpone routing metadata, including any configured default.
+    pub fn with_bucket_plan(self, plan: PostponeBucketPlan) -> Result<Self> {

Review Comment:
   Does `with_bucket_plan` belong on the generic `BucketRouter`? Since a caller 
supplying a plan already knows it needs postpone routing, would it make sense 
to expose `FixedBucketRouter` and `PostponeBucketRouter` directly, with 
`with_bucket_plan` on the latter? Callers that only need `route(batch)` could 
still use `BucketRouter::new(schema)` and let the schema select the 
implementation.



-- 
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]

Reply via email to