This is an automated email from the ASF dual-hosted git repository.

JingsongLi pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/paimon-rust.git


The following commit(s) were added to refs/heads/main by this push:
     new a6b26f90 fix: serialize unbounded varchar as string (#730)
a6b26f90 is described below

commit a6b26f902c123d958425e8862b3502f3ecaba3d2
Author: Jingsong Lee <[email protected]>
AuthorDate: Wed Aug 19 14:35:31 2026 +0800

    fix: serialize unbounded varchar as string (#730)
---
 Cargo.lock                                         |  4 +--
 DEPENDENCIES.rust.tsv                              |  2 +-
 benchmarks/tpcds/DEPENDENCIES.rust.tsv             |  2 +-
 bindings/c/DEPENDENCIES.rust.tsv                   |  2 +-
 bindings/go/DEPENDENCIES.rust.tsv                  |  2 +-
 bindings/python/DEPENDENCIES.rust.tsv              |  2 +-
 crates/integration_tests/DEPENDENCIES.rust.tsv     |  2 +-
 .../integrations/datafusion/DEPENDENCIES.rust.tsv  |  2 +-
 crates/paimon-rest-server/DEPENDENCIES.rust.tsv    |  2 +-
 crates/paimon/DEPENDENCIES.rust.tsv                |  2 +-
 crates/paimon/src/spec/types.rs                    | 38 ++++++++++++++--------
 11 files changed, 36 insertions(+), 24 deletions(-)

diff --git a/Cargo.lock b/Cargo.lock
index a8e8270c..02d2665a 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -2838,9 +2838,9 @@ dependencies = [
 
 [[package]]
 name = "h2"
-version = "0.4.15"
+version = "0.4.16"
 source = "registry+https://github.com/rust-lang/crates.io-index";
-checksum = "6cb093c84e8bd9b188d4c4a8cb6579fc016968d14c99882163cd3ff402a4f155"
+checksum = "a9f37a958b41b3b19ee2707c06439c0e9e547e847223eb791ecb0cb821c65e27"
 dependencies = [
  "atomic-waker",
  "bytes",
diff --git a/DEPENDENCIES.rust.tsv b/DEPENDENCIES.rust.tsv
index 912dea88..5b708be8 100644
--- a/DEPENDENCIES.rust.tsv
+++ b/DEPENDENCIES.rust.tsv
@@ -236,7 +236,7 @@ [email protected]             X                               
                                                X
 [email protected]                X                                               
                                X                                               
        
 [email protected]             X                                                       
                        X                                                       
 [email protected]              X                                               
                                X                                               
        
[email protected]                                                                      
                        X                                                       
[email protected]                                                                      
                        X                                                       
 [email protected]             X                                                       
                        X                                                       
 [email protected]               X                                               
                                X                                               
        
 [email protected]               X                                               
                                X                                               
        
diff --git a/benchmarks/tpcds/DEPENDENCIES.rust.tsv 
b/benchmarks/tpcds/DEPENDENCIES.rust.tsv
index a871ab1e..6824acf6 100644
--- a/benchmarks/tpcds/DEPENDENCIES.rust.tsv
+++ b/benchmarks/tpcds/DEPENDENCIES.rust.tsv
@@ -165,7 +165,7 @@ [email protected]             X                               
                                        X
 [email protected]                X                                               
                        X                                       
 [email protected]             X                                                       
                X                                       
 [email protected]              X                                               
                        X                                       
[email protected]                                                                      
                X                                       
[email protected]                                                                      
                X                                       
 [email protected]             X                                                       
                X                                       
 [email protected]               X                                               
                        X                                       
 [email protected]               X                                               
                        X                                       
diff --git a/bindings/c/DEPENDENCIES.rust.tsv b/bindings/c/DEPENDENCIES.rust.tsv
index 9f5c62a9..eaafce63 100644
--- a/bindings/c/DEPENDENCIES.rust.tsv
+++ b/bindings/c/DEPENDENCIES.rust.tsv
@@ -110,7 +110,7 @@ [email protected]            X                               
                                        X
 [email protected]                X                                               
                        X                               
 [email protected]                X                                               
                        X                               
 [email protected]              X                                               
                        X                               
[email protected]                                                                      
                X                               
[email protected]                                                                      
                X                               
 [email protected]             X                                                       
                X                               
 [email protected]               X                                               
                        X                               
 [email protected]               X                                               
                        X                               
diff --git a/bindings/go/DEPENDENCIES.rust.tsv 
b/bindings/go/DEPENDENCIES.rust.tsv
index 9f5c62a9..eaafce63 100644
--- a/bindings/go/DEPENDENCIES.rust.tsv
+++ b/bindings/go/DEPENDENCIES.rust.tsv
@@ -110,7 +110,7 @@ [email protected]            X                               
                                        X
 [email protected]                X                                               
                        X                               
 [email protected]                X                                               
                        X                               
 [email protected]              X                                               
                        X                               
[email protected]                                                                      
                X                               
[email protected]                                                                      
                X                               
 [email protected]             X                                                       
                X                               
 [email protected]               X                                               
                        X                               
 [email protected]               X                                               
                        X                               
diff --git a/bindings/python/DEPENDENCIES.rust.tsv 
b/bindings/python/DEPENDENCIES.rust.tsv
index e3ec6090..568d06c6 100644
--- a/bindings/python/DEPENDENCIES.rust.tsv
+++ b/bindings/python/DEPENDENCIES.rust.tsv
@@ -189,7 +189,7 @@ [email protected]             X                               
                                                X
 [email protected]                X                                               
                                X                                               
        
 [email protected]             X                                                       
                        X                                                       
 [email protected]              X                                               
                                X                                               
        
[email protected]                                                                      
                        X                                                       
[email protected]                                                                      
                        X                                                       
 [email protected]             X                                                       
                        X                                                       
 [email protected]               X                                               
                                X                                               
        
 [email protected]               X                                               
                                X                                               
        
diff --git a/crates/integration_tests/DEPENDENCIES.rust.tsv 
b/crates/integration_tests/DEPENDENCIES.rust.tsv
index 73588751..8a8add7b 100644
--- a/crates/integration_tests/DEPENDENCIES.rust.tsv
+++ b/crates/integration_tests/DEPENDENCIES.rust.tsv
@@ -110,7 +110,7 @@ [email protected]            X                               
                                        X
 [email protected]                X                                               
                        X                               
 [email protected]                X                                               
                        X                               
 [email protected]              X                                               
                        X                               
[email protected]                                                                      
                X                               
[email protected]                                                                      
                X                               
 [email protected]             X                                                       
                X                               
 [email protected]               X                                               
                        X                               
 [email protected]               X                                               
                        X                               
diff --git a/crates/integrations/datafusion/DEPENDENCIES.rust.tsv 
b/crates/integrations/datafusion/DEPENDENCIES.rust.tsv
index 3089ed33..de5d60d6 100644
--- a/crates/integrations/datafusion/DEPENDENCIES.rust.tsv
+++ b/crates/integrations/datafusion/DEPENDENCIES.rust.tsv
@@ -202,7 +202,7 @@ [email protected]             X                               
                                        X
 [email protected]                X                                               
                        X                                                       
 [email protected]             X                                                       
                X                                                       
 [email protected]              X                                               
                        X                                                       
[email protected]                                                                      
                X                                                       
[email protected]                                                                      
                X                                                       
 [email protected]             X                                                       
                X                                                       
 [email protected]               X                                               
                        X                                                       
 [email protected]               X                                               
                        X                                                       
diff --git a/crates/paimon-rest-server/DEPENDENCIES.rust.tsv 
b/crates/paimon-rest-server/DEPENDENCIES.rust.tsv
index 80ae8801..6b36f7ef 100644
--- a/crates/paimon-rest-server/DEPENDENCIES.rust.tsv
+++ b/crates/paimon-rest-server/DEPENDENCIES.rust.tsv
@@ -113,7 +113,7 @@ [email protected]            X                               
                                        X
 [email protected]                X                                               
                        X                               
 [email protected]                X                                               
                        X                               
 [email protected]              X                                               
                        X                               
[email protected]                                                                      
                X                               
[email protected]                                                                      
                X                               
 [email protected]             X                                                       
                X                               
 [email protected]               X                                               
                        X                               
 [email protected]               X                                               
                        X                               
diff --git a/crates/paimon/DEPENDENCIES.rust.tsv 
b/crates/paimon/DEPENDENCIES.rust.tsv
index 89b76f4f..d8dceab8 100644
--- a/crates/paimon/DEPENDENCIES.rust.tsv
+++ b/crates/paimon/DEPENDENCIES.rust.tsv
@@ -175,7 +175,7 @@ [email protected]             X                               
                                        X
 [email protected]                X                                               
                        X                                               
 [email protected]             X                                                       
                X                                               
 [email protected]              X                                               
                        X                                               
[email protected]                                                                      
                X                                               
[email protected]                                                                      
                X                                               
 [email protected]             X                                                       
                X                                               
 [email protected]               X                                               
                        X                                               
 [email protected]               X                                               
                        X                                               
diff --git a/crates/paimon/src/spec/types.rs b/crates/paimon/src/spec/types.rs
index 6401415d..46d664db 100644
--- a/crates/paimon/src/spec/types.rs
+++ b/crates/paimon/src/spec/types.rs
@@ -1537,7 +1537,11 @@ pub struct VarCharType {
 
 impl Display for VarCharType {
     fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
-        write!(f, "VARCHAR({})", self.length)?;
+        if self.length == Self::MAX_LENGTH {
+            write!(f, "{STRING_TYPE_NAME}")?;
+        } else {
+            write!(f, "VARCHAR({})", self.length)?;
+        }
         if !self.nullable {
             write!(f, " NOT NULL")?;
         }
@@ -2534,24 +2538,32 @@ mod tests {
         }
     }
 
-    /// Regression: `MAX_LENGTH` for `VarCharType`/`VarBinaryType` must fit in 
a
-    /// Java `int`, otherwise `DataTypeJsonParser` rejects the 
`CreateTableRequest`
-    /// REST payload with `NumberFormatException` on `Integer.parseInt`.
     #[test]
-    fn test_max_length_fits_java_integer() {
+    fn test_string_type_serializes_like_java() {
+        let nullable = DataType::VarChar(VarCharType::string_type());
+        assert_eq!(serde_json::to_string(&nullable).unwrap(), r#""STRING""#);
+
+        let not_null =
+            DataType::VarChar(VarCharType::with_nullable(false, 
VarCharType::MAX_LENGTH).unwrap());
+        assert_eq!(
+            serde_json::to_string(&not_null).unwrap(),
+            r#""STRING NOT NULL""#
+        );
+
+        let bounded = DataType::VarChar(VarCharType::new(42).unwrap());
+        assert_eq!(serde_json::to_string(&bounded).unwrap(), 
r#""VARCHAR(42)""#);
+    }
+
+    /// Regression: `MAX_LENGTH` must match Java's `Integer.MAX_VALUE` even 
though
+    /// an unbounded `VarCharType` is serialized through Java's `STRING` alias.
+    #[test]
+    fn test_max_length_matches_java_integer() {
         const JAVA_INTEGER_MAX_VALUE: u32 = i32::MAX as u32;
 
         assert_eq!(VarCharType::MAX_LENGTH, JAVA_INTEGER_MAX_VALUE);
         assert_eq!(VarBinaryType::MAX_LENGTH, JAVA_INTEGER_MAX_VALUE);
 
-        let varchar = VarCharType::string_type().to_string();
-        let length_token = varchar
-            .strip_prefix("VARCHAR(")
-            .and_then(|s| s.split(')').next())
-            .expect("VARCHAR display format");
-        length_token
-            .parse::<i32>()
-            .expect("VARCHAR length must parse as Java int");
+        assert_eq!(VarCharType::string_type().to_string(), STRING_TYPE_NAME);
 
         let varbinary = VarBinaryType::try_new(true, VarBinaryType::MAX_LENGTH)
             .unwrap()

Reply via email to