mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-06-01 04:40:39 +00:00
chore: upgrade some dependencies (#5777)
* chore: upgrade some dependencies * chore: upgrade some dependencies * fix: cr * fix: ci * fix: test * fix: cargo fmt
This commit is contained in:
@@ -40,7 +40,7 @@ fn add_column_options_generator<R: Rng>(
|
||||
// 0 -> NULL
|
||||
// 1 -> DEFAULT VALUE
|
||||
// 2 -> PRIMARY KEY + DEFAULT VALUE
|
||||
let idx = rng.gen_range(0..3);
|
||||
let idx = rng.random_range(0..3);
|
||||
match idx {
|
||||
0 => vec![ColumnOption::Null],
|
||||
1 => {
|
||||
@@ -79,15 +79,15 @@ impl<R: Rng + 'static> Generator<AlterTableExpr, R> for AlterExprAddColumnGenera
|
||||
type Error = Error;
|
||||
|
||||
fn generate(&self, rng: &mut R) -> Result<AlterTableExpr> {
|
||||
let with_location = self.location && rng.gen::<bool>();
|
||||
let with_location = self.location && rng.random::<bool>();
|
||||
let location = if with_location {
|
||||
let use_first = rng.gen::<bool>();
|
||||
let use_first = rng.random::<bool>();
|
||||
let location = if use_first {
|
||||
AddColumnLocation::First
|
||||
} else {
|
||||
AddColumnLocation::After {
|
||||
column_name: self.table_ctx.columns
|
||||
[rng.gen_range(0..self.table_ctx.columns.len())]
|
||||
[rng.random_range(0..self.table_ctx.columns.len())]
|
||||
.name
|
||||
.to_string(),
|
||||
}
|
||||
@@ -129,7 +129,7 @@ impl<R: Rng> Generator<AlterTableExpr, R> for AlterExprDropColumnGenerator<R> {
|
||||
fn generate(&self, rng: &mut R) -> Result<AlterTableExpr> {
|
||||
let droppable = droppable_columns(&self.table_ctx.columns);
|
||||
ensure!(!droppable.is_empty(), error::DroppableColumnsSnafu);
|
||||
let name = droppable[rng.gen_range(0..droppable.len())].name.clone();
|
||||
let name = droppable[rng.random_range(0..droppable.len())].name.clone();
|
||||
Ok(AlterTableExpr {
|
||||
table_name: self.table_ctx.name.clone(),
|
||||
alter_kinds: AlterTableOperation::DropColumn { name },
|
||||
@@ -174,7 +174,7 @@ impl<R: Rng> Generator<AlterTableExpr, R> for AlterExprModifyDataTypeGenerator<R
|
||||
|
||||
fn generate(&self, rng: &mut R) -> Result<AlterTableExpr> {
|
||||
let modifiable = modifiable_columns(&self.table_ctx.columns);
|
||||
let changed = modifiable[rng.gen_range(0..modifiable.len())].clone();
|
||||
let changed = modifiable[rng.random_range(0..modifiable.len())].clone();
|
||||
let mut to_type = self.column_type_generator.gen(rng);
|
||||
while !changed.column_type.can_arrow_type_cast_to(&to_type) {
|
||||
to_type = self.column_type_generator.gen(rng);
|
||||
@@ -209,8 +209,8 @@ impl<R: Rng> Generator<AlterTableExpr, R> for AlterExprSetTableOptionsGenerator<
|
||||
let all_options = AlterTableOption::iter().collect::<Vec<_>>();
|
||||
// Generate random distinct options
|
||||
let mut option_templates_idx = vec![];
|
||||
for _ in 1..rng.gen_range(2..=all_options.len()) {
|
||||
let option = rng.gen_range(0..all_options.len());
|
||||
for _ in 1..rng.random_range(2..=all_options.len()) {
|
||||
let option = rng.random_range(0..all_options.len());
|
||||
if !option_templates_idx.contains(&option) {
|
||||
option_templates_idx.push(option);
|
||||
}
|
||||
@@ -219,10 +219,10 @@ impl<R: Rng> Generator<AlterTableExpr, R> for AlterExprSetTableOptionsGenerator<
|
||||
.iter()
|
||||
.map(|idx| match all_options[*idx] {
|
||||
AlterTableOption::Ttl(_) => {
|
||||
let ttl_type = rng.gen_range(0..3);
|
||||
let ttl_type = rng.random_range(0..3);
|
||||
match ttl_type {
|
||||
0 => {
|
||||
let duration: u32 = rng.gen();
|
||||
let duration: u32 = rng.random();
|
||||
AlterTableOption::Ttl(Ttl::Duration((duration as i64).into()))
|
||||
}
|
||||
1 => AlterTableOption::Ttl(Ttl::Instant),
|
||||
@@ -231,27 +231,27 @@ impl<R: Rng> Generator<AlterTableExpr, R> for AlterExprSetTableOptionsGenerator<
|
||||
}
|
||||
}
|
||||
AlterTableOption::TwcsTimeWindow(_) => {
|
||||
let time_window: u32 = rng.gen();
|
||||
let time_window: u32 = rng.random();
|
||||
AlterTableOption::TwcsTimeWindow((time_window as i64).into())
|
||||
}
|
||||
AlterTableOption::TwcsMaxOutputFileSize(_) => {
|
||||
let max_output_file_size: u64 = rng.gen();
|
||||
let max_output_file_size: u64 = rng.random();
|
||||
AlterTableOption::TwcsMaxOutputFileSize(ReadableSize(max_output_file_size))
|
||||
}
|
||||
AlterTableOption::TwcsMaxInactiveWindowRuns(_) => {
|
||||
let max_inactive_window_runs: u64 = rng.gen();
|
||||
let max_inactive_window_runs: u64 = rng.random();
|
||||
AlterTableOption::TwcsMaxInactiveWindowRuns(max_inactive_window_runs)
|
||||
}
|
||||
AlterTableOption::TwcsMaxActiveWindowFiles(_) => {
|
||||
let max_active_window_files: u64 = rng.gen();
|
||||
let max_active_window_files: u64 = rng.random();
|
||||
AlterTableOption::TwcsMaxActiveWindowFiles(max_active_window_files)
|
||||
}
|
||||
AlterTableOption::TwcsMaxActiveWindowRuns(_) => {
|
||||
let max_active_window_runs: u64 = rng.gen();
|
||||
let max_active_window_runs: u64 = rng.random();
|
||||
AlterTableOption::TwcsMaxActiveWindowRuns(max_active_window_runs)
|
||||
}
|
||||
AlterTableOption::TwcsMaxInactiveWindowFiles(_) => {
|
||||
let max_inactive_window_files: u64 = rng.gen();
|
||||
let max_inactive_window_files: u64 = rng.random();
|
||||
AlterTableOption::TwcsMaxInactiveWindowFiles(max_inactive_window_files)
|
||||
}
|
||||
})
|
||||
@@ -279,8 +279,8 @@ impl<R: Rng> Generator<AlterTableExpr, R> for AlterExprUnsetTableOptionsGenerato
|
||||
let all_options = AlterTableOption::iter().collect::<Vec<_>>();
|
||||
// Generate random distinct options
|
||||
let mut option_templates_idx = vec![];
|
||||
for _ in 1..rng.gen_range(2..=all_options.len()) {
|
||||
let option = rng.gen_range(0..all_options.len());
|
||||
for _ in 1..rng.random_range(2..=all_options.len()) {
|
||||
let option = rng.random_range(0..all_options.len());
|
||||
if !option_templates_idx.contains(&option) {
|
||||
option_templates_idx.push(option);
|
||||
}
|
||||
@@ -325,7 +325,7 @@ mod tests {
|
||||
.generate(&mut rng)
|
||||
.unwrap();
|
||||
let serialized = serde_json::to_string(&expr).unwrap();
|
||||
let expected = r#"{"table_name":{"value":"animI","quote_style":null},"alter_kinds":{"AddColumn":{"column":{"name":{"value":"velit","quote_style":null},"column_type":{"Int32":{}},"options":[{"DefaultValue":{"Int32":1606462472}}]},"location":null}}}"#;
|
||||
let expected = r#"{"table_name":{"value":"quasi","quote_style":null},"alter_kinds":{"AddColumn":{"column":{"name":{"value":"consequatur","quote_style":null},"column_type":{"Float64":{}},"options":[{"DefaultValue":{"Float64":0.48809950435391647}}]},"location":null}}}"#;
|
||||
assert_eq!(expected, serialized);
|
||||
|
||||
let expr = AlterExprRenameGeneratorBuilder::default()
|
||||
@@ -335,7 +335,7 @@ mod tests {
|
||||
.generate(&mut rng)
|
||||
.unwrap();
|
||||
let serialized = serde_json::to_string(&expr).unwrap();
|
||||
let expected = r#"{"table_name":{"value":"animI","quote_style":null},"alter_kinds":{"RenameTable":{"new_table_name":{"value":"nihil","quote_style":null}}}}"#;
|
||||
let expected = r#"{"table_name":{"value":"quasi","quote_style":null},"alter_kinds":{"RenameTable":{"new_table_name":{"value":"voluptates","quote_style":null}}}}"#;
|
||||
assert_eq!(expected, serialized);
|
||||
|
||||
let expr = AlterExprDropColumnGeneratorBuilder::default()
|
||||
@@ -345,7 +345,7 @@ mod tests {
|
||||
.generate(&mut rng)
|
||||
.unwrap();
|
||||
let serialized = serde_json::to_string(&expr).unwrap();
|
||||
let expected = r#"{"table_name":{"value":"animI","quote_style":null},"alter_kinds":{"DropColumn":{"name":{"value":"cUmquE","quote_style":null}}}}"#;
|
||||
let expected = r#"{"table_name":{"value":"quasi","quote_style":null},"alter_kinds":{"DropColumn":{"name":{"value":"ImPEDiT","quote_style":null}}}}"#;
|
||||
assert_eq!(expected, serialized);
|
||||
|
||||
let expr = AlterExprModifyDataTypeGeneratorBuilder::default()
|
||||
@@ -355,7 +355,7 @@ mod tests {
|
||||
.generate(&mut rng)
|
||||
.unwrap();
|
||||
let serialized = serde_json::to_string(&expr).unwrap();
|
||||
let expected = r#"{"table_name":{"value":"animI","quote_style":null},"alter_kinds":{"ModifyDataType":{"column":{"name":{"value":"toTAm","quote_style":null},"column_type":{"Int64":{}},"options":[]}}}}"#;
|
||||
let expected = r#"{"table_name":{"value":"quasi","quote_style":null},"alter_kinds":{"ModifyDataType":{"column":{"name":{"value":"ADIpisci","quote_style":null},"column_type":{"Int64":{}},"options":[]}}}}"#;
|
||||
assert_eq!(expected, serialized);
|
||||
|
||||
let expr = AlterExprSetTableOptionsGeneratorBuilder::default()
|
||||
@@ -365,7 +365,7 @@ mod tests {
|
||||
.generate(&mut rng)
|
||||
.unwrap();
|
||||
let serialized = serde_json::to_string(&expr).unwrap();
|
||||
let expected = r#"{"table_name":{"value":"animI","quote_style":null},"alter_kinds":{"SetTableOptions":{"options":[{"TwcsMaxActiveWindowRuns":14908016120444947142},{"TwcsMaxActiveWindowFiles":5840340123887173415},{"TwcsMaxOutputFileSize":17740311466571102265}]}}}"#;
|
||||
let expected = r#"{"table_name":{"value":"quasi","quote_style":null},"alter_kinds":{"SetTableOptions":{"options":[{"TwcsMaxOutputFileSize":16770910638250818741}]}}}"#;
|
||||
assert_eq!(expected, serialized);
|
||||
|
||||
let expr = AlterExprUnsetTableOptionsGeneratorBuilder::default()
|
||||
@@ -375,7 +375,7 @@ mod tests {
|
||||
.generate(&mut rng)
|
||||
.unwrap();
|
||||
let serialized = serde_json::to_string(&expr).unwrap();
|
||||
let expected = r#"{"table_name":{"value":"animI","quote_style":null},"alter_kinds":{"UnsetTableOptions":{"keys":["compaction.twcs.max_active_window_runs"]}}}"#;
|
||||
let expected = r#"{"table_name":{"value":"quasi","quote_style":null},"alter_kinds":{"UnsetTableOptions":{"keys":["compaction.twcs.max_active_window_runs","compaction.twcs.max_output_file_size","compaction.twcs.time_window","compaction.twcs.max_inactive_window_files","compaction.twcs.max_active_window_files"]}}}"#;
|
||||
assert_eq!(expected, serialized);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -399,7 +399,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_create_table_expr_generator() {
|
||||
let mut rng = rand::thread_rng();
|
||||
let mut rng = rand::rng();
|
||||
|
||||
let expr = CreateTableExprGeneratorBuilder::default()
|
||||
.columns(10)
|
||||
@@ -440,13 +440,13 @@ mod tests {
|
||||
.unwrap();
|
||||
|
||||
let serialized = serde_json::to_string(&expr).unwrap();
|
||||
let expected = r#"{"table_name":{"value":"animI","quote_style":null},"columns":[{"name":{"value":"IMpEdIT","quote_style":null},"column_type":{"Float64":{}},"options":["PrimaryKey","NotNull"]},{"name":{"value":"natuS","quote_style":null},"column_type":{"Timestamp":{"Millisecond":null}},"options":["TimeIndex"]},{"name":{"value":"ADIPisCI","quote_style":null},"column_type":{"Float64":{}},"options":["Null"]},{"name":{"value":"EXpEdita","quote_style":null},"column_type":{"Int16":{}},"options":[{"DefaultValue":{"Int16":4864}}]},{"name":{"value":"cUlpA","quote_style":null},"column_type":{"Int64":{}},"options":["PrimaryKey"]},{"name":{"value":"MOLeStIAs","quote_style":null},"column_type":{"Float64":{}},"options":["NotNull"]},{"name":{"value":"cUmquE","quote_style":null},"column_type":{"Boolean":null},"options":["Null"]},{"name":{"value":"toTAm","quote_style":null},"column_type":{"Float32":{}},"options":[{"DefaultValue":{"Float32":0.21569687}}]},{"name":{"value":"deBitIs","quote_style":null},"column_type":{"Float64":{}},"options":["NotNull"]},{"name":{"value":"QUi","quote_style":null},"column_type":{"Float32":{}},"options":["Null"]}],"if_not_exists":true,"partition":{"partition_columns":["IMpEdIT"],"partition_bounds":[{"Expr":{"lhs":{"Column":"IMpEdIT"},"op":"Lt","rhs":{"Value":{"Float64":5.992310449541053e307}}}},{"Expr":{"lhs":{"Expr":{"lhs":{"Column":"IMpEdIT"},"op":"GtEq","rhs":{"Value":{"Float64":5.992310449541053e307}}}},"op":"And","rhs":{"Expr":{"lhs":{"Column":"IMpEdIT"},"op":"Lt","rhs":{"Value":{"Float64":1.1984620899082105e308}}}}}},{"Expr":{"lhs":{"Column":"IMpEdIT"},"op":"GtEq","rhs":{"Value":{"Float64":1.1984620899082105e308}}}}]},"engine":"mito2","options":{},"primary_keys":[0,4]}"#;
|
||||
let expected = r#"{"table_name":{"value":"quasi","quote_style":null},"columns":[{"name":{"value":"mOLEsTIAs","quote_style":null},"column_type":{"Float64":{}},"options":["PrimaryKey","Null"]},{"name":{"value":"CUMQUe","quote_style":null},"column_type":{"Timestamp":{"Second":null}},"options":["TimeIndex"]},{"name":{"value":"NaTus","quote_style":null},"column_type":{"Int64":{}},"options":[]},{"name":{"value":"EXPeDITA","quote_style":null},"column_type":{"Float64":{}},"options":[]},{"name":{"value":"ImPEDiT","quote_style":null},"column_type":{"Float32":{}},"options":[{"DefaultValue":{"Float32":0.56425774}}]},{"name":{"value":"ADIpisci","quote_style":null},"column_type":{"Float32":{}},"options":["PrimaryKey"]},{"name":{"value":"deBITIs","quote_style":null},"column_type":{"Float32":{}},"options":[{"DefaultValue":{"Float32":0.31315368}}]},{"name":{"value":"toTaM","quote_style":null},"column_type":{"Int32":{}},"options":["NotNull"]},{"name":{"value":"QuI","quote_style":null},"column_type":{"Float32":{}},"options":[{"DefaultValue":{"Float32":0.39941502}}]},{"name":{"value":"INVeNtOre","quote_style":null},"column_type":{"Boolean":null},"options":["PrimaryKey"]}],"if_not_exists":true,"partition":{"partition_columns":["mOLEsTIAs"],"partition_bounds":[{"Expr":{"lhs":{"Column":"mOLEsTIAs"},"op":"Lt","rhs":{"Value":{"Float64":5.992310449541053e307}}}},{"Expr":{"lhs":{"Expr":{"lhs":{"Column":"mOLEsTIAs"},"op":"GtEq","rhs":{"Value":{"Float64":5.992310449541053e307}}}},"op":"And","rhs":{"Expr":{"lhs":{"Column":"mOLEsTIAs"},"op":"Lt","rhs":{"Value":{"Float64":1.1984620899082105e308}}}}}},{"Expr":{"lhs":{"Column":"mOLEsTIAs"},"op":"GtEq","rhs":{"Value":{"Float64":1.1984620899082105e308}}}}]},"engine":"mito2","options":{},"primary_keys":[0,5,9]}"#;
|
||||
assert_eq!(expected, serialized);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_create_logical_table_expr_generator() {
|
||||
let mut rng = rand::thread_rng();
|
||||
let mut rng = rand::rng();
|
||||
|
||||
let physical_table_expr = CreatePhysicalTableExprGeneratorBuilder::default()
|
||||
.if_not_exists(false)
|
||||
@@ -529,13 +529,13 @@ mod tests {
|
||||
.unwrap();
|
||||
|
||||
let logical_table_serialized = serde_json::to_string(&logical_table_expr).unwrap();
|
||||
let logical_table_expected = r#"{"table_name":{"value":"impedit","quote_style":null},"columns":[{"name":{"value":"ts","quote_style":null},"column_type":{"Timestamp":{"Millisecond":null}},"options":["TimeIndex"]},{"name":{"value":"val","quote_style":null},"column_type":{"Float64":{}},"options":[]},{"name":{"value":"qui","quote_style":null},"column_type":{"String":null},"options":["PrimaryKey"]},{"name":{"value":"totam","quote_style":null},"column_type":{"String":null},"options":["PrimaryKey"]},{"name":{"value":"molestias","quote_style":null},"column_type":{"String":null},"options":["PrimaryKey"]},{"name":{"value":"natus","quote_style":null},"column_type":{"String":null},"options":["PrimaryKey"]},{"name":{"value":"cumque","quote_style":null},"column_type":{"String":null},"options":["PrimaryKey"]}],"if_not_exists":false,"partition":null,"engine":"metric","options":{"on_physical_table":{"String":"expedita"}},"primary_keys":[2,5,3,6,4]}"#;
|
||||
let logical_table_expected = r#"{"table_name":{"value":"impedit","quote_style":null},"columns":[{"name":{"value":"ts","quote_style":null},"column_type":{"Timestamp":{"Millisecond":null}},"options":["TimeIndex"]},{"name":{"value":"val","quote_style":null},"column_type":{"Float64":{}},"options":[]},{"name":{"value":"totam","quote_style":null},"column_type":{"String":null},"options":["PrimaryKey"]},{"name":{"value":"cumque","quote_style":null},"column_type":{"String":null},"options":["PrimaryKey"]},{"name":{"value":"natus","quote_style":null},"column_type":{"String":null},"options":["PrimaryKey"]},{"name":{"value":"molestias","quote_style":null},"column_type":{"String":null},"options":["PrimaryKey"]},{"name":{"value":"qui","quote_style":null},"column_type":{"String":null},"options":["PrimaryKey"]}],"if_not_exists":false,"partition":null,"engine":"metric","options":{"on_physical_table":{"String":"expedita"}},"primary_keys":[4,2,3,6,5]}"#;
|
||||
assert_eq!(logical_table_expected, logical_table_serialized);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_create_database_expr_generator() {
|
||||
let mut rng = rand::thread_rng();
|
||||
let mut rng = rand::rng();
|
||||
|
||||
let expr = CreateDatabaseExprGeneratorBuilder::default()
|
||||
.if_not_exists(true)
|
||||
@@ -558,7 +558,7 @@ mod tests {
|
||||
|
||||
let serialized = serde_json::to_string(&expr).unwrap();
|
||||
let expected =
|
||||
r#"{"database_name":{"value":"eXPedITa","quote_style":null},"if_not_exists":true}"#;
|
||||
r#"{"database_name":{"value":"EXPediTA","quote_style":null},"if_not_exists":true}"#;
|
||||
assert_eq!(expected, serialized);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ use std::marker::PhantomData;
|
||||
|
||||
use datatypes::value::Value;
|
||||
use derive_builder::Builder;
|
||||
use rand::seq::SliceRandom;
|
||||
use rand::seq::{IndexedRandom, SliceRandom};
|
||||
use rand::Rng;
|
||||
|
||||
use super::TsValueGenerator;
|
||||
@@ -60,7 +60,7 @@ impl<R: Rng + 'static> Generator<InsertIntoExpr, R> for InsertExprGenerator<R> {
|
||||
let can_omit = column.is_nullable() || column.has_default_value();
|
||||
|
||||
// 50% chance to omit a column if it's not required
|
||||
if !can_omit || rng.gen_bool(0.5) {
|
||||
if !can_omit || rng.random_bool(0.5) {
|
||||
values_columns.push(column.clone());
|
||||
}
|
||||
}
|
||||
@@ -76,12 +76,12 @@ impl<R: Rng + 'static> Generator<InsertIntoExpr, R> for InsertExprGenerator<R> {
|
||||
for _ in 0..self.rows {
|
||||
let mut row = Vec::with_capacity(values_columns.len());
|
||||
for column in &values_columns {
|
||||
if column.is_nullable() && rng.gen_bool(0.2) {
|
||||
if column.is_nullable() && rng.random_bool(0.2) {
|
||||
row.push(RowValue::Value(Value::Null));
|
||||
continue;
|
||||
}
|
||||
|
||||
if column.has_default_value() && rng.gen_bool(0.2) {
|
||||
if column.has_default_value() && rng.random_bool(0.2) {
|
||||
row.push(RowValue::Default);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
use std::marker::PhantomData;
|
||||
|
||||
use derive_builder::Builder;
|
||||
use rand::seq::SliceRandom;
|
||||
use rand::seq::{IndexedRandom, SliceRandom};
|
||||
use rand::Rng;
|
||||
|
||||
use crate::context::TableContextRef;
|
||||
@@ -37,7 +37,7 @@ impl<R: Rng + 'static> Generator<SelectExpr, R> for SelectExprGenerator<R> {
|
||||
type Error = Error;
|
||||
|
||||
fn generate(&self, rng: &mut R) -> Result<SelectExpr> {
|
||||
let selection = rng.gen_range(1..self.table_ctx.columns.len());
|
||||
let selection = rng.random_range(1..self.table_ctx.columns.len());
|
||||
let mut selected_columns = self
|
||||
.table_ctx
|
||||
.columns
|
||||
@@ -46,16 +46,16 @@ impl<R: Rng + 'static> Generator<SelectExpr, R> for SelectExprGenerator<R> {
|
||||
.collect::<Vec<_>>();
|
||||
selected_columns.shuffle(rng);
|
||||
|
||||
let order_by_selection = rng.gen_range(1..selection);
|
||||
let order_by_selection = rng.random_range(1..selection);
|
||||
|
||||
let order_by = selected_columns
|
||||
.choose_multiple(rng, order_by_selection)
|
||||
.map(|c| c.name.to_string())
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
let limit = rng.gen_range(1..self.max_limit);
|
||||
let limit = rng.random_range(1..self.max_limit);
|
||||
|
||||
let direction = if rng.gen_bool(1.0 / 2.0) {
|
||||
let direction = if rng.random_bool(1.0 / 2.0) {
|
||||
Direction::Asc
|
||||
} else {
|
||||
Direction::Desc
|
||||
|
||||
Reference in New Issue
Block a user