Skip to content

Commit

Permalink
fix: 10000 years --> forever
Browse files Browse the repository at this point in the history
  • Loading branch information
discord9 committed Dec 4, 2024
1 parent 449c1c0 commit 9d8b08d
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 5 deletions.
7 changes: 5 additions & 2 deletions src/common/base/src/ttl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use serde::{Deserialize, Serialize};
/// Time To Live
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Clone, Copy, Default)]
pub enum TimeToLive {
/// immediately throw away on insert
/// Immediately throw away on insert
Immediate,
/// Duration to keep the data, this duration should be non-zero
Duration(Duration),
Expand Down Expand Up @@ -56,6 +56,7 @@ impl<'de> Deserialize<'de> for TimeToLive {
formatter.write_str("a string of time, 'immediate', 'forever' or null")
}

/// Correctly deserialize null in json
fn visit_unit<E>(self) -> Result<Self::Value, E> {
Ok(TimeToLive::Forever)
}
Expand Down Expand Up @@ -84,7 +85,9 @@ impl Display for TimeToLive {
}

impl TimeToLive {
/// Parse a string into TimeToLive
/// Parse a string that is either `immediate`, `forever`, or a duration to `TimeToLive`
///
/// note that a empty string is treat as `forever` too
pub fn from_humantime_or_str(s: &str) -> Result<Self, String> {
match s {
"immediate" => Ok(TimeToLive::Immediate),
Expand Down
4 changes: 2 additions & 2 deletions src/metric-engine/src/engine/create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,7 @@ pub(crate) fn region_options_for_metadata_region(
mut original: HashMap<String, String>,
) -> HashMap<String, String> {
original.remove(APPEND_MODE_KEY);
original.insert(TTL_KEY.to_string(), "10000 years".to_string());
original.insert(TTL_KEY.to_string(), "forever".to_string());
original
}

Expand Down Expand Up @@ -731,7 +731,7 @@ mod test {
);
assert_eq!(
metadata_region_request.options.get("ttl").unwrap(),
"10000 years"
"forever"
);
}
}
3 changes: 3 additions & 0 deletions tests/cases/standalone/common/alter/alter_database.result
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ SHOW CREATE DATABASE alter_database;
| Database | Create Database |
+----------------+----------------------------------------------+
| alter_database | CREATE DATABASE IF NOT EXISTS alter_database |
| | WITH( |
| | ttl = 'forever' |
| | ) |
+----------------+----------------------------------------------+

ALTER DATABASE alter_database SET 'ttl'='😁';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,9 @@ SHOW CREATE TABLE ato;
| | ) |
| | |
| | ENGINE=mito |
| | |
| | WITH( |
| | ttl = 'forever' |
| | ) |
+-------+------------------------------------+

ALTER TABLE ato SET 'ttl'='1s';
Expand Down

0 comments on commit 9d8b08d

Please sign in to comment.