diff --git a/src/catalog/src/information_schema/tables.rs b/src/catalog/src/information_schema/tables.rs index 9957f6715458..ef8eee267289 100644 --- a/src/catalog/src/information_schema/tables.rs +++ b/src/catalog/src/information_schema/tables.rs @@ -304,10 +304,11 @@ impl InformationSchemaTablesBuilder { self.update_time.push(None); self.check_time.push(None); + // use mariadb default table version number here self.version.push(Some(11)); self.table_comment.push(table_info.desc.as_deref()); self.create_options - .push(Some(format!("{:?}", table_info.meta.options).as_ref())); + .push(Some(table_info.meta.options.to_string().as_ref())); self.create_time .push(Some(table_info.meta.created_on.timestamp_millis().into())); diff --git a/src/table/src/requests.rs b/src/table/src/requests.rs index 519ee2adb62b..a00b25eacb13 100644 --- a/src/table/src/requests.rs +++ b/src/table/src/requests.rs @@ -15,6 +15,7 @@ //! Table and TableEngine requests use std::collections::HashMap; +use std::fmt; use std::str::FromStr; use std::time::Duration; @@ -128,6 +129,25 @@ impl TableOptions { } } +impl fmt::Display for TableOptions { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + let mut key_vals = vec![]; + if let Some(size) = self.write_buffer_size { + key_vals.push(format!("{}={}", WRITE_BUFFER_SIZE_KEY, size)); + } + + if let Some(ttl) = self.ttl { + key_vals.push(format!("{}={}", TTL_KEY, humantime::Duration::from(ttl))); + } + + for (k, v) in &self.extra_options { + key_vals.push(format!("{}={}", k, v)); + } + + write!(f, "{}", key_vals.join(" ")) + } +} + impl From<&TableOptions> for HashMap { fn from(opts: &TableOptions) -> Self { let mut res = HashMap::with_capacity(2 + opts.extra_options.len()); @@ -345,4 +365,29 @@ mod tests { let serialized = TableOptions::try_from_iter(&serialized_map).unwrap(); assert_eq!(options, serialized); } + + #[test] + fn test_table_options_to_string() { + let options = TableOptions { + write_buffer_size: Some(ReadableSize::mb(128)), + ttl: Some(Duration::from_secs(1000)), + extra_options: HashMap::new(), + }; + + assert_eq!( + "write_buffer_size=128.0MiB ttl=16m 40s", + options.to_string() + ); + + let options = TableOptions { + write_buffer_size: Some(ReadableSize::mb(128)), + ttl: Some(Duration::from_secs(1000)), + extra_options: HashMap::from([("a".to_string(), "A".to_string())]), + }; + + assert_eq!( + "write_buffer_size=128.0MiB ttl=16m 40s a=A", + options.to_string() + ); + } }