Skip to content

Commit ef5c8bf

Browse files
authored
chore: rename default_cluster_key_id to cluster_key_seq (#17135)
* chore: rename default_cluster_key_id to cluster_key_seq * fix
1 parent f1c95cc commit ef5c8bf

28 files changed

+67
-65
lines changed

src/meta/app/src/schema/table.rs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -260,10 +260,12 @@ pub struct TableMeta {
260260
pub storage_params: Option<StorageParams>,
261261
pub part_prefix: String,
262262
pub options: BTreeMap<String, String>,
263-
// The default cluster key.
264-
pub default_cluster_key: Option<String>,
265-
// The sequence number of default_cluster_key.
266-
pub default_cluster_key_id: u32,
263+
pub cluster_key: Option<String>,
264+
/// A sequential number that uniquely identifies changes to the cluster key.
265+
/// This value increments by 1 each time the cluster key is created or modified,
266+
/// ensuring a unique identifier for each version of the cluster key.
267+
/// It remains unchanged when the cluster key is dropped.
268+
pub cluster_key_seq: u32,
267269
pub created_on: DateTime<Utc>,
268270
pub updated_on: DateTime<Utc>,
269271
pub comment: String,
@@ -408,9 +410,9 @@ impl TableInfo {
408410

409411
pub fn cluster_key(&self) -> Option<(u32, String)> {
410412
self.meta
411-
.default_cluster_key
413+
.cluster_key
412414
.clone()
413-
.map(|k| (self.meta.default_cluster_key_id, k))
415+
.map(|k| (self.meta.cluster_key_seq, k))
414416
}
415417
}
416418

@@ -423,8 +425,8 @@ impl Default for TableMeta {
423425
storage_params: None,
424426
part_prefix: "".to_string(),
425427
options: BTreeMap::new(),
426-
default_cluster_key: None,
427-
default_cluster_key_id: 0,
428+
cluster_key: None,
429+
cluster_key_seq: 0,
428430
created_on: Utc::now(),
429431
updated_on: Utc::now(),
430432
comment: "".to_string(),

src/meta/proto-conv/src/table_from_to_protobuf_impl.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,8 @@ impl FromToProto for mt::TableMeta {
192192
indexes.insert(name, mt::TableIndex::from_pb(index)?);
193193
}
194194

195-
let default_cluster_key_id = if let Some(cluster_key_id) = p.default_cluster_key_id {
196-
cluster_key_id
195+
let cluster_key_seq = if let Some(seq) = p.cluster_key_seq {
196+
seq
197197
} else if p.cluster_keys.is_empty() {
198198
0
199199
} else {
@@ -210,8 +210,8 @@ impl FromToProto for mt::TableMeta {
210210
},
211211
part_prefix: p.part_prefix.unwrap_or("".to_string()),
212212
options: p.options,
213-
default_cluster_key: p.default_cluster_key,
214-
default_cluster_key_id,
213+
cluster_key: p.cluster_key,
214+
cluster_key_seq,
215215
created_on: DateTime::<Utc>::from_pb(p.created_on)?,
216216
updated_on: DateTime::<Utc>::from_pb(p.updated_on)?,
217217
drop_on: match p.drop_on {
@@ -257,10 +257,10 @@ impl FromToProto for mt::TableMeta {
257257
Some(self.part_prefix.clone())
258258
},
259259
options: self.options.clone(),
260-
default_cluster_key: self.default_cluster_key.clone(),
260+
cluster_key: self.cluster_key.clone(),
261261
// cluster_keys is deprecated.
262262
cluster_keys: vec![],
263-
default_cluster_key_id: Some(self.default_cluster_key_id),
263+
cluster_key_seq: Some(self.cluster_key_seq),
264264
created_on: self.created_on.to_pb()?,
265265
updated_on: self.updated_on.to_pb()?,
266266
drop_on: match self.drop_on {

src/meta/proto-conv/tests/it/proto_conv.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,8 @@ fn new_table_meta() -> mt::TableMeta {
140140
part_prefix: "".to_string(),
141141
engine_options: btreemap! {s("abc") => s("def")},
142142
options: btreemap! {s("xyz") => s("foo")},
143-
default_cluster_key: Some("(a + 2, b)".to_string()),
144-
default_cluster_key_id: 0,
143+
cluster_key: Some("(a + 2, b)".to_string()),
144+
cluster_key_seq: 0,
145145
created_on: Utc.with_ymd_and_hms(2014, 11, 28, 12, 0, 9).unwrap(),
146146
updated_on: Utc.with_ymd_and_hms(2014, 11, 29, 12, 0, 10).unwrap(),
147147
comment: s("table_comment"),

src/meta/proto-conv/tests/it/v002_table_meta.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,8 @@ fn test_decode_v2_table_meta() -> anyhow::Result<()> {
131131
part_prefix: "".to_string(),
132132
engine_options: btreemap! {s("abc") => s("def")},
133133
options: btreemap! {s("xyz") => s("foo")},
134-
default_cluster_key: Some("(a + 2, b)".to_string()),
135-
default_cluster_key_id: 0,
134+
cluster_key: Some("(a + 2, b)".to_string()),
135+
cluster_key_seq: 0,
136136
created_on: Utc.with_ymd_and_hms(2014, 11, 28, 12, 0, 9).unwrap(),
137137
updated_on: Utc.with_ymd_and_hms(2014, 11, 29, 12, 0, 10).unwrap(),
138138
comment: s("table_comment"),

src/meta/proto-conv/tests/it/v010_table_meta.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,8 @@ fn test_decode_v10_table_meta() -> anyhow::Result<()> {
133133
storage_params: None,
134134
part_prefix: "".to_string(),
135135
options: btreemap! {s("xyz") => s("foo")},
136-
default_cluster_key: Some("(a + 2, b)".to_string()),
137-
default_cluster_key_id: 0,
136+
cluster_key: Some("(a + 2, b)".to_string()),
137+
cluster_key_seq: 0,
138138
created_on: Utc.with_ymd_and_hms(2014, 11, 28, 12, 0, 9).unwrap(),
139139
updated_on: Utc.with_ymd_and_hms(2014, 11, 29, 12, 0, 10).unwrap(),
140140
comment: s("table_comment"),

src/meta/proto-conv/tests/it/v012_table_meta.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,8 @@ fn test_decode_v12_table_meta() -> anyhow::Result<()> {
135135
storage_params: Some(StorageParams::default()),
136136
part_prefix: "".to_string(),
137137
options: btreemap! {s("xyz") => s("foo")},
138-
default_cluster_key: Some("(a + 2, b)".to_string()),
139-
default_cluster_key_id: 0,
138+
cluster_key: Some("(a + 2, b)".to_string()),
139+
cluster_key_seq: 0,
140140
created_on: Utc.with_ymd_and_hms(2014, 11, 28, 12, 0, 9).unwrap(),
141141
updated_on: Utc.with_ymd_and_hms(2014, 11, 29, 12, 0, 10).unwrap(),
142142
comment: s("table_comment"),

src/meta/proto-conv/tests/it/v023_table_meta.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,8 @@ fn test_decode_v23_table_meta() -> anyhow::Result<()> {
135135
storage_params: Some(StorageParams::default()),
136136
part_prefix: "lulu_".to_string(),
137137
options: btreemap! {s("xyz") => s("foo")},
138-
default_cluster_key: Some("(a + 2, b)".to_string()),
139-
default_cluster_key_id: 0,
138+
cluster_key: Some("(a + 2, b)".to_string()),
139+
cluster_key_seq: 0,
140140
created_on: Utc.with_ymd_and_hms(2014, 11, 28, 12, 0, 9).unwrap(),
141141
updated_on: Utc.with_ymd_and_hms(2014, 11, 29, 12, 0, 10).unwrap(),
142142
comment: s("table_comment"),

src/meta/proto-conv/tests/it/v024_table_meta.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,8 @@ fn test_decode_v24_table_meta() -> anyhow::Result<()> {
135135
storage_params: Some(StorageParams::default()),
136136
part_prefix: "lulu_".to_string(),
137137
options: btreemap! {s("xyz") => s("foo")},
138-
default_cluster_key: Some("(a + 2, b)".to_string()),
139-
default_cluster_key_id: 0,
138+
cluster_key: Some("(a + 2, b)".to_string()),
139+
cluster_key_seq: 0,
140140
created_on: Utc.with_ymd_and_hms(2014, 11, 28, 12, 0, 9).unwrap(),
141141
updated_on: Utc.with_ymd_and_hms(2014, 11, 29, 12, 0, 10).unwrap(),
142142
comment: s("table_comment"),

src/meta/proto-conv/tests/it/v033_table_meta.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,8 @@ fn test_decode_v33_table_meta() -> anyhow::Result<()> {
137137
part_prefix: "".to_string(),
138138
engine_options: btreemap! {s("abc") => s("def")},
139139
options: btreemap! {s("xyz") => s("foo")},
140-
default_cluster_key: Some("(a + 2, b)".to_string()),
141-
default_cluster_key_id: 0,
140+
cluster_key: Some("(a + 2, b)".to_string()),
141+
cluster_key_seq: 0,
142142
created_on: Utc.with_ymd_and_hms(2014, 11, 28, 12, 0, 9).unwrap(),
143143
updated_on: Utc.with_ymd_and_hms(2014, 11, 29, 12, 0, 10).unwrap(),
144144
comment: s("table_comment"),

src/meta/proto-conv/tests/it/v040_table_meta.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,8 @@ fn test_decode_v40_table_meta() -> anyhow::Result<()> {
137137
part_prefix: "".to_string(),
138138
engine_options: btreemap! {s("abc") => s("def")},
139139
options: btreemap! {s("xyz") => s("foo")},
140-
default_cluster_key: Some("(a + 2, b)".to_string()),
141-
default_cluster_key_id: 0,
140+
cluster_key: Some("(a + 2, b)".to_string()),
141+
cluster_key_seq: 0,
142142
created_on: Utc.with_ymd_and_hms(2014, 11, 28, 12, 0, 9).unwrap(),
143143
updated_on: Utc.with_ymd_and_hms(2014, 11, 29, 12, 0, 10).unwrap(),
144144
comment: s("table_comment"),

0 commit comments

Comments
 (0)