luoyuxia commented on code in PR #53:
URL: https://github.com/apache/fluss-rust/pull/53#discussion_r2573089760


##########
crates/fluss/src/metadata/json_serde.rs:
##########
@@ -150,18 +169,85 @@ impl JsonSerde for DataType {
             "BIGINT" => DataTypes::bigint(),
             "FLOAT" => DataTypes::float(),
             "DOUBLE" => DataTypes::double(),
-            "CHAR" => todo!(),
+            "CHAR" => {
+                let length = node
+                    .get(Self::FIELD_NAME_LENGTH)
+                    .and_then(|v| v.as_u64())
+                    .unwrap_or(1) as u32;
+                DataTypes::char(length)
+            },
             "STRING" => DataTypes::string(),
-            "DECIMAL" => todo!(),
+            "DECIMAL" => {
+                let precision = node
+                    .get(Self::FIELD_NAME_PRECISION)
+                    .and_then(|v| v.as_u64())
+                    .unwrap_or(10) as u32;

Review Comment:
   dito
   Let's throw error



##########
crates/fluss/src/metadata/json_serde.rs:
##########
@@ -462,3 +593,43 @@ impl JsonSerde for TableDescriptor {
         builder.build()
     }
 }
+
+#[cfg(test)]
+mod tests {
+    use super::*;
+    use crate::metadata::DataTypes;
+
+    #[test]
+    fn test_datatype_json_serde() {
+        let data_types = vec![
+            DataTypes::boolean(),
+            DataTypes::tinyint(),
+            DataTypes::smallint(),
+            DataTypes::int(),
+            DataTypes::bigint(),
+            DataTypes::float(),
+            DataTypes::double(),
+            DataTypes::char(10),
+            DataTypes::string(),
+            DataTypes::decimal(10, 2),
+            DataTypes::date(),
+            DataTypes::time(),
+            DataTypes::timestamp(),
+            DataTypes::timestamp_ltz(),
+            DataTypes::bytes(),
+            DataTypes::binary(100),
+            DataTypes::array(DataTypes::int()),
+            DataTypes::map(DataTypes::string(), DataTypes::int()),
+            DataTypes::row(vec![
+            crate::metadata::DataField::new("f1".to_string(), 
DataTypes::int(), None),

Review Comment:
   nit:
   ```suggestion
               DataField::new("f1".to_string(), DataTypes::int(), None),
   ```



##########
crates/fluss/src/metadata/json_serde.rs:
##########
@@ -150,18 +169,85 @@ impl JsonSerde for DataType {
             "BIGINT" => DataTypes::bigint(),
             "FLOAT" => DataTypes::float(),
             "DOUBLE" => DataTypes::double(),
-            "CHAR" => todo!(),
+            "CHAR" => {
+                let length = node
+                    .get(Self::FIELD_NAME_LENGTH)
+                    .and_then(|v| v.as_u64())
+                    .unwrap_or(1) as u32;

Review Comment:
   Let's throw error when field name not exist.



##########
crates/fluss/src/metadata/json_serde.rs:
##########
@@ -462,3 +593,43 @@ impl JsonSerde for TableDescriptor {
         builder.build()
     }
 }
+
+#[cfg(test)]
+mod tests {
+    use super::*;
+    use crate::metadata::DataTypes;
+
+    #[test]
+    fn test_datatype_json_serde() {
+        let data_types = vec![
+            DataTypes::boolean(),
+            DataTypes::tinyint(),
+            DataTypes::smallint(),
+            DataTypes::int(),

Review Comment:
   nit:
   ```suggestion
               DataTypes::int().as_non_nullable(),
   ```
   to verify non nullable type



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