From ea9af42091f056b01c03b445c91f7883954650bc Mon Sep 17 00:00:00 2001 From: LFC Date: Wed, 21 Dec 2022 19:32:30 +0800 Subject: [PATCH] chore: upgrade Rust to nightly 2022-12-20 (#772) * chore: upgrade Rust to nightly 2022-12-20 * chore: upgrade Rust to nightly 2022-12-20 Co-authored-by: luofucong --- .github/workflows/coverage.yml | 2 +- .github/workflows/develop.yml | 2 +- .github/workflows/release.yml | 2 +- benchmarks/src/bin/nyc-taxi.rs | 16 +++---- rust-toolchain | 2 +- src/catalog/src/helper.rs | 27 ++++------- src/catalog/src/lib.rs | 7 ++- src/catalog/src/local/manager.rs | 4 +- src/catalog/src/remote/manager.rs | 9 ++-- src/catalog/src/system.rs | 8 ++-- src/catalog/tests/local_catalog_tests.rs | 3 +- src/catalog/tests/mock.rs | 6 +-- src/cmd/src/standalone.rs | 3 +- src/common/error/src/ext.rs | 4 +- src/common/error/src/format.rs | 4 +- src/common/error/src/status_code.rs | 4 +- .../function/src/scalars/numpy/interp.rs | 2 +- src/common/function/src/scalars/udf.rs | 7 +-- src/common/grpc-expr/src/alter.rs | 2 +- src/common/grpc-expr/src/insert.rs | 4 +- src/common/grpc-expr/src/lib.rs | 1 - src/common/grpc/benches/channel_manager.rs | 2 +- src/common/grpc/src/channel_manager.rs | 2 +- src/common/query/src/function.rs | 7 +-- .../query/src/logical_plan/accumulator.rs | 2 +- src/common/recordbatch/src/lib.rs | 3 +- src/common/substrait/src/df_expr.rs | 10 ++--- src/common/substrait/src/df_logical.rs | 12 +++-- src/common/substrait/src/types.rs | 8 ++-- src/common/telemetry/src/panic_hook.rs | 2 +- src/datanode/src/error.rs | 2 +- src/datanode/src/instance.rs | 2 +- src/datanode/src/instance/grpc.rs | 6 +-- src/datanode/src/instance/sql.rs | 3 +- src/datanode/src/server.rs | 4 +- src/datanode/src/server/grpc.rs | 3 +- src/datanode/src/sql.rs | 2 +- src/datanode/src/sql/alter.rs | 2 +- src/datanode/src/sql/create.rs | 7 ++- src/datanode/src/tests/instance_test.rs | 3 +- src/datanode/src/tests/test_util.rs | 4 +- src/datatypes/src/error.rs | 2 +- src/datatypes/src/lib.rs | 3 -- src/datatypes/src/schema/constraint.rs | 11 ++--- src/datatypes/src/types/date_type.rs | 2 +- src/datatypes/src/types/datetime_type.rs | 2 +- src/datatypes/src/types/null_type.rs | 2 +- src/datatypes/src/value.rs | 45 +++++++++---------- src/datatypes/src/vectors/binary.rs | 4 +- src/datatypes/src/vectors/boolean.rs | 6 +-- src/datatypes/src/vectors/constant.rs | 2 +- src/datatypes/src/vectors/datetime.rs | 2 +- src/datatypes/src/vectors/helper.rs | 2 +- src/datatypes/src/vectors/list.rs | 5 +-- src/datatypes/src/vectors/null.rs | 4 +- .../src/vectors/operations/filter.rs | 4 +- src/datatypes/src/vectors/primitive.rs | 2 +- src/frontend/src/catalog.rs | 2 +- src/frontend/src/instance.rs | 2 +- src/frontend/src/instance/distributed.rs | 6 +-- src/frontend/src/instance/opentsdb.rs | 2 +- src/frontend/src/instance/prometheus.rs | 7 ++- src/frontend/src/spliter.rs | 2 +- src/frontend/src/table.rs | 9 ++-- src/frontend/src/table/route.rs | 2 +- src/frontend/src/table/scan.rs | 2 +- src/frontend/src/tests.rs | 8 ++-- src/log-store/src/fs/chunk.rs | 2 +- src/log-store/src/fs/file.rs | 6 +-- src/log-store/src/fs/file_name.rs | 8 ++-- src/log-store/src/fs/io/unix.rs | 4 +- src/log-store/src/fs/log.rs | 7 ++- src/meta-client/src/client.rs | 4 +- src/meta-srv/src/keys.rs | 8 ++-- src/meta-srv/src/lease.rs | 2 +- src/meta-srv/src/service/heartbeat.rs | 2 +- src/meta-srv/src/service/router.rs | 6 +-- src/mito/src/engine.rs | 16 +++---- src/mito/src/table.rs | 4 +- src/query/src/datafusion.rs | 2 +- src/query/src/optimizer.rs | 13 ++---- src/query/tests/argmax_test.rs | 5 +-- src/query/tests/argmin_test.rs | 5 +-- src/query/tests/function.rs | 2 +- src/query/tests/mean_test.rs | 2 +- src/query/tests/my_sum_udaf_example.rs | 5 +-- src/query/tests/percentile_test.rs | 7 +-- src/query/tests/polyval_test.rs | 5 +-- src/query/tests/scipy_stats_norm_cdf_test.rs | 3 +- src/query/tests/scipy_stats_norm_pdf.rs | 3 +- src/script/src/lib.rs | 1 - src/script/src/python/builtins/mod.rs | 42 +++++++---------- src/script/src/python/builtins/test.rs | 4 +- src/script/src/python/coprocessor.rs | 10 ++--- src/script/src/python/coprocessor/compile.rs | 5 +-- src/script/src/python/coprocessor/parse.rs | 7 +-- src/script/src/python/error.rs | 2 +- src/script/src/python/test.rs | 2 +- src/script/src/python/utils.rs | 10 ++--- src/script/src/python/vector.rs | 36 +++++++-------- src/servers/src/auth/user_provider.rs | 2 +- src/servers/src/grpc/handler.rs | 2 +- src/servers/src/http.rs | 16 +++---- src/servers/src/http/handler.rs | 4 +- src/servers/src/http/opentsdb.rs | 2 +- src/servers/src/http/script.rs | 2 +- src/servers/src/influxdb.rs | 5 +-- src/servers/src/mysql/federated.rs | 2 +- src/servers/src/opentsdb.rs | 2 +- src/servers/src/opentsdb/codec.rs | 6 +-- src/servers/src/postgres/auth_handler.rs | 2 +- src/servers/src/postgres/handler.rs | 6 +-- src/servers/src/prometheus.rs | 14 +++--- src/servers/src/server.rs | 25 +++++------ src/servers/tests/http/http_handler_test.rs | 6 +-- src/servers/tests/http/opentsdb_test.rs | 3 +- src/servers/tests/mysql/mysql_server_test.rs | 3 +- src/servers/tests/opentsdb.rs | 13 +++--- src/servers/tests/postgres/mod.rs | 28 ++++-------- src/sql/src/parser.rs | 3 +- src/sql/src/parsers/insert_parser.rs | 2 +- src/sql/src/statements.rs | 22 +++++---- src/sql/src/statements/insert.rs | 9 ++-- src/sql/src/statements/show.rs | 4 +- .../bench_memtable_read_write_ratio.rs | 7 ++- src/storage/src/engine.rs | 4 +- src/storage/src/flush.rs | 3 +- src/storage/src/lib.rs | 2 +- src/storage/src/manifest/storage.rs | 14 +++--- src/storage/src/metadata.rs | 2 +- src/storage/src/read/merge.rs | 4 +- src/storage/src/schema/compat.rs | 6 +-- src/storage/src/schema/store.rs | 2 +- src/storage/src/test_util/config_util.rs | 2 +- src/storage/src/test_util/descriptor_util.rs | 2 +- src/storage/src/write_batch.rs | 2 +- src/storage/src/write_batch/codec.rs | 2 +- src/storage/src/write_batch/compat.rs | 6 +-- src/table/src/engine.rs | 6 +-- src/table/src/metadata.rs | 20 ++------- src/table/src/table/numbers.rs | 2 +- src/table/src/test_util/mock_engine.rs | 8 +--- tests-integration/src/test_util.rs | 4 +- tests/runner/src/env.rs | 13 +++--- tests/runner/src/util.rs | 2 +- 145 files changed, 366 insertions(+), 515 deletions(-) diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index af5d54e1b4..81f6005e88 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -24,7 +24,7 @@ on: name: Code coverage env: - RUST_TOOLCHAIN: nightly-2022-07-14 + RUST_TOOLCHAIN: nightly-2022-12-20 jobs: coverage: diff --git a/.github/workflows/develop.yml b/.github/workflows/develop.yml index 2cba1fa5d2..b877df919d 100644 --- a/.github/workflows/develop.yml +++ b/.github/workflows/develop.yml @@ -23,7 +23,7 @@ on: name: CI env: - RUST_TOOLCHAIN: nightly-2022-07-14 + RUST_TOOLCHAIN: nightly-2022-12-20 jobs: typos: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 5a98be2201..8a1433db6f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -10,7 +10,7 @@ on: name: Release env: - RUST_TOOLCHAIN: nightly-2022-07-14 + RUST_TOOLCHAIN: nightly-2022-12-20 # FIXME(zyy17): Would be better to use `gh release list -L 1 | cut -f 3` to get the latest release version tag, but for a long time, we will stay at 'v0.1.0-alpha-*'. SCHEDULED_BUILD_VERSION_PREFIX: v0.1.0-alpha diff --git a/benchmarks/src/bin/nyc-taxi.rs b/benchmarks/src/bin/nyc-taxi.rs index 0d097fb3a0..885f1827e1 100644 --- a/benchmarks/src/bin/nyc-taxi.rs +++ b/benchmarks/src/bin/nyc-taxi.rs @@ -15,7 +15,6 @@ //! Use the taxi trip records from New York City dataset to bench. You can download the dataset from //! [here](https://www1.nyc.gov/site/tlc/about/tlc-trip-record-data.page). -#![feature(once_cell)] #![allow(clippy::print_stdout)] use std::collections::HashMap; @@ -94,7 +93,7 @@ async fn write_data( .unwrap(); let progress_bar = mpb.add(ProgressBar::new(row_num as _)); progress_bar.set_style(pb_style); - progress_bar.set_message(format!("{:?}", path)); + progress_bar.set_message(format!("{path:?}")); let mut total_rpc_elapsed_ms = 0; @@ -115,10 +114,7 @@ async fn write_data( progress_bar.inc(row_count as _); } - progress_bar.finish_with_message(format!( - "file {:?} done in {}ms", - path, total_rpc_elapsed_ms - )); + progress_bar.finish_with_message(format!("file {path:?} done in {total_rpc_elapsed_ms}ms",)); total_rpc_elapsed_ms } @@ -355,12 +351,12 @@ fn query_set() -> HashMap { ret.insert( "count_all".to_string(), - format!("SELECT COUNT(*) FROM {};", TABLE_NAME), + format!("SELECT COUNT(*) FROM {TABLE_NAME};"), ); ret.insert( "fare_amt_by_passenger".to_string(), - format!("SELECT passenger_count, MIN(fare_amount), MAX(fare_amount), SUM(fare_amount) FROM {} GROUP BY passenger_count",TABLE_NAME) + format!("SELECT passenger_count, MIN(fare_amount), MAX(fare_amount), SUM(fare_amount) FROM {TABLE_NAME} GROUP BY passenger_count") ); ret @@ -373,7 +369,7 @@ async fn do_write(args: &Args, client: &Client) { let mut write_jobs = JoinSet::new(); let create_table_result = admin.create(create_table_expr()).await; - println!("Create table result: {:?}", create_table_result); + println!("Create table result: {create_table_result:?}"); let progress_bar_style = ProgressStyle::with_template( "[{elapsed_precise}] {bar:60.cyan/blue} {pos:>7}/{len:7} {msg}", @@ -406,7 +402,7 @@ async fn do_write(args: &Args, client: &Client) { async fn do_query(num_iter: usize, db: &Database) { for (query_name, query) in query_set() { - println!("Running query: {}", query); + println!("Running query: {query}"); for i in 0..num_iter { let now = Instant::now(); let _res = db.select(Select::Sql(query.clone())).await.unwrap(); diff --git a/rust-toolchain b/rust-toolchain index 746dd10072..14b94c3fef 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1 @@ -nightly-2022-07-14 +nightly-2022-12-20 diff --git a/src/catalog/src/helper.rs b/src/catalog/src/helper.rs index 062d07bc19..0993e865f6 100644 --- a/src/catalog/src/helper.rs +++ b/src/catalog/src/helper.rs @@ -33,48 +33,38 @@ const ALPHANUMERICS_NAME_PATTERN: &str = "[a-zA-Z_][a-zA-Z0-9_]*"; lazy_static! { static ref CATALOG_KEY_PATTERN: Regex = Regex::new(&format!( - "^{}-({})$", - CATALOG_KEY_PREFIX, ALPHANUMERICS_NAME_PATTERN + "^{CATALOG_KEY_PREFIX}-({ALPHANUMERICS_NAME_PATTERN})$" )) .unwrap(); } lazy_static! { static ref SCHEMA_KEY_PATTERN: Regex = Regex::new(&format!( - "^{}-({})-({})$", - SCHEMA_KEY_PREFIX, ALPHANUMERICS_NAME_PATTERN, ALPHANUMERICS_NAME_PATTERN + "^{SCHEMA_KEY_PREFIX}-({ALPHANUMERICS_NAME_PATTERN})-({ALPHANUMERICS_NAME_PATTERN})$" )) .unwrap(); } lazy_static! { static ref TABLE_GLOBAL_KEY_PATTERN: Regex = Regex::new(&format!( - "^{}-({})-({})-({})$", - TABLE_GLOBAL_KEY_PREFIX, - ALPHANUMERICS_NAME_PATTERN, - ALPHANUMERICS_NAME_PATTERN, - ALPHANUMERICS_NAME_PATTERN + "^{TABLE_GLOBAL_KEY_PREFIX}-({ALPHANUMERICS_NAME_PATTERN})-({ALPHANUMERICS_NAME_PATTERN})-({ALPHANUMERICS_NAME_PATTERN})$" )) .unwrap(); } lazy_static! { static ref TABLE_REGIONAL_KEY_PATTERN: Regex = Regex::new(&format!( - "^{}-({})-({})-({})-([0-9]+)$", - TABLE_REGIONAL_KEY_PREFIX, - ALPHANUMERICS_NAME_PATTERN, - ALPHANUMERICS_NAME_PATTERN, - ALPHANUMERICS_NAME_PATTERN + "^{TABLE_REGIONAL_KEY_PREFIX}-({ALPHANUMERICS_NAME_PATTERN})-({ALPHANUMERICS_NAME_PATTERN})-({ALPHANUMERICS_NAME_PATTERN})-([0-9]+)$" )) .unwrap(); } pub fn build_catalog_prefix() -> String { - format!("{}-", CATALOG_KEY_PREFIX) + format!("{CATALOG_KEY_PREFIX}-") } pub fn build_schema_prefix(catalog_name: impl AsRef) -> String { - format!("{}-{}-", SCHEMA_KEY_PREFIX, catalog_name.as_ref()) + format!("{SCHEMA_KEY_PREFIX}-{}-", catalog_name.as_ref()) } pub fn build_table_global_prefix( @@ -82,8 +72,7 @@ pub fn build_table_global_prefix( schema_name: impl AsRef, ) -> String { format!( - "{}-{}-{}-", - TABLE_GLOBAL_KEY_PREFIX, + "{TABLE_GLOBAL_KEY_PREFIX}-{}-{}-", catalog_name.as_ref(), schema_name.as_ref() ) @@ -378,7 +367,7 @@ mod tests { table_info, }; let serialized = serde_json::to_string(&value).unwrap(); - let deserialized = TableGlobalValue::parse(&serialized).unwrap(); + let deserialized = TableGlobalValue::parse(serialized).unwrap(); assert_eq!(value, deserialized); } } diff --git a/src/catalog/src/lib.rs b/src/catalog/src/lib.rs index d71a0c6d5b..21d8efe65f 100644 --- a/src/catalog/src/lib.rs +++ b/src/catalog/src/lib.rs @@ -157,7 +157,7 @@ pub struct RegisterSchemaRequest { /// Formats table fully-qualified name pub fn format_full_table_name(catalog: &str, schema: &str, table: &str) -> String { - format!("{}.{}.{}", catalog, schema, table) + format!("{catalog}.{schema}.{table}") } pub trait CatalogProviderFactory { @@ -187,8 +187,7 @@ pub(crate) async fn handle_system_table_request<'a, M: CatalogManager>( .await .with_context(|_| CreateTableSnafu { table_info: format!( - "{}.{}.{}, id: {}", - catalog_name, schema_name, table_name, table_id, + "{catalog_name}.{schema_name}.{table_name}, id: {table_id}", ), })?; manager @@ -200,7 +199,7 @@ pub(crate) async fn handle_system_table_request<'a, M: CatalogManager>( table: table.clone(), }) .await?; - info!("Created and registered system table: {}", table_name); + info!("Created and registered system table: {table_name}"); table }; if let Some(hook) = req.open_hook { diff --git a/src/catalog/src/local/manager.rs b/src/catalog/src/local/manager.rs index e4c89933e0..1a1f1a995a 100644 --- a/src/catalog/src/local/manager.rs +++ b/src/catalog/src/local/manager.rs @@ -338,7 +338,7 @@ impl CatalogManager for LocalCatalogManager { let schema = catalog .schema(schema_name)? .with_context(|| SchemaNotFoundSnafu { - schema_info: format!("{}.{}", catalog_name, schema_name), + schema_info: format!("{catalog_name}.{schema_name}"), })?; { @@ -452,7 +452,7 @@ impl CatalogManager for LocalCatalogManager { let schema = catalog .schema(schema_name)? .with_context(|| SchemaNotFoundSnafu { - schema_info: format!("{}.{}", catalog_name, schema_name), + schema_info: format!("{catalog_name}.{schema_name}"), })?; schema.table(table_name) } diff --git a/src/catalog/src/remote/manager.rs b/src/catalog/src/remote/manager.rs index c37acdc303..c18a079c84 100644 --- a/src/catalog/src/remote/manager.rs +++ b/src/catalog/src/remote/manager.rs @@ -331,10 +331,7 @@ impl RemoteCatalogManager { .open_table(&context, request) .await .with_context(|_| OpenTableSnafu { - table_info: format!( - "{}.{}.{}, id:{}", - catalog_name, schema_name, table_name, table_id - ), + table_info: format!("{catalog_name}.{schema_name}.{table_name}, id:{table_id}"), })? { Some(table) => { info!( @@ -355,7 +352,7 @@ impl RemoteCatalogManager { .clone() .try_into() .context(InvalidTableSchemaSnafu { - table_info: format!("{}.{}.{}", catalog_name, schema_name, table_name,), + table_info: format!("{catalog_name}.{schema_name}.{table_name}"), schema: meta.schema.clone(), })?; let req = CreateTableRequest { @@ -477,7 +474,7 @@ impl CatalogManager for RemoteCatalogManager { let schema = catalog .schema(schema_name)? .with_context(|| SchemaNotFoundSnafu { - schema_info: format!("{}.{}", catalog_name, schema_name), + schema_info: format!("{catalog_name}.{schema_name}"), })?; schema.table(table_name) } diff --git a/src/catalog/src/system.rs b/src/catalog/src/system.rs index a845c08143..df39d3a5ab 100644 --- a/src/catalog/src/system.rs +++ b/src/catalog/src/system.rs @@ -197,7 +197,7 @@ pub fn build_table_insert_request(full_table_name: String, table_id: TableId) -> } pub fn build_schema_insert_request(catalog_name: String, schema_name: String) -> InsertRequest { - let full_schema_name = format!("{}.{}", catalog_name, schema_name); + let full_schema_name = format!("{catalog_name}.{schema_name}"); build_insert_request( EntryType::Schema, full_schema_name.as_bytes(), @@ -390,7 +390,7 @@ mod tests { if let Entry::Catalog(e) = entry { assert_eq!("some_catalog", e.catalog_name); } else { - panic!("Unexpected type: {:?}", entry); + panic!("Unexpected type: {entry:?}"); } } @@ -407,7 +407,7 @@ mod tests { assert_eq!("some_catalog", e.catalog_name); assert_eq!("some_schema", e.schema_name); } else { - panic!("Unexpected type: {:?}", entry); + panic!("Unexpected type: {entry:?}"); } } @@ -426,7 +426,7 @@ mod tests { assert_eq!("some_table", e.table_name); assert_eq!(42, e.table_id); } else { - panic!("Unexpected type: {:?}", entry); + panic!("Unexpected type: {entry:?}"); } } diff --git a/src/catalog/tests/local_catalog_tests.rs b/src/catalog/tests/local_catalog_tests.rs index 2e57754077..e58722bac4 100644 --- a/src/catalog/tests/local_catalog_tests.rs +++ b/src/catalog/tests/local_catalog_tests.rs @@ -69,8 +69,7 @@ mod tests { assert!( err.to_string() .contains("Table `greptime.public.test_table` already exists"), - "Actual error message: {}", - err + "Actual error message: {err}", ); } diff --git a/src/catalog/tests/mock.rs b/src/catalog/tests/mock.rs index 01aec6e2f8..336f41ba0a 100644 --- a/src/catalog/tests/mock.rs +++ b/src/catalog/tests/mock.rs @@ -189,10 +189,10 @@ impl TableEngine for MockTableEngine { unimplemented!() } - fn get_table<'a>( + fn get_table( &self, _ctx: &EngineContext, - table_ref: &'a TableReference, + table_ref: &TableReference, ) -> table::Result> { futures::executor::block_on(async { Ok(self @@ -204,7 +204,7 @@ impl TableEngine for MockTableEngine { }) } - fn table_exists<'a>(&self, _ctx: &EngineContext, table_ref: &'a TableReference) -> bool { + fn table_exists(&self, _ctx: &EngineContext, table_ref: &TableReference) -> bool { futures::executor::block_on(async { self.tables .read() diff --git a/src/cmd/src/standalone.rs b/src/cmd/src/standalone.rs index d4b65c3a85..e14f6f6e0a 100644 --- a/src/cmd/src/standalone.rs +++ b/src/cmd/src/standalone.rs @@ -221,8 +221,7 @@ impl TryFrom for FrontendOptions { if addr == datanode_grpc_addr { return IllegalConfigSnafu { msg: format!( - "gRPC listen address conflicts with datanode reserved gRPC addr: {}", - datanode_grpc_addr + "gRPC listen address conflicts with datanode reserved gRPC addr: {datanode_grpc_addr}", ), } .fail(); diff --git a/src/common/error/src/ext.rs b/src/common/error/src/ext.rs index 54b4343120..9d2b3fa0ae 100644 --- a/src/common/error/src/ext.rs +++ b/src/common/error/src/ext.rs @@ -131,7 +131,7 @@ mod tests { assert!(ErrorCompat::backtrace(&err).is_some()); - let msg = format!("{:?}", err); + let msg = format!("{err:?}"); assert!(msg.contains("\nBacktrace:\n")); let fmt_msg = format!("{:?}", DebugFormat::new(&err)); assert_eq!(msg, fmt_msg); @@ -151,7 +151,7 @@ mod tests { assert!(err.as_any().downcast_ref::().is_some()); assert!(err.source().is_some()); - let msg = format!("{:?}", err); + let msg = format!("{err:?}"); assert!(msg.contains("\nBacktrace:\n")); assert!(msg.contains("Caused by")); diff --git a/src/common/error/src/format.rs b/src/common/error/src/format.rs index 87d8171ce0..40c077ca3d 100644 --- a/src/common/error/src/format.rs +++ b/src/common/error/src/format.rs @@ -31,11 +31,11 @@ impl<'a, E: ErrorExt + ?Sized> fmt::Debug for DebugFormat<'a, E> { write!(f, "{}.", self.0)?; if let Some(source) = self.0.source() { // Source error use debug format for more verbose info. - write!(f, " Caused by: {:?}", source)?; + write!(f, " Caused by: {source:?}")?; } if let Some(backtrace) = self.0.backtrace_opt() { // Add a newline to separate causes and backtrace. - write!(f, "\nBacktrace:\n{}", backtrace)?; + write!(f, "\nBacktrace:\n{backtrace}")?; } Ok(()) diff --git a/src/common/error/src/status_code.rs b/src/common/error/src/status_code.rs index 8f8a576e8d..3e5fec37ac 100644 --- a/src/common/error/src/status_code.rs +++ b/src/common/error/src/status_code.rs @@ -87,7 +87,7 @@ impl StatusCode { impl fmt::Display for StatusCode { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { // The current debug format is suitable to display. - write!(f, "{:?}", self) + write!(f, "{self:?}") } } @@ -96,7 +96,7 @@ mod tests { use super::*; fn assert_status_code_display(code: StatusCode, msg: &str) { - let code_msg = format!("{}", code); + let code_msg = format!("{code}"); assert_eq!(msg, code_msg); } diff --git a/src/common/function/src/scalars/numpy/interp.rs b/src/common/function/src/scalars/numpy/interp.rs index c4bb6e9811..c4dbadc999 100644 --- a/src/common/function/src/scalars/numpy/interp.rs +++ b/src/common/function/src/scalars/numpy/interp.rs @@ -343,7 +343,7 @@ mod tests { Arc::new(Int64Vector::from_vec(fp.clone())), ]; let vector = interp(&args).unwrap(); - assert!(matches!(vector.get(0), Value::Float64(v) if v==x[0] as f64)); + assert!(matches!(vector.get(0), Value::Float64(v) if v == x[0])); // x=None output:Null let input = vec![None, Some(0.0), Some(0.3)]; diff --git a/src/common/function/src/scalars/udf.rs b/src/common/function/src/scalars/udf.rs index f6a7dcee87..38812f695e 100644 --- a/src/common/function/src/scalars/udf.rs +++ b/src/common/function/src/scalars/udf.rs @@ -127,12 +127,7 @@ mod tests { assert_eq!(4, vec.len()); for i in 0..4 { - assert_eq!( - i == 0 || i == 3, - vec.get_data(i).unwrap(), - "failed at {}", - i - ) + assert_eq!(i == 0 || i == 3, vec.get_data(i).unwrap(), "Failed at {i}",) } } _ => unreachable!(), diff --git a/src/common/grpc-expr/src/alter.rs b/src/common/grpc-expr/src/alter.rs index 8f43932c35..45c9e710d1 100644 --- a/src/common/grpc-expr/src/alter.rs +++ b/src/common/grpc-expr/src/alter.rs @@ -106,7 +106,7 @@ pub fn create_table_schema(expr: &CreateTableExpr) -> Result { .iter() .any(|column| column.name == expr.time_index), MissingTimestampColumnSnafu { - msg: format!("CreateExpr: {:?}", expr) + msg: format!("CreateExpr: {expr:?}") } ); diff --git a/src/common/grpc-expr/src/insert.rs b/src/common/grpc-expr/src/insert.rs index a8273c62b6..169574b444 100644 --- a/src/common/grpc-expr/src/insert.rs +++ b/src/common/grpc-expr/src/insert.rs @@ -154,7 +154,7 @@ fn collect_column_values(column_datatype: ColumnDataType, values: &Values) -> Ve collect_values!(values.i32_values, |v| ValueRef::from(*v)) } ColumnDataType::Int64 => { - collect_values!(values.i64_values, |v| ValueRef::from(*v as i64)) + collect_values!(values.i64_values, |v| ValueRef::from(*v)) } ColumnDataType::Uint8 => { collect_values!(values.u8_values, |v| ValueRef::from(*v as u8)) @@ -166,7 +166,7 @@ fn collect_column_values(column_datatype: ColumnDataType, values: &Values) -> Ve collect_values!(values.u32_values, |v| ValueRef::from(*v)) } ColumnDataType::Uint64 => { - collect_values!(values.u64_values, |v| ValueRef::from(*v as u64)) + collect_values!(values.u64_values, |v| ValueRef::from(*v)) } ColumnDataType::Float32 => collect_values!(values.f32_values, |v| ValueRef::from(*v)), ColumnDataType::Float64 => collect_values!(values.f64_values, |v| ValueRef::from(*v)), diff --git a/src/common/grpc-expr/src/lib.rs b/src/common/grpc-expr/src/lib.rs index 71786d670f..f296966bb3 100644 --- a/src/common/grpc-expr/src/lib.rs +++ b/src/common/grpc-expr/src/lib.rs @@ -1,4 +1,3 @@ -#![feature(assert_matches)] // Copyright 2022 Greptime Team // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/common/grpc/benches/channel_manager.rs b/src/common/grpc/benches/channel_manager.rs index 0b95dcddd0..1b2a917b56 100644 --- a/src/common/grpc/benches/channel_manager.rs +++ b/src/common/grpc/benches/channel_manager.rs @@ -26,7 +26,7 @@ async fn do_bench_channel_manager() { let join = tokio::spawn(async move { for _ in 0..10000 { let idx = rand::random::() % 100; - let ret = m_clone.get(format!("{}", idx)); + let ret = m_clone.get(format!("{idx}")); assert!(ret.is_ok()); } }); diff --git a/src/common/grpc/src/channel_manager.rs b/src/common/grpc/src/channel_manager.rs index 7bb87872f8..42f5dea47d 100644 --- a/src/common/grpc/src/channel_manager.rs +++ b/src/common/grpc/src/channel_manager.rs @@ -120,7 +120,7 @@ impl ChannelManager { fn build_endpoint(&self, addr: &str) -> Result { let mut endpoint = - Endpoint::new(format!("http://{}", addr)).context(error::CreateChannelSnafu)?; + Endpoint::new(format!("http://{addr}")).context(error::CreateChannelSnafu)?; if let Some(dur) = self.config.timeout { endpoint = endpoint.timeout(dur); diff --git a/src/common/query/src/function.rs b/src/common/query/src/function.rs index 01bfffce7f..cde2e25f14 100644 --- a/src/common/query/src/function.rs +++ b/src/common/query/src/function.rs @@ -161,12 +161,7 @@ mod tests { assert_eq!(4, vec.len()); for i in 0..4 { - assert_eq!( - i == 0 || i == 3, - vec.get_data(i).unwrap(), - "failed at {}", - i - ) + assert_eq!(i == 0 || i == 3, vec.get_data(i).unwrap(), "Failed at {i}") } } _ => unreachable!(), diff --git a/src/common/query/src/logical_plan/accumulator.rs b/src/common/query/src/logical_plan/accumulator.rs index 4b83a7efa8..7ef476d2b9 100644 --- a/src/common/query/src/logical_plan/accumulator.rs +++ b/src/common/query/src/logical_plan/accumulator.rs @@ -131,7 +131,7 @@ impl DfAccumulator for DfAccumulatorAdaptor { let state_types = self.creator.state_types()?; if state_values.len() != state_types.len() { return error::BadAccumulatorImplSnafu { - err_msg: format!("Accumulator {:?} returned state values size do not match its state types size.", self), + err_msg: format!("Accumulator {self:?} returned state values size do not match its state types size."), } .fail()?; } diff --git a/src/common/recordbatch/src/lib.rs b/src/common/recordbatch/src/lib.rs index be96a94a50..4fcb69656d 100644 --- a/src/common/recordbatch/src/lib.rs +++ b/src/common/recordbatch/src/lib.rs @@ -231,8 +231,7 @@ mod tests { assert_eq!( result.unwrap_err().to_string(), format!( - "Failed to create RecordBatches, reason: expect RecordBatch schema equals {:?}, actual: {:?}", - schema1, schema2 + "Failed to create RecordBatches, reason: expect RecordBatch schema equals {schema1:?}, actual: {schema2:?}", ) ); diff --git a/src/common/substrait/src/df_expr.rs b/src/common/substrait/src/df_expr.rs index b8d77a113c..88a35261d8 100644 --- a/src/common/substrait/src/df_expr.rs +++ b/src/common/substrait/src/df_expr.rs @@ -61,7 +61,7 @@ pub(crate) fn to_df_expr( | RexType::Cast(_) | RexType::Subquery(_) | RexType::Enum(_) => UnsupportedExprSnafu { - name: format!("substrait expression {:?}", expr_rex_type), + name: format!("substrait expression {expr_rex_type:?}"), } .fail()?, } @@ -109,7 +109,7 @@ pub fn convert_scalar_function( let fn_name = ctx .find_scalar_fn(anchor) .with_context(|| InvalidParametersSnafu { - reason: format!("Unregistered scalar function reference: {}", anchor), + reason: format!("Unregistered scalar function reference: {anchor}"), })?; // convenient util @@ -435,7 +435,7 @@ pub fn convert_scalar_function( // skip Wildcard, unimplemented. // end other direct expr _ => UnsupportedExprSnafu { - name: format!("scalar function {}", fn_name), + name: format!("scalar function {fn_name}"), } .fail()?, }; @@ -595,8 +595,8 @@ pub fn convert_column(column: &Column, schema: &Schema) -> Result InvalidParametersSnafu { reason: format!( - "Trying to convert DDL/DML plan to substrait proto, plan: {:?}", - plan + "Trying to convert DDL/DML plan to substrait proto, plan: {plan:?}", ), } .fail()?, @@ -572,7 +571,7 @@ mod test { let proto = convertor.encode(plan.clone()).unwrap(); let tripped_plan = convertor.decode(proto, catalog).unwrap(); - assert_eq!(format!("{:?}", plan), format!("{:?}", tripped_plan)); + assert_eq!(format!("{plan:?}"), format!("{tripped_plan:?}")); } #[tokio::test] @@ -606,8 +605,7 @@ mod test { let table_scan_plan = LogicalPlan::TableScan(TableScan { table_name: format!( - "{}.{}.{}", - DEFAULT_CATALOG_NAME, DEFAULT_SCHEMA_NAME, DEFAULT_TABLE_NAME + "{DEFAULT_CATALOG_NAME}.{DEFAULT_SCHEMA_NAME}.{DEFAULT_TABLE_NAME}", ), source: adapter, projection: Some(projection), diff --git a/src/common/substrait/src/types.rs b/src/common/substrait/src/types.rs index d1033c7a3e..31de2a16a1 100644 --- a/src/common/substrait/src/types.rs +++ b/src/common/substrait/src/types.rs @@ -87,7 +87,7 @@ pub fn to_concrete_type(ty: &SType) -> Result<(ConcreteDataType, bool)> { | Kind::List(_) | Kind::Map(_) | Kind::UserDefinedTypeReference(_) => UnsupportedSubstraitTypeSnafu { - ty: format!("{:?}", kind), + ty: format!("{kind:?}"), } .fail(), } @@ -154,7 +154,7 @@ pub(crate) fn scalar_value_as_literal_type(v: &ScalarValue) -> Result LiteralType _ => { return error::UnsupportedExprSnafu { - name: format!("{:?}", v), + name: format!("{v:?}"), } .fail() } @@ -177,7 +177,7 @@ pub(crate) fn literal_type_to_scalar_value(t: LiteralType) -> Result ScalarValue _ => { return error::UnsupportedSubstraitTypeSnafu { - ty: format!("{:?}", kind), + ty: format!("{kind:?}"), } .fail() } @@ -194,7 +194,7 @@ pub(crate) fn literal_type_to_scalar_value(t: LiteralType) -> Result ScalarValue _ => { return error::UnsupportedSubstraitTypeSnafu { - ty: format!("{:?}", t), + ty: format!("{t:?}"), } .fail() } diff --git a/src/common/telemetry/src/panic_hook.rs b/src/common/telemetry/src/panic_hook.rs index e29a832637..ef2c2e639b 100644 --- a/src/common/telemetry/src/panic_hook.rs +++ b/src/common/telemetry/src/panic_hook.rs @@ -28,7 +28,7 @@ pub fn set_panic_hook() { let default_hook = panic::take_hook(); panic::set_hook(Box::new(move |panic| { let backtrace = Backtrace::new(); - let backtrace = format!("{:?}", backtrace); + let backtrace = format!("{backtrace:?}"); if let Some(location) = panic.location() { tracing::error!( message = %panic, diff --git a/src/datanode/src/error.rs b/src/datanode/src/error.rs index 1597ac7388..6115bfa60a 100644 --- a/src/datanode/src/error.rs +++ b/src/datanode/src/error.rs @@ -155,7 +155,7 @@ pub enum Error { #[snafu(display("Failed to init backend, config: {:#?}, source: {}", config, source))] InitBackend { - config: ObjectStoreConfig, + config: Box, source: object_store::Error, backtrace: Backtrace, }, diff --git a/src/datanode/src/instance.rs b/src/datanode/src/instance.rs index 9d09e4724c..697d931301 100644 --- a/src/datanode/src/instance.rs +++ b/src/datanode/src/instance.rs @@ -233,7 +233,7 @@ pub(crate) async fn new_fs_object_store(data_dir: &str) -> Result { .context(error::CreateDirSnafu { dir: &data_dir })?; info!("The file storage directory is: {}", &data_dir); - let atomic_write_dir = format!("{}/.tmp/", data_dir); + let atomic_write_dir = format!("{data_dir}/.tmp/"); let accessor = FsBuilder::default() .root(&data_dir) diff --git a/src/datanode/src/instance/grpc.rs b/src/datanode/src/instance/grpc.rs index 0817abcb96..39c53e9c26 100644 --- a/src/datanode/src/instance/grpc.rs +++ b/src/datanode/src/instance/grpc.rs @@ -117,7 +117,7 @@ impl Instance { } Some(select_expr::Expr::LogicalPlan(plan)) => self.execute_logical(plan).await, _ => UnsupportedExprSnafu { - name: format!("{:?}", expr), + name: format!("{expr:?}"), } .fail(), } @@ -175,7 +175,7 @@ impl GrpcQueryHandler for Instance { Some(object_expr::Expr::Select(select_expr)) => self.handle_select(select_expr).await, other => { return servers::error::NotSupportedSnafu { - feat: format!("{:?}", other), + feat: format!("{other:?}"), } .fail(); } @@ -200,7 +200,7 @@ impl GrpcAdminHandler for Instance { } other => { return servers::error::NotSupportedSnafu { - feat: format!("{:?}", other), + feat: format!("{other:?}"), } .fail(); } diff --git a/src/datanode/src/instance/sql.rs b/src/datanode/src/instance/sql.rs index 41269882ec..f238a03745 100644 --- a/src/datanode/src/instance/sql.rs +++ b/src/datanode/src/instance/sql.rs @@ -187,8 +187,7 @@ fn table_idents_to_full_name( )), _ => error::InvalidSqlSnafu { msg: format!( - "expect table name to be .., .
or
, actual: {}", - obj_name + "expect table name to be ..
, .
or
, actual: {obj_name}", ), }.fail(), } diff --git a/src/datanode/src/server.rs b/src/datanode/src/server.rs index 9be540d692..cbb2475955 100644 --- a/src/datanode/src/server.rs +++ b/src/datanode/src/server.rs @@ -40,7 +40,7 @@ impl Services { pub async fn try_new(instance: InstanceRef, opts: &DatanodeOptions) -> Result { let grpc_runtime = Arc::new( RuntimeBuilder::default() - .worker_threads(opts.rpc_runtime_size as usize) + .worker_threads(opts.rpc_runtime_size) .thread_name("grpc-io-handlers") .build() .context(RuntimeResourceSnafu)?, @@ -54,7 +54,7 @@ impl Services { Mode::Distributed => { let mysql_io_runtime = Arc::new( RuntimeBuilder::default() - .worker_threads(opts.mysql_runtime_size as usize) + .worker_threads(opts.mysql_runtime_size) .thread_name("mysql-io-handlers") .build() .context(RuntimeResourceSnafu)?, diff --git a/src/datanode/src/server/grpc.rs b/src/datanode/src/server/grpc.rs index 3fa54f3b39..8327b9e1d9 100644 --- a/src/datanode/src/server/grpc.rs +++ b/src/datanode/src/server/grpc.rs @@ -202,8 +202,7 @@ mod tests { let err_msg = result.unwrap_err().to_string(); assert!( err_msg.contains("Missing timestamp column"), - "actual: {}", - err_msg + "actual: {err_msg}", ); } diff --git a/src/datanode/src/sql.rs b/src/datanode/src/sql.rs index b336ef8177..aa41e8a255 100644 --- a/src/datanode/src/sql.rs +++ b/src/datanode/src/sql.rs @@ -96,7 +96,7 @@ impl SqlHandler { result } - pub(crate) fn get_table<'a>(&self, table_ref: &'a TableReference) -> Result { + pub(crate) fn get_table(&self, table_ref: &TableReference) -> Result { self.table_engine .get_table(&EngineContext::default(), table_ref) .with_context(|_| GetTableSnafu { diff --git a/src/datanode/src/sql/alter.rs b/src/datanode/src/sql/alter.rs index 77fada09fd..1fa48a3b18 100644 --- a/src/datanode/src/sql/alter.rs +++ b/src/datanode/src/sql/alter.rs @@ -61,7 +61,7 @@ impl SqlHandler { let alter_kind = match alter_table.alter_operation() { AlterTableOperation::AddConstraint(table_constraint) => { return error::InvalidSqlSnafu { - msg: format!("unsupported table constraint {}", table_constraint), + msg: format!("unsupported table constraint {table_constraint}"), } .fail() } diff --git a/src/datanode/src/sql/create.rs b/src/datanode/src/sql/create.rs index ac80338aa8..7e83907e1b 100644 --- a/src/datanode/src/sql/create.rs +++ b/src/datanode/src/sql/create.rs @@ -143,7 +143,7 @@ impl SqlHandler { )?; } else { return error::InvalidSqlSnafu { - msg: format!("Cannot recognize named UNIQUE constraint: {}", name), + msg: format!("Cannot recognize named UNIQUE constraint: {name}"), } .fail(); } @@ -158,8 +158,7 @@ impl SqlHandler { } else { return error::InvalidSqlSnafu { msg: format!( - "Unrecognized non-primary unnamed UNIQUE constraint: {:?}", - name + "Unrecognized non-primary unnamed UNIQUE constraint: {name:?}", ), } .fail(); @@ -167,7 +166,7 @@ impl SqlHandler { } _ => { return ConstraintNotSupportedSnafu { - constraint: format!("{:?}", c), + constraint: format!("{c:?}"), } .fail(); } diff --git a/src/datanode/src/tests/instance_test.rs b/src/datanode/src/tests/instance_test.rs index 26ba03da73..09771f5eda 100644 --- a/src/datanode/src/tests/instance_test.rs +++ b/src/datanode/src/tests/instance_test.rs @@ -487,12 +487,11 @@ async fn test_insert_with_default_value_for_type(type_name: &str) { let create_sql = format!( r#"create table test_table( host string, - ts {} DEFAULT CURRENT_TIMESTAMP, + ts {type_name} DEFAULT CURRENT_TIMESTAMP, cpu double default 0, TIME INDEX (ts), PRIMARY KEY(host) ) engine=mito with(regions=1);"#, - type_name ); let output = execute_sql(&instance, &create_sql).await; assert!(matches!(output, Output::AffectedRows(1))); diff --git a/src/datanode/src/tests/test_util.rs b/src/datanode/src/tests/test_util.rs index a7cf8e1fe5..9fba0ff5f1 100644 --- a/src/datanode/src/tests/test_util.rs +++ b/src/datanode/src/tests/test_util.rs @@ -40,8 +40,8 @@ pub struct TestGuard { } pub fn create_tmp_dir_and_datanode_opts(name: &str) -> (DatanodeOptions, TestGuard) { - let wal_tmp_dir = TempDir::new(&format!("gt_wal_{}", name)).unwrap(); - let data_tmp_dir = TempDir::new(&format!("gt_data_{}", name)).unwrap(); + let wal_tmp_dir = TempDir::new(&format!("gt_wal_{name}")).unwrap(); + let data_tmp_dir = TempDir::new(&format!("gt_data_{name}")).unwrap(); let opts = DatanodeOptions { wal_dir: wal_tmp_dir.path().to_str().unwrap().to_string(), storage: ObjectStoreConfig::File { diff --git a/src/datatypes/src/error.rs b/src/datatypes/src/error.rs index 2cb8553a90..ddb390a8a5 100644 --- a/src/datatypes/src/error.rs +++ b/src/datatypes/src/error.rs @@ -139,7 +139,7 @@ mod tests { map.insert(false, 2); let result = serde_json::to_string(&map).context(SerializeSnafu); - assert!(result.is_err(), "serialize result is: {:?}", result); + assert!(result.is_err(), "serialize result is: {result:?}"); let err = serde_json::to_string(&map) .context(SerializeSnafu) .err() diff --git a/src/datatypes/src/lib.rs b/src/datatypes/src/lib.rs index 3051c7a4b3..ff15b33c89 100644 --- a/src/datatypes/src/lib.rs +++ b/src/datatypes/src/lib.rs @@ -12,9 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -#![feature(generic_associated_types)] -#![feature(assert_matches)] - pub mod arrow_array; pub mod data_type; pub mod error; diff --git a/src/datatypes/src/schema/constraint.rs b/src/datatypes/src/schema/constraint.rs index 4dd3ecc14b..f512f3190d 100644 --- a/src/datatypes/src/schema/constraint.rs +++ b/src/datatypes/src/schema/constraint.rs @@ -57,8 +57,8 @@ impl TryFrom for Vec { impl Display for ColumnDefaultConstraint { fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { match self { - ColumnDefaultConstraint::Function(expr) => write!(f, "{}", expr), - ColumnDefaultConstraint::Value(v) => write!(f, "{}", v), + ColumnDefaultConstraint::Function(expr) => write!(f, "{expr}"), + ColumnDefaultConstraint::Value(v) => write!(f, "{v}"), } } } @@ -172,10 +172,7 @@ fn create_current_timestamp_vector( std::iter::repeat(util::current_time_millis()).take(num_rows), ))), _ => error::DefaultValueTypeSnafu { - reason: format!( - "Not support to assign current timestamp to {:?} type", - data_type - ), + reason: format!("Not support to assign current timestamp to {data_type:?} type",), } .fail(), } @@ -301,6 +298,6 @@ mod tests { let err = constraint .create_default_vector(&data_type, false, 4) .unwrap_err(); - assert!(matches!(err, Error::DefaultValueType { .. }), "{:?}", err); + assert!(matches!(err, Error::DefaultValueType { .. }), "{err:?}"); } } diff --git a/src/datatypes/src/types/date_type.rs b/src/datatypes/src/types/date_type.rs index afd482359d..6b7bb788a3 100644 --- a/src/datatypes/src/types/date_type.rs +++ b/src/datatypes/src/types/date_type.rs @@ -83,7 +83,7 @@ impl LogicalPrimitiveType for DateType { ValueRef::Null => Ok(None), ValueRef::Date(v) => Ok(Some(v)), other => error::CastTypeSnafu { - msg: format!("Failed to cast value {:?} to Date", other,), + msg: format!("Failed to cast value {other:?} to Date"), } .fail(), } diff --git a/src/datatypes/src/types/datetime_type.rs b/src/datatypes/src/types/datetime_type.rs index ccd810eee7..47e1183a3a 100644 --- a/src/datatypes/src/types/datetime_type.rs +++ b/src/datatypes/src/types/datetime_type.rs @@ -84,7 +84,7 @@ impl LogicalPrimitiveType for DateTimeType { ValueRef::Null => Ok(None), ValueRef::DateTime(v) => Ok(Some(v)), other => error::CastTypeSnafu { - msg: format!("Failed to cast value {:?} to DateTime", other,), + msg: format!("Failed to cast value {other:?} to DateTime"), } .fail(), } diff --git a/src/datatypes/src/types/null_type.rs b/src/datatypes/src/types/null_type.rs index b9bb2dc752..21a008e1da 100644 --- a/src/datatypes/src/types/null_type.rs +++ b/src/datatypes/src/types/null_type.rs @@ -49,7 +49,7 @@ impl DataType for NullType { } fn create_mutable_vector(&self, _capacity: usize) -> Box { - Box::new(NullVectorBuilder::default()) + Box::::default() } fn is_timestamp_compatible(&self) -> bool { diff --git a/src/datatypes/src/value.rs b/src/datatypes/src/value.rs index 7201ffbac4..3adbd2c6f3 100644 --- a/src/datatypes/src/value.rs +++ b/src/datatypes/src/value.rs @@ -70,31 +70,31 @@ impl Display for Value { fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { match self { Value::Null => write!(f, "{}", self.data_type().name()), - Value::Boolean(v) => write!(f, "{}", v), - Value::UInt8(v) => write!(f, "{}", v), - Value::UInt16(v) => write!(f, "{}", v), - Value::UInt32(v) => write!(f, "{}", v), - Value::UInt64(v) => write!(f, "{}", v), - Value::Int8(v) => write!(f, "{}", v), - Value::Int16(v) => write!(f, "{}", v), - Value::Int32(v) => write!(f, "{}", v), - Value::Int64(v) => write!(f, "{}", v), - Value::Float32(v) => write!(f, "{}", v), - Value::Float64(v) => write!(f, "{}", v), + Value::Boolean(v) => write!(f, "{v}"), + Value::UInt8(v) => write!(f, "{v}"), + Value::UInt16(v) => write!(f, "{v}"), + Value::UInt32(v) => write!(f, "{v}"), + Value::UInt64(v) => write!(f, "{v}"), + Value::Int8(v) => write!(f, "{v}"), + Value::Int16(v) => write!(f, "{v}"), + Value::Int32(v) => write!(f, "{v}"), + Value::Int64(v) => write!(f, "{v}"), + Value::Float32(v) => write!(f, "{v}"), + Value::Float64(v) => write!(f, "{v}"), Value::String(v) => write!(f, "{}", v.as_utf8()), Value::Binary(v) => { let hex = v .iter() - .map(|b| format!("{:02x}", b)) + .map(|b| format!("{b:02x}")) .collect::>() .join(""); - write!(f, "{}", hex) + write!(f, "{hex}") } - Value::Date(v) => write!(f, "{}", v), - Value::DateTime(v) => write!(f, "{}", v), + Value::Date(v) => write!(f, "{v}"), + Value::DateTime(v) => write!(f, "{v}"), Value::Timestamp(v) => write!(f, "{}", v.to_iso8601_string()), Value::List(v) => { - let default = Box::new(vec![]); + let default = Box::>::default(); let items = v.items().as_ref().unwrap_or(&default); let items = items .iter() @@ -146,7 +146,7 @@ impl Value { Value::Null => Ok(None), Value::List(v) => Ok(Some(v)), other => error::CastTypeSnafu { - msg: format!("Failed to cast {:?} to list value", other), + msg: format!("Failed to cast {other:?} to list value"), } .fail(), } @@ -214,8 +214,7 @@ impl Value { output_type_id == value_type_id || self.is_null(), error::ToScalarValueSnafu { reason: format!( - "expect value to return output_type {:?}, actual: {:?}", - output_type_id, value_type_id, + "expect value to return output_type {output_type_id:?}, actual: {value_type_id:?}", ), } ); @@ -1345,7 +1344,7 @@ mod tests { ); assert_eq!( Value::List(ListValue::new( - Some(Box::new(vec![])), + Some(Box::default()), ConcreteDataType::timestamp_second_datatype(), )) .to_string(), @@ -1353,7 +1352,7 @@ mod tests { ); assert_eq!( Value::List(ListValue::new( - Some(Box::new(vec![])), + Some(Box::default()), ConcreteDataType::timestamp_millisecond_datatype(), )) .to_string(), @@ -1361,7 +1360,7 @@ mod tests { ); assert_eq!( Value::List(ListValue::new( - Some(Box::new(vec![])), + Some(Box::default()), ConcreteDataType::timestamp_microsecond_datatype(), )) .to_string(), @@ -1369,7 +1368,7 @@ mod tests { ); assert_eq!( Value::List(ListValue::new( - Some(Box::new(vec![])), + Some(Box::default()), ConcreteDataType::timestamp_nanosecond_datatype(), )) .to_string(), diff --git a/src/datatypes/src/vectors/binary.rs b/src/datatypes/src/vectors/binary.rs index 3b5defc8ec..b2756294c3 100644 --- a/src/datatypes/src/vectors/binary.rs +++ b/src/datatypes/src/vectors/binary.rs @@ -252,7 +252,7 @@ mod tests { #[test] fn test_serialize_binary_vector_to_json() { - let vector = BinaryVector::from(BinaryArray::from_iter_values(&[ + let vector = BinaryVector::from(BinaryArray::from_iter_values([ vec![1, 2, 3], vec![1, 2, 3], ])); @@ -281,7 +281,7 @@ mod tests { #[test] fn test_from_arrow_array() { - let arrow_array = BinaryArray::from_iter_values(&[vec![1, 2, 3], vec![1, 2, 3]]); + let arrow_array = BinaryArray::from_iter_values([vec![1, 2, 3], vec![1, 2, 3]]); let original = BinaryArray::from(arrow_array.data().clone()); let vector = BinaryVector::from(arrow_array); assert_eq!(original, vector.array); diff --git a/src/datatypes/src/vectors/boolean.rs b/src/datatypes/src/vectors/boolean.rs index 2b4e5b8e10..facbc2cfc6 100644 --- a/src/datatypes/src/vectors/boolean.rs +++ b/src/datatypes/src/vectors/boolean.rs @@ -296,7 +296,7 @@ mod tests { let vec = BooleanVector::from(input.clone()); assert_eq!(4, vec.len()); for (i, v) in input.into_iter().enumerate() { - assert_eq!(Some(v), vec.get_data(i), "failed at {}", i) + assert_eq!(Some(v), vec.get_data(i), "Failed at {i}") } } @@ -306,7 +306,7 @@ mod tests { let vec = input.iter().collect::(); assert_eq!(4, vec.len()); for (i, v) in input.into_iter().enumerate() { - assert_eq!(v, vec.get_data(i), "failed at {}", i) + assert_eq!(v, vec.get_data(i), "Failed at {i}") } } @@ -316,7 +316,7 @@ mod tests { let vec = BooleanVector::from(input.clone()); assert_eq!(4, vec.len()); for (i, v) in input.into_iter().enumerate() { - assert_eq!(v, vec.get_data(i), "failed at {}", i) + assert_eq!(v, vec.get_data(i), "failed at {i}") } } diff --git a/src/datatypes/src/vectors/constant.rs b/src/datatypes/src/vectors/constant.rs index 87739e9131..825d1dc7bd 100644 --- a/src/datatypes/src/vectors/constant.rs +++ b/src/datatypes/src/vectors/constant.rs @@ -203,7 +203,7 @@ mod tests { let a = Int32Vector::from_slice(vec![1]); let c = ConstantVector::new(Arc::new(a), 10); - let s = format!("{:?}", c); + let s = format!("{c:?}"); assert_eq!(s, "ConstantVector([Int32(1); 10])"); } diff --git a/src/datatypes/src/vectors/datetime.rs b/src/datatypes/src/vectors/datetime.rs index a40a3e54d3..524ada8869 100644 --- a/src/datatypes/src/vectors/datetime.rs +++ b/src/datatypes/src/vectors/datetime.rs @@ -37,7 +37,7 @@ mod tests { #[test] fn test_datetime_vector() { - let v = DateTimeVector::new(PrimitiveArray::from_slice(&[1, 2, 3])); + let v = DateTimeVector::new(PrimitiveArray::from_slice([1, 2, 3])); assert_eq!(ConcreteDataType::datetime_datatype(), v.data_type()); assert_eq!(3, v.len()); assert_eq!("DateTimeVector", v.vector_type_name()); diff --git a/src/datatypes/src/vectors/helper.rs b/src/datatypes/src/vectors/helper.rs index e3a2eaaa58..cd04eae643 100644 --- a/src/datatypes/src/vectors/helper.rs +++ b/src/datatypes/src/vectors/helper.rs @@ -205,7 +205,7 @@ impl Helper { | ScalarValue::Time64Microsecond(_) | ScalarValue::Time64Nanosecond(_) => { return error::ConversionSnafu { - from: format!("Unsupported scalar value: {}", value), + from: format!("Unsupported scalar value: {value}"), } .fail() } diff --git a/src/datatypes/src/vectors/list.rs b/src/datatypes/src/vectors/list.rs index 747e03557b..3e9b3637b8 100644 --- a/src/datatypes/src/vectors/list.rs +++ b/src/datatypes/src/vectors/list.rs @@ -157,10 +157,7 @@ impl From for ListVector { fn from(array: ListArray) -> Self { let item_type = ConcreteDataType::from_arrow_type(match array.data_type() { ArrowDataType::List(field) => field.data_type(), - other => panic!( - "Try to create ListVector from an arrow array with type {:?}", - other - ), + other => panic!("Try to create ListVector from an arrow array with type {other:?}"), }); Self { array, item_type } } diff --git a/src/datatypes/src/vectors/null.rs b/src/datatypes/src/vectors/null.rs index bb66e09b39..7f6d3fbeb1 100644 --- a/src/datatypes/src/vectors/null.rs +++ b/src/datatypes/src/vectors/null.rs @@ -167,7 +167,7 @@ impl MutableVector for NullVectorBuilder { ensure!( value.is_null(), error::CastTypeSnafu { - msg: format!("Failed to cast value ref {:?} to null", value), + msg: format!("Failed to cast value ref {value:?} to null"), } ); @@ -243,7 +243,7 @@ mod tests { #[test] fn test_debug_null_vector() { let array = NullVector::new(1024 * 1024); - assert_eq!(format!("{:?}", array), "NullVector(1048576)"); + assert_eq!(format!("{array:?}"), "NullVector(1048576)"); } #[test] diff --git a/src/datatypes/src/vectors/operations/filter.rs b/src/datatypes/src/vectors/operations/filter.rs index 8368a6afb4..d921a67bb2 100644 --- a/src/datatypes/src/vectors/operations/filter.rs +++ b/src/datatypes/src/vectors/operations/filter.rs @@ -45,11 +45,11 @@ mod tests { }; fn check_filter_primitive(expect: &[i32], input: &[i32], filter: &[bool]) { - let v = Int32Vector::from_slice(&input); + let v = Int32Vector::from_slice(input); let filter = BooleanVector::from_slice(filter); let out = v.filter(&filter).unwrap(); - let expect: VectorRef = Arc::new(Int32Vector::from_slice(&expect)); + let expect: VectorRef = Arc::new(Int32Vector::from_slice(expect)); assert_eq!(expect, out); } diff --git a/src/datatypes/src/vectors/primitive.rs b/src/datatypes/src/vectors/primitive.rs index 7829c31731..42bee1e339 100644 --- a/src/datatypes/src/vectors/primitive.rs +++ b/src/datatypes/src/vectors/primitive.rs @@ -365,7 +365,7 @@ pub(crate) fn replicate_primitive( return vector.get_slice(0, 0); } - let mut builder = PrimitiveVectorBuilder::::with_capacity(*offsets.last().unwrap() as usize); + let mut builder = PrimitiveVectorBuilder::::with_capacity(*offsets.last().unwrap()); let mut previous_offset = 0; diff --git a/src/frontend/src/catalog.rs b/src/frontend/src/catalog.rs index 0c66980334..0cfd453f7e 100644 --- a/src/frontend/src/catalog.rs +++ b/src/frontend/src/catalog.rs @@ -291,7 +291,7 @@ impl SchemaProvider for FrontendSchemaProvider { } Some(r) => r, }; - let val = TableGlobalValue::from_bytes(&res.1).context(InvalidCatalogValueSnafu)?; + let val = TableGlobalValue::from_bytes(res.1).context(InvalidCatalogValueSnafu)?; let table = Arc::new(DistTable::new( table_name, diff --git a/src/frontend/src/instance.rs b/src/frontend/src/instance.rs index 19d49a611d..b14bb136eb 100644 --- a/src/frontend/src/instance.rs +++ b/src/frontend/src/instance.rs @@ -643,7 +643,7 @@ impl GrpcQueryHandler for Instance { .await .map_err(BoxedError::new) .with_context(|_| server_error::ExecuteQuerySnafu { - query: format!("{:?}", insert_expr), + query: format!("{insert_expr:?}"), })?; let object_result = match output { Output::AffectedRows(rows) => ObjectResultBuilder::default() diff --git a/src/frontend/src/instance/distributed.rs b/src/frontend/src/instance/distributed.rs index 8205a8cd0e..31657c0f29 100644 --- a/src/frontend/src/instance/distributed.rs +++ b/src/frontend/src/instance/distributed.rs @@ -241,12 +241,12 @@ impl DistInstance { .schema(schema_name) .context(CatalogSnafu)? .context(SchemaNotFoundSnafu { - schema_info: format!("{}.{}", catalog_name, schema_name), + schema_info: format!("{catalog_name}.{schema_name}"), })? .table(table_name) .context(CatalogSnafu)? .context(TableNotFoundSnafu { - table_name: format!("{}.{}.{}", catalog_name, schema_name, table_name), + table_name: format!("{catalog_name}.{schema_name}.{table_name}"), })?; let dist_table = table @@ -392,7 +392,7 @@ impl GrpcAdminHandler for DistInstance { } .map_err(BoxedError::new) .context(server_error::ExecuteQuerySnafu { - query: format!("{:?}", query), + query: format!("{query:?}"), }) } } diff --git a/src/frontend/src/instance/opentsdb.rs b/src/frontend/src/instance/opentsdb.rs index 89cb869fc5..b52f37aabb 100644 --- a/src/frontend/src/instance/opentsdb.rs +++ b/src/frontend/src/instance/opentsdb.rs @@ -51,7 +51,7 @@ impl Instance { .await .map_err(BoxedError::new) .with_context(|_| server_error::ExecuteQuerySnafu { - query: format!("{:?}", data_point), + query: format!("{data_point:?}"), })?; Ok(()) } diff --git a/src/frontend/src/instance/prometheus.rs b/src/frontend/src/instance/prometheus.rs index d1a848e158..fde5e0b43c 100644 --- a/src/frontend/src/instance/prometheus.rs +++ b/src/frontend/src/instance/prometheus.rs @@ -54,8 +54,7 @@ fn negotiate_response_type(accepted_response_types: &[i32]) -> ServerResult { @@ -139,7 +138,7 @@ impl PrometheusProtocolHandler for Instance { .await .map_err(BoxedError::new) .with_context(|_| error::ExecuteInsertSnafu { - msg: format!("{:?}", request), + msg: format!("{request:?}"), })?; } } diff --git a/src/frontend/src/spliter.rs b/src/frontend/src/spliter.rs index f70116b69e..d7753d434c 100644 --- a/src/frontend/src/spliter.rs +++ b/src/frontend/src/spliter.rs @@ -66,7 +66,7 @@ impl WriteSpliter { { Ok(region_id) => region_id, Err(e) => { - let reason = format!("{:?}", e); + let reason = format!("{e:?}"); return FindRegionSnafu { reason }.fail(); } }; diff --git a/src/frontend/src/table.rs b/src/frontend/src/table.rs index 9b26dc2d0e..b7291dc9b6 100644 --- a/src/frontend/src/table.rs +++ b/src/frontend/src/table.rs @@ -162,9 +162,9 @@ impl DistTable { filters: &[Expr], ) -> Result> { let regions = if let Some((first, rest)) = filters.split_first() { - let mut target = self.find_regions0(partition_rule.clone(), first)?; + let mut target = Self::find_regions0(partition_rule.clone(), first)?; for filter in rest { - let regions = self.find_regions0(partition_rule.clone(), filter)?; + let regions = Self::find_regions0(partition_rule.clone(), filter)?; // When all filters are provided as a collection, it often implicitly states that // "all filters must be satisfied". So we join all the results here. @@ -193,7 +193,6 @@ impl DistTable { // - expr with arithmetic like "a + 1 < 10" (should have been optimized in logic plan?) // - not comparison or neither "AND" nor "OR" operations, for example, "a LIKE x" fn find_regions0( - &self, partition_rule: PartitionRuleRef, filter: &Expr, ) -> Result> { @@ -222,9 +221,9 @@ impl DistTable { if matches!(op, Operator::And | Operator::Or) => { let left_regions = - self.find_regions0(partition_rule.clone(), &(*left.clone()).into())?; + Self::find_regions0(partition_rule.clone(), &(*left.clone()).into())?; let right_regions = - self.find_regions0(partition_rule.clone(), &(*right.clone()).into())?; + Self::find_regions0(partition_rule.clone(), &(*right.clone()).into())?; let regions = match op { Operator::And => left_regions .intersection(&right_regions) diff --git a/src/frontend/src/table/route.rs b/src/frontend/src/table/route.rs index eaeb3e14c0..8099d43a30 100644 --- a/src/frontend/src/table/route.rs +++ b/src/frontend/src/table/route.rs @@ -44,7 +44,7 @@ impl TableRoutes { .await .map_err(|e| { error::GetCacheSnafu { - err_msg: format!("{:?}", e), + err_msg: format!("{e:?}"), } .build() }) diff --git a/src/frontend/src/table/scan.rs b/src/frontend/src/table/scan.rs index 3d9f623aeb..e0f3dc78d5 100644 --- a/src/frontend/src/table/scan.rs +++ b/src/frontend/src/table/scan.rs @@ -82,7 +82,7 @@ impl DatanodeInstance { let table_provider = Arc::new(DfTableProviderAdapter::new(self.table.clone())); let mut builder = LogicalPlanBuilder::scan_with_filters( - &table_scan.table_name.to_string(), + table_scan.table_name.to_string(), Arc::new(DefaultTableSource::new(table_provider)), table_scan.projection.clone(), table_scan diff --git a/src/frontend/src/tests.rs b/src/frontend/src/tests.rs index 37292458f3..d6a074373b 100644 --- a/src/frontend/src/tests.rs +++ b/src/frontend/src/tests.rs @@ -59,8 +59,8 @@ pub(crate) async fn create_frontend_instance(test_name: &str) -> (Arc, } fn create_tmp_dir_and_datanode_opts(name: &str) -> (DatanodeOptions, TestGuard) { - let wal_tmp_dir = TempDir::new(&format!("gt_wal_{}", name)).unwrap(); - let data_tmp_dir = TempDir::new(&format!("gt_data_{}", name)).unwrap(); + let wal_tmp_dir = TempDir::new(&format!("gt_wal_{name}")).unwrap(); + let data_tmp_dir = TempDir::new(&format!("gt_data_{name}")).unwrap(); let opts = DatanodeOptions { wal_dir: wal_tmp_dir.path().to_str().unwrap().to_string(), storage: ObjectStoreConfig::File { @@ -138,8 +138,8 @@ async fn create_dist_datanode_instance( meta_srv: MockInfo, ) -> Arc { let current = common_time::util::current_time_millis(); - let wal_tmp_dir = TempDir::new_in("/tmp", &format!("dist_datanode-wal-{}", current)).unwrap(); - let data_tmp_dir = TempDir::new_in("/tmp", &format!("dist_datanode-data-{}", current)).unwrap(); + let wal_tmp_dir = TempDir::new_in("/tmp", &format!("dist_datanode-wal-{current}")).unwrap(); + let data_tmp_dir = TempDir::new_in("/tmp", &format!("dist_datanode-data-{current}")).unwrap(); let opts = DatanodeOptions { node_id: Some(datanode_id), wal_dir: wal_tmp_dir.path().to_str().unwrap().to_string(), diff --git a/src/log-store/src/fs/chunk.rs b/src/log-store/src/fs/chunk.rs index d123684cd9..a59b34e557 100644 --- a/src/log-store/src/fs/chunk.rs +++ b/src/log-store/src/fs/chunk.rs @@ -145,7 +145,7 @@ impl Buffer for ChunkList { } left -= actual; } else { - panic!("Advance step [{}] exceeds max readable bytes", by); + panic!("Advance step [{by}] exceeds max readable bytes"); } } } diff --git a/src/log-store/src/fs/file.rs b/src/log-store/src/fs/file.rs index 163cbe22d6..132fbd337e 100644 --- a/src/log-store/src/fs/file.rs +++ b/src/log-store/src/fs/file.rs @@ -653,7 +653,7 @@ fn read_at(file: &Arc, offset: usize, file_length: usize) -> Result if offset > file_length { return Err(Eof); } - let size = CHUNK_SIZE.min((file_length - offset) as usize); + let size = CHUNK_SIZE.min(file_length - offset); let mut data = Box::new([0u8; CHUNK_SIZE]); crate::fs::io::pread_exact(file.as_ref(), &mut data[0..size], offset as u64)?; Ok(Chunk::new(data, size)) @@ -684,7 +684,7 @@ mod tests { let mut file = LogFile::open(path.clone(), &config) .await - .unwrap_or_else(|_| panic!("Failed to open file: {}", path)); + .unwrap_or_else(|_| panic!("Failed to open file: {path}")); file.start().await.expect("Failed to start log file"); assert_eq!( @@ -873,7 +873,7 @@ mod tests { let mut file = LogFile::open(path.clone(), &config) .await - .unwrap_or_else(|_| panic!("Failed to open file: {}", path)); + .unwrap_or_else(|_| panic!("Failed to open file: {path}")); let state = file.state.clone(); file.start().await.unwrap(); diff --git a/src/log-store/src/fs/file_name.rs b/src/log-store/src/fs/file_name.rs index b4b04968f0..5555138039 100644 --- a/src/log-store/src/fs/file_name.rs +++ b/src/log-store/src/fs/file_name.rs @@ -97,13 +97,13 @@ mod tests { #[test] pub fn test_padding_file_name() { let id = u64::MIN; - assert_eq!("00000000000000000000", format!("{:020}", id)); + assert_eq!("00000000000000000000", format!("{id:020}")); let id = 123u64; - assert_eq!("00000000000000000123", format!("{:020}", id)); + assert_eq!("00000000000000000123", format!("{id:020}")); let id = 123123123123u64; - assert_eq!("00000000123123123123", format!("{:020}", id)); + assert_eq!("00000000123123123123", format!("{id:020}")); let id = u64::MAX; - assert_eq!(u64::MAX.to_string(), format!("{:020}", id)); + assert_eq!(u64::MAX.to_string(), format!("{id:020}")); } #[test] diff --git a/src/log-store/src/fs/io/unix.rs b/src/log-store/src/fs/io/unix.rs index 09dc2bf921..f0936ada2c 100644 --- a/src/log-store/src/fs/io/unix.rs +++ b/src/log-store/src/fs/io/unix.rs @@ -20,9 +20,9 @@ use snafu::ResultExt; use crate::error::{Error, IoSnafu}; pub fn pread_exact(file: &File, buf: &mut [u8], offset: u64) -> Result<(), Error> { - file.read_exact_at(buf, offset as u64).context(IoSnafu) + file.read_exact_at(buf, offset).context(IoSnafu) } pub fn pwrite_all(file: &File, buf: &[u8], offset: u64) -> Result<(), Error> { - file.write_all_at(buf, offset as u64).context(IoSnafu) + file.write_all_at(buf, offset).context(IoSnafu) } diff --git a/src/log-store/src/fs/log.rs b/src/log-store/src/fs/log.rs index 38c8dc285f..96576b330d 100644 --- a/src/log-store/src/fs/log.rs +++ b/src/log-store/src/fs/log.rs @@ -93,8 +93,7 @@ impl LocalFileLogStore { Arc::get_mut(active_file) .with_context(|| InternalSnafu { msg: format!( - "Concurrent modification on log store {} start is not allowed", - active_file_name + "Concurrent modification on log store {active_file_name} start is not allowed" ), })? .start() @@ -143,9 +142,9 @@ impl LocalFileLogStore { let file = LogFile::open(path, config).await?; info!("Load log store file {}: {:?}", start_id, file); if map.contains_key(&start_id) { - error!("Log file with start entry id: {} already exists", start_id); + error!("Log file with start entry id: {start_id} already exists"); return DuplicateFileSnafu { - msg: format!("File with start id: {} duplicates on start", start_id), + msg: format!("File with start id: {start_id} duplicates on start"), } .fail(); } diff --git a/src/meta-client/src/client.rs b/src/meta-client/src/client.rs index 1c88c832c1..f85fec8b4c 100644 --- a/src/meta-client/src/client.rs +++ b/src/meta-client/src/client.rs @@ -326,7 +326,7 @@ mod tests { async fn gen_data(&self) { for i in 0..10 { let req = PutRequest::new() - .with_key(self.key(&format!("key-{}", i))) + .with_key(self.key(&format!("key-{i}"))) .with_value(format!("{}-{}", "value", i).into_bytes()) .with_prev_kv(); let res = self.client.put(req).await; @@ -547,7 +547,7 @@ mod tests { let kvs = res.unwrap().take_kvs(); assert_eq!(10, kvs.len()); for (i, mut kv) in kvs.into_iter().enumerate() { - assert_eq!(tc.key(&format!("key-{}", i)), kv.take_key()); + assert_eq!(tc.key(&format!("key-{i}")), kv.take_key()); assert_eq!(format!("{}-{}", "value", i).into_bytes(), kv.take_value()); } } diff --git a/src/meta-srv/src/keys.rs b/src/meta-srv/src/keys.rs index 6add27c86b..0f6bf7a22d 100644 --- a/src/meta-srv/src/keys.rs +++ b/src/meta-srv/src/keys.rs @@ -31,7 +31,7 @@ pub(crate) const TABLE_ROUTE_PREFIX: &str = "__meta_table_route"; lazy_static! { static ref DATANODE_KEY_PATTERN: Regex = - Regex::new(&format!("^{}-([0-9]+)-([0-9]+)$", DN_LEASE_PREFIX)).unwrap(); + Regex::new(&format!("^{DN_LEASE_PREFIX}-([0-9]+)-([0-9]+)$")).unwrap(); } #[derive(Debug, Clone, Eq, PartialEq)] pub struct LeaseKey { @@ -52,10 +52,10 @@ impl FromStr for LeaseKey { let cluster_id = caps[1].to_string(); let node_id = caps[2].to_string(); let cluster_id: u64 = cluster_id.parse().context(error::ParseNumSnafu { - err_msg: format!("invalid cluster_id: {}", cluster_id), + err_msg: format!("invalid cluster_id: {cluster_id}"), })?; let node_id: u64 = node_id.parse().context(error::ParseNumSnafu { - err_msg: format!("invalid node_id: {}", node_id), + err_msg: format!("invalid node_id: {node_id}"), })?; Ok(Self { @@ -118,7 +118,7 @@ impl TryFrom for Vec { fn try_from(dn_value: LeaseValue) -> Result { Ok(serde_json::to_string(&dn_value) .context(error::SerializeToJsonSnafu { - input: format!("{:?}", dn_value), + input: format!("{dn_value:?}"), })? .into_bytes()) } diff --git a/src/meta-srv/src/lease.rs b/src/meta-srv/src/lease.rs index 41a9b77678..570749a765 100644 --- a/src/meta-srv/src/lease.rs +++ b/src/meta-srv/src/lease.rs @@ -53,5 +53,5 @@ where #[inline] pub fn get_lease_prefix(cluster_id: u64) -> Vec { - format!("{}-{}", DN_LEASE_PREFIX, cluster_id).into_bytes() + format!("{DN_LEASE_PREFIX}-{cluster_id}").into_bytes() } diff --git a/src/meta-srv/src/service/heartbeat.rs b/src/meta-srv/src/service/heartbeat.rs index e3882478f4..331b6b3b10 100644 --- a/src/meta-srv/src/service/heartbeat.rs +++ b/src/meta-srv/src/service/heartbeat.rs @@ -100,7 +100,7 @@ impl heartbeat_server::Heartbeat for MetaSrv { pusher_key.as_ref().unwrap_or(&"unknow".to_string()) ); if let Some(key) = pusher_key { - let _ = handler_group.unregister(&key); + let _ = handler_group.unregister(&key).await; } }); diff --git a/src/meta-srv/src/service/router.rs b/src/meta-srv/src/service/router.rs index 1162b34dac..18cf40df43 100644 --- a/src/meta-srv/src/service/router.rs +++ b/src/meta-srv/src/service/router.rs @@ -164,7 +164,7 @@ async fn handle_delete(req: DeleteRequest, ctx: Context) -> Result Result> { - let tg_key = format!("{}", key).into_bytes(); + let tg_key = format!("{key}").into_bytes(); let tv = get_from_store(kv_store, tg_key).await?; match tv { Some(tv) => { - let tv = TableGlobalValue::from_bytes(&tv).context(error::InvalidCatalogValueSnafu)?; + let tv = TableGlobalValue::from_bytes(tv).context(error::InvalidCatalogValueSnafu)?; Ok(Some(tv)) } None => Ok(None), diff --git a/src/mito/src/engine.rs b/src/mito/src/engine.rs index 2c2f092617..cab3d527dc 100644 --- a/src/mito/src/engine.rs +++ b/src/mito/src/engine.rs @@ -49,7 +49,7 @@ const INIT_TABLE_VERSION: TableVersion = 0; /// Generate region name in the form of "{TABLE_ID}_{REGION_NUMBER}" #[inline] fn region_name(table_id: TableId, n: u32) -> String { - format!("{}_{:010}", table_id, n) + format!("{table_id}_{n:010}") } #[inline] @@ -59,7 +59,7 @@ fn region_id(table_id: TableId, n: u32) -> RegionId { #[inline] fn table_dir(schema_name: &str, table_id: TableId) -> String { - format!("{}/{}/", schema_name, table_id) + format!("{schema_name}/{table_id}/") } /// [TableEngine] implementation. @@ -109,15 +109,15 @@ impl TableEngine for MitoEngine { Ok(self.inner.alter_table(ctx, req).await?) } - fn get_table<'a>( + fn get_table( &self, _ctx: &EngineContext, - table_ref: &'a TableReference, + table_ref: &TableReference, ) -> TableResult> { Ok(self.inner.get_table(table_ref)) } - fn table_exists<'a>(&self, _ctx: &EngineContext, table_ref: &'a TableReference) -> bool { + fn table_exists(&self, _ctx: &EngineContext, table_ref: &TableReference) -> bool { self.inner.get_table(table_ref).is_some() } @@ -292,7 +292,7 @@ impl MitoEngineInner { return Ok(table); } else { return TableExistsSnafu { - table_name: format!("{}.{}.{}", catalog_name, schema_name, table_name), + table_name: format!("{catalog_name}.{schema_name}.{table_name}"), } .fail(); } @@ -459,7 +459,7 @@ impl MitoEngineInner { Ok(table) } - fn get_table<'a>(&self, table_ref: &'a TableReference) -> Option { + fn get_table(&self, table_ref: &TableReference) -> Option { self.tables .read() .unwrap() @@ -876,7 +876,7 @@ mod tests { let result = table_engine.create_table(&ctx, request).await; assert!(result.is_err()); - assert!(matches!(result, Err(e) if format!("{:?}", e).contains("Table already exists"))); + assert!(matches!(result, Err(e) if format!("{e:?}").contains("Table already exists"))); } #[tokio::test] diff --git a/src/mito/src/table.rs b/src/mito/src/table.rs index 463e7c866e..74488d3f40 100644 --- a/src/mito/src/table.rs +++ b/src/mito/src/table.rs @@ -56,7 +56,7 @@ use crate::manifest::TableManifest; #[inline] fn table_manifest_dir(table_dir: &str) -> String { - format!("{}/manifest/", table_dir) + format!("{table_dir}/manifest/") } /// [Table] implementation. @@ -284,7 +284,7 @@ impl Stream for ChunkStream { #[inline] fn column_qualified_name(table_name: &str, region_name: &str, column_name: &str) -> String { - format!("{}.{}.{}", table_name, region_name, column_name) + format!("{table_name}.{region_name}.{column_name}") } impl MitoTable { diff --git a/src/query/src/datafusion.rs b/src/query/src/datafusion.rs index 79c3bc7938..21c4cc767e 100644 --- a/src/query/src/datafusion.rs +++ b/src/query/src/datafusion.rs @@ -281,7 +281,7 @@ mod tests { // TODO(sunng87): do not rely on to_string for compare assert_eq!( - format!("{:?}", plan), + format!("{plan:?}"), r#"DfPlan(Limit: skip=0, fetch=20 Projection: SUM(numbers.number) Aggregate: groupBy=[[]], aggr=[[SUM(numbers.number)]] diff --git a/src/query/src/optimizer.rs b/src/query/src/optimizer.rs index 2e66588769..513d96e5ba 100644 --- a/src/query/src/optimizer.rs +++ b/src/query/src/optimizer.rs @@ -34,11 +34,7 @@ use datatypes::arrow::datatypes::DataType; pub struct TypeConversionRule; impl OptimizerRule for TypeConversionRule { - fn optimize( - &self, - plan: &LogicalPlan, - optimizer_config: &mut OptimizerConfig, - ) -> Result { + fn optimize(&self, plan: &LogicalPlan, _config: &mut OptimizerConfig) -> Result { let mut converter = TypeConverter { schemas: plan.all_schemas(), }; @@ -46,7 +42,7 @@ impl OptimizerRule for TypeConversionRule { match plan { LogicalPlan::Filter(filter) => Ok(LogicalPlan::Filter(Filter::try_new( filter.predicate().clone().rewrite(&mut converter)?, - Arc::new(self.optimize(filter.input(), optimizer_config)?), + Arc::new(self.optimize(filter.input(), _config)?), )?)), LogicalPlan::TableScan(TableScan { table_name, @@ -92,7 +88,7 @@ impl OptimizerRule for TypeConversionRule { let inputs = plan.inputs(); let new_inputs = inputs .iter() - .map(|plan| self.optimize(plan, optimizer_config)) + .map(|plan| self.optimize(plan, _config)) .collect::>>()?; let expr = plan @@ -175,8 +171,7 @@ impl<'a> TypeConverter<'a> { let casted_right = Self::cast_scalar_value(value, left_type)?; if casted_right.is_null() { return Err(DataFusionError::Plan(format!( - "column:{:?} value:{:?} is invalid", - col, value + "column:{col:?} value:{value:?} is invalid", ))); } if reverse { diff --git a/src/query/tests/argmax_test.rs b/src/query/tests/argmax_test.rs index cbf1ae931d..88dbde83e4 100644 --- a/src/query/tests/argmax_test.rs +++ b/src/query/tests/argmax_test.rs @@ -82,10 +82,7 @@ async fn execute_argmax<'a>( table_name: &'a str, engine: Arc, ) -> RecordResult> { - let sql = format!( - "select ARGMAX({}) as argmax from {}", - column_name, table_name - ); + let sql = format!("select ARGMAX({column_name}) as argmax from {table_name}"); let plan = engine .sql_to_plan(&sql, Arc::new(QueryContext::new())) .unwrap(); diff --git a/src/query/tests/argmin_test.rs b/src/query/tests/argmin_test.rs index 546fa9ae23..2655a8db17 100644 --- a/src/query/tests/argmin_test.rs +++ b/src/query/tests/argmin_test.rs @@ -82,10 +82,7 @@ async fn execute_argmin<'a>( table_name: &'a str, engine: Arc, ) -> RecordResult> { - let sql = format!( - "select argmin({}) as argmin from {}", - column_name, table_name - ); + let sql = format!("select argmin({column_name}) as argmin from {table_name}"); let plan = engine .sql_to_plan(&sql, Arc::new(QueryContext::new())) .unwrap(); diff --git a/src/query/tests/function.rs b/src/query/tests/function.rs index 7de93a6265..3a0bad3351 100644 --- a/src/query/tests/function.rs +++ b/src/query/tests/function.rs @@ -81,7 +81,7 @@ pub async fn get_numbers_from_table<'s, T>( where T: WrapperType, { - let sql = format!("SELECT {} FROM {}", column_name, table_name); + let sql = format!("SELECT {column_name} FROM {table_name}"); let plan = engine .sql_to_plan(&sql, Arc::new(QueryContext::new())) .unwrap(); diff --git a/src/query/tests/mean_test.rs b/src/query/tests/mean_test.rs index 000323fb21..56bf327339 100644 --- a/src/query/tests/mean_test.rs +++ b/src/query/tests/mean_test.rs @@ -78,7 +78,7 @@ async fn execute_mean<'a>( table_name: &'a str, engine: Arc, ) -> RecordResult> { - let sql = format!("select MEAN({}) as mean from {}", column_name, table_name); + let sql = format!("select MEAN({column_name}) as mean from {table_name}"); let plan = engine .sql_to_plan(&sql, Arc::new(QueryContext::new())) .unwrap(); diff --git a/src/query/tests/my_sum_udaf_example.rs b/src/query/tests/my_sum_udaf_example.rs index 54d3a62a5b..06adca86c1 100644 --- a/src/query/tests/my_sum_udaf_example.rs +++ b/src/query/tests/my_sum_udaf_example.rs @@ -217,10 +217,7 @@ where Arc::new(|| Arc::new(MySumAccumulatorCreator::default())), ))); - let sql = format!( - "select MY_SUM({}) as my_sum from {}", - column_name, table_name - ); + let sql = format!("select MY_SUM({column_name}) as my_sum from {table_name}"); let plan = engine.sql_to_plan(&sql, Arc::new(QueryContext::new()))?; let output = engine.execute(&plan).await?; diff --git a/src/query/tests/percentile_test.rs b/src/query/tests/percentile_test.rs index e639d4b3e6..724d80c663 100644 --- a/src/query/tests/percentile_test.rs +++ b/src/query/tests/percentile_test.rs @@ -85,7 +85,7 @@ where let expected_value = numbers.iter().map(|&n| n.as_()).collect::>(); let expected_value: inc_stats::Percentiles = expected_value.iter().cloned().collect(); - let expected_value = expected_value.percentile(&0.5).unwrap(); + let expected_value = expected_value.percentile(0.5).unwrap(); assert_eq!(value, expected_value.into()); Ok(()) } @@ -95,10 +95,7 @@ async fn execute_percentile<'a>( table_name: &'a str, engine: Arc, ) -> RecordResult> { - let sql = format!( - "select PERCENTILE({},50.0) as percentile from {}", - column_name, table_name - ); + let sql = format!("select PERCENTILE({column_name},50.0) as percentile from {table_name}"); let plan = engine .sql_to_plan(&sql, Arc::new(QueryContext::new())) .unwrap(); diff --git a/src/query/tests/polyval_test.rs b/src/query/tests/polyval_test.rs index 248c0d42d7..d174d20ec0 100644 --- a/src/query/tests/polyval_test.rs +++ b/src/query/tests/polyval_test.rs @@ -78,10 +78,7 @@ async fn execute_polyval<'a>( table_name: &'a str, engine: Arc, ) -> RecordResult> { - let sql = format!( - "select POLYVAL({}, 0) as polyval from {}", - column_name, table_name - ); + let sql = format!("select POLYVAL({column_name}, 0) as polyval from {table_name}"); let plan = engine .sql_to_plan(&sql, Arc::new(QueryContext::new())) .unwrap(); diff --git a/src/query/tests/scipy_stats_norm_cdf_test.rs b/src/query/tests/scipy_stats_norm_cdf_test.rs index dee8f5c87e..0c8f502518 100644 --- a/src/query/tests/scipy_stats_norm_cdf_test.rs +++ b/src/query/tests/scipy_stats_norm_cdf_test.rs @@ -76,8 +76,7 @@ async fn execute_scipy_stats_norm_cdf<'a>( engine: Arc, ) -> RecordResult> { let sql = format!( - "select SCIPYSTATSNORMCDF({},2.0) as scipy_stats_norm_cdf from {}", - column_name, table_name + "select SCIPYSTATSNORMCDF({column_name},2.0) as scipy_stats_norm_cdf from {table_name}", ); let plan = engine .sql_to_plan(&sql, Arc::new(QueryContext::new())) diff --git a/src/query/tests/scipy_stats_norm_pdf.rs b/src/query/tests/scipy_stats_norm_pdf.rs index 03e4cf1292..1142db4364 100644 --- a/src/query/tests/scipy_stats_norm_pdf.rs +++ b/src/query/tests/scipy_stats_norm_pdf.rs @@ -76,8 +76,7 @@ async fn execute_scipy_stats_norm_pdf<'a>( engine: Arc, ) -> RecordResult> { let sql = format!( - "select SCIPYSTATSNORMPDF({},2.0) as scipy_stats_norm_pdf from {}", - column_name, table_name + "select SCIPYSTATSNORMPDF({column_name},2.0) as scipy_stats_norm_pdf from {table_name}" ); let plan = engine .sql_to_plan(&sql, Arc::new(QueryContext::new())) diff --git a/src/script/src/lib.rs b/src/script/src/lib.rs index 43db30b5d4..adb949918c 100644 --- a/src/script/src/lib.rs +++ b/src/script/src/lib.rs @@ -12,7 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -#![feature(iterator_try_reduce)] pub mod engine; pub mod error; #[cfg(feature = "python")] diff --git a/src/script/src/python/builtins/mod.rs b/src/script/src/python/builtins/mod.rs index 4cd52cc609..f23cd63ad0 100644 --- a/src/script/src/python/builtins/mod.rs +++ b/src/script/src/python/builtins/mod.rs @@ -145,7 +145,7 @@ fn try_into_py_obj(col: DFColValue, vm: &VirtualMachine) -> PyResult { let ret = PyVector::from( HelperVec::try_into_vector(arr) - .map_err(|err| vm.new_type_error(format!("Unsupported type: {:#?}", err)))?, + .map_err(|err| vm.new_type_error(format!("Unsupported type: {err:#?}")))?, ) .into_pyobject(vm); Ok(ret) @@ -319,13 +319,11 @@ pub(crate) mod greptime_builtin { let func: Option = FUNCTION_REGISTRY.get_function(name); let res = match func { Some(f) => f.eval(Default::default(), &v), - None => return Err(vm.new_type_error(format!("Can't find function {}", name))), + None => return Err(vm.new_type_error(format!("Can't find function {name}"))), }; match res { Ok(v) => Ok(v.into()), - Err(err) => { - Err(vm.new_runtime_error(format!("Fail to evaluate the function,: {}", err))) - } + Err(err) => Err(vm.new_runtime_error(format!("Fail to evaluate the function,: {err}"))), } } @@ -338,26 +336,24 @@ pub(crate) mod greptime_builtin { let func = FUNCTION_REGISTRY.get_aggr_function(name); let f = match func { Some(f) => f.create().creator(), - None => return Err(vm.new_type_error(format!("Can't find function {}", name))), + None => return Err(vm.new_type_error(format!("Can't find function {name}"))), }; let types: Vec<_> = v.iter().map(|v| v.data_type()).collect(); let acc = f(&types); let mut acc = match acc { Ok(acc) => acc, Err(err) => { - return Err(vm.new_runtime_error(format!("Failed to create accumulator: {}", err))) + return Err(vm.new_runtime_error(format!("Failed to create accumulator: {err}"))) } }; match acc.update_batch(&v) { Ok(_) => (), - Err(err) => { - return Err(vm.new_runtime_error(format!("Failed to update batch: {}", err))) - } + Err(err) => return Err(vm.new_runtime_error(format!("Failed to update batch: {err}"))), }; let res = match acc.evaluate() { Ok(r) => r, Err(err) => { - return Err(vm.new_runtime_error(format!("Failed to evaluate accumulator: {}", err))) + return Err(vm.new_runtime_error(format!("Failed to evaluate accumulator: {err}"))) } }; let res = val_to_pyobj(res, vm); @@ -792,7 +788,7 @@ pub(crate) mod greptime_builtin { ConstantVector::new(Arc::new(Int64Vector::from_vec(vec![pow])) as _, len_base); Arc::new(ret) as _ } else { - return Err(vm.new_type_error(format!("Unsupported type({:#?}) for pow()", pow))); + return Err(vm.new_type_error(format!("Unsupported type({pow:#?}) for pow()"))); }; // pyfunction can return PyResult<...>, args can be like PyObjectRef or anything // impl IntoPyNativeFunc, see rustpython-vm function for more details @@ -837,8 +833,7 @@ pub(crate) mod greptime_builtin { let ret = cur.slice(0, 0); let ret = Helper::try_into_vector(ret.clone()).map_err(|e| { vm.new_type_error(format!( - "Can't cast result into vector, result: {:?}, err: {:?}", - ret, e + "Can't cast result into vector, result: {ret:?}, err: {e:?}", )) })?; return Ok(ret.into()); @@ -850,8 +845,7 @@ pub(crate) mod greptime_builtin { })?; let ret = Helper::try_into_vector(ret.clone()).map_err(|e| { vm.new_type_error(format!( - "Can't cast result into vector, result: {:?}, err: {:?}", - ret, e + "Can't cast result into vector, result: {ret:?}, err: {e:?}", )) })?; Ok(ret.into()) @@ -864,8 +858,7 @@ pub(crate) mod greptime_builtin { let ret = cur.slice(0, 0); let ret = Helper::try_into_vector(ret.clone()).map_err(|e| { vm.new_type_error(format!( - "Can't cast result into vector, result: {:?}, err: {:?}", - ret, e + "Can't cast result into vector, result: {ret:?}, err: {e:?}", )) })?; return Ok(ret.into()); @@ -877,8 +870,7 @@ pub(crate) mod greptime_builtin { })?; let ret = Helper::try_into_vector(ret.clone()).map_err(|e| { vm.new_type_error(format!( - "Can't cast result into vector, result: {:?}, err: {:?}", - ret, e + "Can't cast result into vector, result: {ret:?}, err: {e:?}", )) })?; Ok(ret.into()) @@ -929,7 +921,7 @@ pub(crate) mod greptime_builtin { .as_any() .downcast_ref::() .ok_or_else(|| { - vm.new_type_error(format!("ts must be int64, found: {:?}", ts_array_ref)) + vm.new_type_error(format!("ts must be int64, found: {ts_array_ref:?}")) })?; let slices = { let oldest = aggregate::min(ts) @@ -975,7 +967,7 @@ pub(crate) mod greptime_builtin { }, Err(err) => Err(vm .new_runtime_error( - format!("expect `interval()`'s `func` return a PyVector(`vector`) or int/float/bool, found return to be {:?}, error msg: {err}", obj) + format!("expect `interval()`'s `func` return a PyVector(`vector`) or int/float/bool, found return to be {obj:?}, error msg: {err}") ) ) } @@ -1019,8 +1011,7 @@ pub(crate) mod greptime_builtin { }; let ret = Helper::try_into_vector(ret.clone()).map_err(|e| { vm.new_type_error(format!( - "Can't cast result into vector, result: {:?}, err: {:?}", - ret, e + "Can't cast result into vector, result: {ret:?}, err: {e:?}", )) })?; Ok(ret.into()) @@ -1036,8 +1027,7 @@ pub(crate) mod greptime_builtin { }; let ret = Helper::try_into_vector(ret.clone()).map_err(|e| { vm.new_type_error(format!( - "Can't cast result into vector, result: {:?}, err: {:?}", - ret, e + "Can't cast result into vector, result: {ret:?}, err: {e:?}", )) })?; Ok(ret.into()) diff --git a/src/script/src/python/builtins/test.rs b/src/script/src/python/builtins/test.rs index 16828ba883..d9ab067811 100644 --- a/src/script/src/python/builtins/test.rs +++ b/src/script/src/python/builtins/test.rs @@ -88,7 +88,7 @@ fn convert_scalar_to_py_obj_and_back() { let col = try_into_columnar_value(list_obj, vm); if let Err(err) = col { let reason = format_py_error(err, vm); - assert!(format!("{}", reason).contains( + assert!(format!("{reason}").contains( "TypeError: All elements in a list should be same type to cast to Datafusion list!" )); } @@ -353,7 +353,7 @@ fn run_builtin_fn_testcases() { }, Err(err) => { if !err_res.contains(&err){ - panic!("Error message not containing, expect {err_res}, found {}", err) + panic!("Error message not containing, expect {err_res}, found {err}") } } } diff --git a/src/script/src/python/coprocessor.rs b/src/script/src/python/coprocessor.rs index 3dcc348562..b9a77ef340 100644 --- a/src/script/src/python/coprocessor.rs +++ b/src/script/src/python/coprocessor.rs @@ -185,9 +185,9 @@ fn try_into_columns( col_len: usize, ) -> Result> { if is_instance::(obj, vm) { - let tuple = obj.payload::().with_context(|| { - ret_other_error_with(format!("can't cast obj {:?} to PyTuple)", obj)) - })?; + let tuple = obj + .payload::() + .with_context(|| ret_other_error_with(format!("can't cast obj {obj:?} to PyTuple)")))?; let cols = tuple .iter() .map(|obj| py_vec_obj_to_array(obj, vm, col_len)) @@ -206,7 +206,7 @@ fn select_from_rb(rb: &RecordBatch, fetch_names: &[String]) -> Result Re // It's safe to unwrap loc, it is always exists. stmts.push(gen_call(name, deco_args, &loc.unwrap())); } else { - return fail_parse_error!( - format!("Expect statement in script, found: {:?}", top), - None, - ); + return fail_parse_error!(format!("Expect statement in script, found: {top:?}"), None); } // use `compile::Mode::BlockExpr` so it return the result of statement compile_top( diff --git a/src/script/src/python/coprocessor/parse.rs b/src/script/src/python/coprocessor/parse.rs index 324b5f7fc8..b8280a8db1 100644 --- a/src/script/src/python/coprocessor/parse.rs +++ b/src/script/src/python/coprocessor/parse.rs @@ -99,7 +99,7 @@ fn try_into_datatype(ty: &str, loc: &Location) -> Result> { "_" => Ok(None), // note the different between "_" and _ _ => fail_parse_error!( - format!("Unknown datatype: {ty} at {:?}", loc), + format!("Unknown datatype: {ty} at {loc:?}"), Some(loc.to_owned()) ), } @@ -209,10 +209,7 @@ fn check_annotation_ret_slice(sub: &ast::Expr<()>) -> Result<&ast::Expr<()>> { ensure!( id == "vector", ret_parse_error( - format!( - "Wrong type annotation, expect `vector[...]`, found `{}`", - id - ), + format!("Wrong type annotation, expect `vector[...]`, found `{id}`"), Some(value.location) ) ); diff --git a/src/script/src/python/error.rs b/src/script/src/python/error.rs index 6e20e86db0..9564e373f7 100644 --- a/src/script/src/python/error.rs +++ b/src/script/src/python/error.rs @@ -221,7 +221,7 @@ pub fn get_error_reason_loc(err: &Error) -> (String, Option) { Error::PyRuntime { msg, .. } => (msg.clone(), None), Error::PyParse { source, .. } => (source.error.to_string(), Some(source.location)), Error::PyCompile { source, .. } => (source.error.to_string(), Some(source.location)), - _ => (format!("Unknown error: {:?}", err), None), + _ => (format!("Unknown error: {err:?}"), None), } } diff --git a/src/script/src/python/test.rs b/src/script/src/python/test.rs index 49b511c101..901e8391ba 100644 --- a/src/script/src/python/test.rs +++ b/src/script/src/python/test.rs @@ -153,7 +153,7 @@ fn run_ron_testcases() { } => { let rb = create_sample_recordbatch(); let res = coprocessor::exec_coprocessor(&testcase.code, &rb); - assert!(res.is_err(), "{:#?}\nExpect Err(...), actual Ok(...)", res); + assert!(res.is_err(), "{res:#?}\nExpect Err(...), actual Ok(...)"); if let Err(res) = res { error!( "{}", diff --git a/src/script/src/python/utils.rs b/src/script/src/python/utils.rs index 8f078c163c..56c73ccb3e 100644 --- a/src/script/src/python/utils.rs +++ b/src/script/src/python/utils.rs @@ -40,7 +40,7 @@ pub fn format_py_error(excep: PyBaseExceptionRef, vm: &VirtualMachine) -> error: let mut msg = String::new(); if let Err(e) = vm.write_exception(&mut msg, &excep) { return error::Error::PyRuntime { - msg: format!("Failed to write exception msg, err: {}", e), + msg: format!("Failed to write exception msg, err: {e}"), backtrace: Backtrace::generate(), }; } @@ -59,9 +59,9 @@ pub fn py_vec_obj_to_array( ) -> Result { // It's ugly, but we can't find a better way right now. if is_instance::(obj, vm) { - let pyv = obj.payload::().with_context(|| { - ret_other_error_with(format!("can't cast obj {:?} to PyVector", obj)) - })?; + let pyv = obj + .payload::() + .with_context(|| ret_other_error_with(format!("can't cast obj {obj:?} to PyVector")))?; Ok(pyv.as_vector_ref()) } else if is_instance::(obj, vm) { let val = obj @@ -110,6 +110,6 @@ pub fn py_vec_obj_to_array( _ => unreachable!(), } } else { - ret_other_error_with(format!("Expect a vector or a constant, found {:?}", obj)).fail() + ret_other_error_with(format!("Expect a vector or a constant, found {obj:?}")).fail() } } diff --git a/src/script/src/python/vector.rs b/src/script/src/python/vector.rs index 47fae45ed1..7ec61fbd4c 100644 --- a/src/script/src/python/vector.rs +++ b/src/script/src/python/vector.rs @@ -59,28 +59,26 @@ fn emit_cast_error( dst_ty: &ArrowDataType, ) -> PyBaseExceptionRef { vm.new_type_error(format!( - "Can't cast source operand of type {:?} into target type of {:?}", - src_ty, dst_ty + "Can't cast source operand of type {src_ty:?} into target type of {dst_ty:?}", )) } /// Performs `val - arr`. fn arrow_rsub(arr: &dyn Array, val: &dyn Array, vm: &VirtualMachine) -> PyResult { - arithmetic::subtract_dyn(val, arr).map_err(|e| vm.new_type_error(format!("rsub error: {}", e))) + arithmetic::subtract_dyn(val, arr).map_err(|e| vm.new_type_error(format!("rsub error: {e}"))) } /// Performs `val / arr` fn arrow_rtruediv(arr: &dyn Array, val: &dyn Array, vm: &VirtualMachine) -> PyResult { - arithmetic::divide_dyn(val, arr) - .map_err(|e| vm.new_type_error(format!("rtruediv error: {}", e))) + arithmetic::divide_dyn(val, arr).map_err(|e| vm.new_type_error(format!("rtruediv error: {e}"))) } /// Performs `val / arr`, but cast to i64. fn arrow_rfloordiv(arr: &dyn Array, val: &dyn Array, vm: &VirtualMachine) -> PyResult { let array = arithmetic::divide_dyn(val, arr) - .map_err(|e| vm.new_type_error(format!("rtruediv divide error: {}", e)))?; + .map_err(|e| vm.new_type_error(format!("rtruediv divide error: {e}")))?; compute::cast(&array, &ArrowDataType::Int64) - .map_err(|e| vm.new_type_error(format!("rtruediv cast error: {}", e))) + .map_err(|e| vm.new_type_error(format!("rtruediv cast error: {e}"))) } fn wrap_result(f: F) -> impl Fn(&dyn Array, &dyn Array, &VirtualMachine) -> PyResult @@ -88,7 +86,7 @@ where F: Fn(&dyn Array, &dyn Array) -> ArrowResult, { move |left, right, vm| { - f(left, right).map_err(|e| vm.new_type_error(format!("arithmetic error {}", e))) + f(left, right).map_err(|e| vm.new_type_error(format!("arithmetic error {e}"))) } } @@ -154,8 +152,7 @@ impl PyVector { v } else { return Err(vm.new_type_error(format!( - "Can't cast pyobject {:?} into concrete type {:?}", - obj, datatype + "Can't cast pyobject {obj:?} into concrete type {datatype:?}", ))); }; // Safety: `pyobj_try_to_typed_val()` has checked the data type. @@ -262,8 +259,7 @@ impl PyVector { Ok(Helper::try_into_vector(result.clone()) .map_err(|e| { vm.new_type_error(format!( - "Can't cast result into vector, result: {:?}, err: {:?}", - result, e + "Can't cast result into vector, result: {result:?}, err: {e:?}", )) })? .into()) @@ -305,13 +301,12 @@ impl PyVector { let right = cast(right, &target_type, vm)?; let result = op(left.as_ref(), right.as_ref()) - .map_err(|e| vm.new_type_error(format!("Can't compute op, error: {}", e)))?; + .map_err(|e| vm.new_type_error(format!("Can't compute op, error: {e}")))?; Ok(Helper::try_into_vector(result.clone()) .map_err(|e| { vm.new_type_error(format!( - "Can't cast result into vector, result: {:?}, err: {:?}", - result, e + "Can't cast result into vector, result: {result:?}, err: {e:?}", )) })? .into()) @@ -549,8 +544,7 @@ impl PyVector { res.map_err(|err| vm.new_runtime_error(format!("Arrow Error: {err:#?}")))?; let ret = Helper::try_into_vector(res.clone()).map_err(|e| { vm.new_type_error(format!( - "Can't cast result into vector, result: {:?}, err: {:?}", - res, e + "Can't cast result into vector, result: {res:?}, err: {e:?}", )) })?; Ok(ret.into()) @@ -580,7 +574,7 @@ impl PyVector { let res = compute::filter(self.to_arrow_array().as_ref(), mask) .map_err(|err| vm.new_runtime_error(format!("Arrow Error: {err:#?}")))?; let ret = Helper::try_into_vector(res.clone()).map_err(|e| { - vm.new_type_error(format!("Can't cast result into vector, err: {:?}", e)) + vm.new_type_error(format!("Can't cast result into vector, err: {e:?}")) })?; Ok(Self::from(ret).into_pyobject(vm)) } else { @@ -683,7 +677,7 @@ fn get_arrow_scalar_op( move |a: &dyn Array, b: &dyn Array, vm| -> PyResult { let array = - op_bool_arr(a, b).map_err(|e| vm.new_type_error(format!("scalar op error: {}", e)))?; + op_bool_arr(a, b).map_err(|e| vm.new_type_error(format!("scalar op error: {e}")))?; Ok(Arc::new(array)) } } @@ -932,7 +926,7 @@ fn get_concrete_type(obj: &PyObjectRef, vm: &VirtualMachine) -> PyResult(obj, vm) { Ok(ConcreteDataType::string_datatype()) } else { - Err(vm.new_type_error(format!("Unsupported pyobject type: {:?}", obj))) + Err(vm.new_type_error(format!("Unsupported pyobject type: {obj:?}"))) } } @@ -1205,7 +1199,7 @@ pub mod tests { } } } else { - panic!("{code}: {:?}", result) + panic!("{code}: {result:?}") } } } diff --git a/src/servers/src/auth/user_provider.rs b/src/servers/src/auth/user_provider.rs index f58dbb4853..d2888cc5e3 100644 --- a/src/servers/src/auth/user_provider.rs +++ b/src/servers/src/auth/user_provider.rs @@ -243,7 +243,7 @@ admin=654321", assert!(lw.flush().is_ok()); } - let param = format!("file:{}", file_path); + let param = format!("file:{file_path}"); let provider = StaticUserProvider::try_from(param.as_str()).unwrap(); test_auth(&provider, "root", "123456").await; test_auth(&provider, "admin", "654321").await; diff --git a/src/servers/src/grpc/handler.rs b/src/servers/src/grpc/handler.rs index 8ee4ce88ae..a087f76aaf 100644 --- a/src/servers/src/grpc/handler.rs +++ b/src/servers/src/grpc/handler.rs @@ -79,7 +79,7 @@ impl BatchHandler { // 1. prevent the execution from being cancelled unexpected by tonic runtime. // 2. avoid the handler blocks the gRPC runtime because `exec_admin_request` may block // the caller thread. - let _ = self.runtime.spawn(async move { + self.runtime.spawn(async move { let result = future.await; // Ignore send result. Usually an error indicates the rx is dropped (request timeouted). diff --git a/src/servers/src/http.rs b/src/servers/src/http.rs index 263b8b1193..ccb28b0e11 100644 --- a/src/servers/src/http.rs +++ b/src/servers/src/http.rs @@ -255,7 +255,7 @@ impl JsonResponse { Err(e) => { return Self::with_error( - format!("Recordbatch error: {}", e), + format!("Recordbatch error: {e}"), e.status_code(), ); } @@ -271,7 +271,7 @@ impl JsonResponse { }, Err(e) => { return Self::with_error( - format!("Query engine output error: {}", e), + format!("Query engine output error: {e}"), e.status_code(), ); } @@ -378,7 +378,7 @@ impl HttpServer { ..Info::default() }, servers: vec![OpenAPIServer { - url: format!("/{}", HTTP_API_VERSION), + url: format!("/{HTTP_API_VERSION}"), ..OpenAPIServer::default() }], ..OpenApi::default() @@ -392,25 +392,25 @@ impl HttpServer { .finish_api(&mut api) .layer(Extension(Arc::new(api))); - let mut router = Router::new().nest(&format!("/{}", HTTP_API_VERSION), sql_router); + let mut router = Router::new().nest(&format!("/{HTTP_API_VERSION}"), sql_router); if let Some(opentsdb_handler) = self.opentsdb_handler.clone() { router = router.nest( - &format!("/{}/opentsdb", HTTP_API_VERSION), + &format!("/{HTTP_API_VERSION}/opentsdb"), self.route_opentsdb(opentsdb_handler), ); } if let Some(influxdb_handler) = self.influxdb_handler.clone() { router = router.nest( - &format!("/{}/influxdb", HTTP_API_VERSION), + &format!("/{HTTP_API_VERSION}/influxdb"), self.route_influxdb(influxdb_handler), ); } if let Some(prom_handler) = self.prom_handler.clone() { router = router.nest( - &format!("/{}/prometheus", HTTP_API_VERSION), + &format!("/{HTTP_API_VERSION}/prometheus"), self.route_prom(prom_handler), ); } @@ -513,7 +513,7 @@ impl Server for HttpServer { /// handle error middleware async fn handle_error(err: BoxError) -> Json { Json(JsonResponse::with_error( - format!("Unhandled internal error: {}", err), + format!("Unhandled internal error: {err}"), StatusCode::Unexpected, )) } diff --git a/src/servers/src/http/handler.rs b/src/servers/src/http/handler.rs index 419b0f891b..361a00dab2 100644 --- a/src/servers/src/http/handler.rs +++ b/src/servers/src/http/handler.rs @@ -52,13 +52,13 @@ pub async fn sql( Ok(true) => query_ctx.set_current_schema(db), Ok(false) => { return Json(JsonResponse::with_error( - format!("Database not found: {}", db), + format!("Database not found: {db}"), StatusCode::DatabaseNotFound, )); } Err(e) => { return Json(JsonResponse::with_error( - format!("Error checking database: {}, {}", db, e), + format!("Error checking database: {db}, {e}"), StatusCode::Internal, )); } diff --git a/src/servers/src/http/opentsdb.rs b/src/servers/src/http/opentsdb.rs index d47e26b441..62a2060990 100644 --- a/src/servers/src/http/opentsdb.rs +++ b/src/servers/src/http/opentsdb.rs @@ -214,7 +214,7 @@ mod test { assert_eq!(data_points.len(), 1); assert_eq!(data_points[0], data_point1); - let body = Body::from(format!("[{},{}]", raw_data_point1, raw_data_point2)); + let body = Body::from(format!("[{raw_data_point1},{raw_data_point2}]")); let data_points = parse_data_points(body).await.unwrap(); assert_eq!(data_points.len(), 2); assert_eq!(data_points[0], data_point1); diff --git a/src/servers/src/http/script.rs b/src/servers/src/http/script.rs index 04d0571b8d..3683f8aeb0 100644 --- a/src/servers/src/http/script.rs +++ b/src/servers/src/http/script.rs @@ -62,7 +62,7 @@ pub async fn scripts( let body = match script_handler.insert_script(name.unwrap(), &script).await { Ok(()) => JsonResponse::with_output(None), - Err(e) => json_err!(format!("Insert script error: {}", e), e.status_code()), + Err(e) => json_err!(format!("Insert script error: {e}"), e.status_code()), }; Json(body) diff --git a/src/servers/src/influxdb.rs b/src/servers/src/influxdb.rs index 870f6918b8..93da4c2c07 100644 --- a/src/servers/src/influxdb.rs +++ b/src/servers/src/influxdb.rs @@ -81,10 +81,7 @@ impl TryFrom<&InfluxdbRequest> for Vec { writer.commit(); } - Ok(writers - .into_iter() - .map(|(_, writer)| writer.finish()) - .collect()) + Ok(writers.into_values().map(|x| x.finish()).collect()) } } diff --git a/src/servers/src/mysql/federated.rs b/src/servers/src/mysql/federated.rs index 1736ae67fe..d9e5d635af 100644 --- a/src/servers/src/mysql/federated.rs +++ b/src/servers/src/mysql/federated.rs @@ -55,7 +55,7 @@ static SHOW_SQL_MODE_PATTERN: Lazy = Lazy::new(|| Regex::new("(?i)^(SHOW VARIABLES LIKE 'sql_mode'(.*))").unwrap()); static OTHER_NOT_SUPPORTED_STMT: Lazy = Lazy::new(|| { - RegexSet::new(&[ + RegexSet::new([ // Txn. "(?i)^(ROLLBACK(.*))", "(?i)^(COMMIT(.*))", diff --git a/src/servers/src/opentsdb.rs b/src/servers/src/opentsdb.rs index dbe0fb601a..a50c87907e 100644 --- a/src/servers/src/opentsdb.rs +++ b/src/servers/src/opentsdb.rs @@ -84,7 +84,7 @@ impl OpentsdbServer { let connection = Connection::new(stream); let mut handler = Handler::new(query_handler, connection, shutdown); - let _ = io_runtime.spawn(async move { + io_runtime.spawn(async move { if let Err(e) = handler.run().await { error!(e; "Unexpected error when handling OpenTSDB connection"); } diff --git a/src/servers/src/opentsdb/codec.rs b/src/servers/src/opentsdb/codec.rs index 49fccc4848..6dc61f6784 100644 --- a/src/servers/src/opentsdb/codec.rs +++ b/src/servers/src/opentsdb/codec.rs @@ -48,7 +48,7 @@ impl DataPoint { // OpenTSDB command is case sensitive, verified in real OpenTSDB. if cmd != "put" { return error::InvalidQuerySnafu { - reason: format!("unknown command {}.", cmd), + reason: format!("unknown command {cmd}."), } .fail(); } @@ -89,7 +89,7 @@ impl DataPoint { let tag = token.split('=').collect::>(); if tag.len() != 2 || tag[0].is_empty() || tag[1].is_empty() { return error::InvalidQuerySnafu { - reason: format!("put: invalid tag: {}", token), + reason: format!("put: invalid tag: {token}"), } .fail(); } @@ -97,7 +97,7 @@ impl DataPoint { let tagv = tag[1].to_string(); if tags.iter().any(|(t, _)| t == &tagk) { return error::InvalidQuerySnafu { - reason: format!("put: illegal argument: duplicate tag: {}", tagk), + reason: format!("put: illegal argument: duplicate tag: {tagk}"), } .fail(); } diff --git a/src/servers/src/postgres/auth_handler.rs b/src/servers/src/postgres/auth_handler.rs index 22ea5798ba..4fd7aad9e2 100644 --- a/src/servers/src/postgres/auth_handler.rs +++ b/src/servers/src/postgres/auth_handler.rs @@ -162,7 +162,7 @@ impl StartupHandler for PgAuthStartupHandler { client, "FATAL", "3D000", - format!("Database not found: {}", db), + format!("Database not found: {db}"), ) .await?; return Ok(()); diff --git a/src/servers/src/postgres/handler.rs b/src/servers/src/postgres/handler.rs index 6fa4da6a16..e7f68f1fc0 100644 --- a/src/servers/src/postgres/handler.rs +++ b/src/servers/src/postgres/handler.rs @@ -193,7 +193,7 @@ fn type_translate(origin: &ConcreteDataType) -> Result { &ConcreteDataType::DateTime(_) => Ok(Type::TIMESTAMP), &ConcreteDataType::Timestamp(_) => Ok(Type::TIMESTAMP), &ConcreteDataType::List(_) => error::InternalSnafu { - err_msg: format!("not implemented for column datatype {:?}", origin), + err_msg: format!("not implemented for column datatype {origin:?}"), } .fail(), } @@ -336,7 +336,7 @@ mod test { let err = encode_value( &Value::List(ListValue::new( - Some(Box::new(vec![])), + Some(Box::default()), ConcreteDataType::int8_datatype(), )), &mut builder, @@ -344,7 +344,7 @@ mod test { .unwrap_err(); match err { PgWireError::ApiError(e) => { - assert!(format!("{}", e).contains("Internal error:")); + assert!(format!("{e}").contains("Internal error:")); } _ => { unreachable!() diff --git a/src/servers/src/prometheus.rs b/src/servers/src/prometheus.rs index 80d9db0b74..b252b1cfa4 100644 --- a/src/servers/src/prometheus.rs +++ b/src/servers/src/prometheus.rs @@ -63,8 +63,7 @@ pub fn query_to_sql(db: &str, q: &Query) -> Result<(String, String)> { let mut conditions: Vec = Vec::with_capacity(label_matches.len()); conditions.push(format!( - "{}>={} AND {}<={}", - TIMESTAMP_COLUMN_NAME, start_timestamp_ms, TIMESTAMP_COLUMN_NAME, end_timestamp_ms, + "{TIMESTAMP_COLUMN_NAME}>={start_timestamp_ms} AND {TIMESTAMP_COLUMN_NAME}<={end_timestamp_ms}", )); for m in label_matches { @@ -82,18 +81,18 @@ pub fn query_to_sql(db: &str, q: &Query) -> Result<(String, String)> { match m_type { MatcherType::Eq => { - conditions.push(format!("{}='{}'", name, value)); + conditions.push(format!("{name}='{value}'")); } MatcherType::Neq => { - conditions.push(format!("{}!='{}'", name, value)); + conditions.push(format!("{name}!='{value}'")); } // Case sensitive regexp match MatcherType::Re => { - conditions.push(format!("{}~'{}'", name, value)); + conditions.push(format!("{name}~'{value}'")); } // Case sensitive regexp not match MatcherType::Nre => { - conditions.push(format!("{}!~'{}'", name, value)); + conditions.push(format!("{name}!~'{value}'")); } } } @@ -103,8 +102,7 @@ pub fn query_to_sql(db: &str, q: &Query) -> Result<(String, String)> { Ok(( table_name.to_string(), format!( - "select * from {}.{} where {} order by {}", - db, table_name, conditions, TIMESTAMP_COLUMN_NAME, + "select * from {db}.{table_name} where {conditions} order by {TIMESTAMP_COLUMN_NAME}", ), )) } diff --git a/src/servers/src/server.rs b/src/servers/src/server.rs index 70e020fcd0..bce62845f9 100644 --- a/src/servers/src/server.rs +++ b/src/servers/src/server.rs @@ -19,7 +19,7 @@ use async_trait::async_trait; use common_runtime::Runtime; use common_telemetry::logging::{error, info}; use futures::future::{AbortHandle, AbortRegistration, Abortable}; -use snafu::ResultExt; +use snafu::{ensure, ResultExt}; use tokio::sync::Mutex; use tokio::task::JoinHandle; use tokio_stream::wrappers::TcpListenerStream; @@ -64,12 +64,12 @@ impl AcceptTask { name, error ); } else { - info!("{} server is shutdown.", name); + info!("{name} server is shutdown."); } Ok(()) } None => error::InternalSnafu { - err_msg: format!("{} server is not started.", name), + err_msg: format!("{name} server is not started."), } .fail()?, } @@ -86,32 +86,31 @@ impl AcceptTask { tokio::net::TcpListener::bind(addr) .await .context(error::TokioIoSnafu { - err_msg: format!("{} failed to bind addr {}", name, addr), + err_msg: format!("{name} failed to bind addr {addr}"), })?; // get actually bond addr in case input addr use port 0 let addr = listener.local_addr()?; - info!("{} server started at {}", name, addr); + info!("{name} server started at {addr}"); let stream = TcpListenerStream::new(listener); let stream = Abortable::new(stream, registration); Ok((stream, addr)) } None => error::InternalSnafu { - err_msg: format!("{} server has been started.", name), + err_msg: format!("{name} server has been started."), } .fail()?, } } fn start_with(&mut self, join_handle: JoinHandle<()>, name: &str) -> Result<()> { - if self.join_handle.is_some() { - return error::InternalSnafu { - err_msg: format!("{} server has been started.", name), + ensure!( + self.join_handle.is_none(), + error::InternalSnafu { + err_msg: format!("{name} server has been started."), } - .fail(); - } - let _ = self.join_handle.insert(join_handle); - + ); + self.join_handle.get_or_insert(join_handle); Ok(()) } } diff --git a/src/servers/tests/http/http_handler_test.rs b/src/servers/tests/http/http_handler_test.rs index 17a3e8235e..b15d3844cd 100644 --- a/src/servers/tests/http/http_handler_test.rs +++ b/src/servers/tests/http/http_handler_test.rs @@ -60,7 +60,7 @@ async fn test_sql_output_rows() { axum::Extension(UserInfo::default()), ) .await; - assert!(json.success(), "{:?}", json); + assert!(json.success(), "{json:?}"); assert!(json.error().is_none()); match &json.output().expect("assertion failed")[0] { JsonOutput::Records(records) => { @@ -103,7 +103,7 @@ def test(n): body, ) .await; - assert!(!json.success(), "{:?}", json); + assert!(!json.success(), "{json:?}"); assert_eq!(json.error().unwrap(), "Invalid argument: invalid name"); let body = RawBody(Body::from(script)); @@ -117,7 +117,7 @@ def test(n): body, ) .await; - assert!(json.success(), "{:?}", json); + assert!(json.success(), "{json:?}"); assert!(json.error().is_none()); assert!(json.output().is_none()); } diff --git a/src/servers/tests/http/opentsdb_test.rs b/src/servers/tests/http/opentsdb_test.rs index ffb76d8f89..227093e563 100644 --- a/src/servers/tests/http/opentsdb_test.rs +++ b/src/servers/tests/http/opentsdb_test.rs @@ -202,13 +202,12 @@ async fn test_opentsdb_debug_put() { fn create_data_point(metric: &str) -> String { format!( r#"{{ - "metric": "{}", + "metric": "{metric}", "timestamp": 1000, "value": 1, "tags": {{ "host": "web01" }} }}"#, - metric ) } diff --git a/src/servers/tests/mysql/mysql_server_test.rs b/src/servers/tests/mysql/mysql_server_test.rs index 2d1aac91a9..eca4f05b2d 100644 --- a/src/servers/tests/mysql/mysql_server_test.rs +++ b/src/servers/tests/mysql/mysql_server_test.rs @@ -266,8 +266,7 @@ async fn test_query_concurrently() -> Result<()> { let expected: u32 = rand.gen_range(0..100); let result: u32 = connection .query_first(format!( - "SELECT uint32s FROM numbers WHERE uint32s = {}", - expected + "SELECT uint32s FROM numbers WHERE uint32s = {expected}" )) .await .unwrap() diff --git a/src/servers/tests/opentsdb.rs b/src/servers/tests/opentsdb.rs index 12c08ec89a..e9611703cd 100644 --- a/src/servers/tests/opentsdb.rs +++ b/src/servers/tests/opentsdb.rs @@ -105,7 +105,7 @@ async fn test_shutdown_opentsdb_server_concurrently() -> Result<()> { match stream { Ok(stream) => { let mut connection = Connection::new(stream); - let result = connection.write_line(format!("put {} 1 1", i)).await; + let result = connection.write_line(format!("put {i} 1 1")).await; i += 1; if i > 4 { @@ -116,7 +116,7 @@ async fn test_shutdown_opentsdb_server_concurrently() -> Result<()> { if let Err(e) = result { match e { Error::InternalIo { .. } => return, - _ => panic!("Not IO error, err is {}", e), + _ => panic!("Not IO error, err is {e}"), } } @@ -170,13 +170,13 @@ async fn test_opentsdb_connection_shutdown() -> Result<()> { let mut i = 2; loop { // The connection may not be unwritable after shutdown immediately. - let result = connection.write_line(format!("put {} 1 1", i)).await; + let result = connection.write_line(format!("put {i} 1 1")).await; i += 1; if result.is_err() { if let Err(e) = result { match e { Error::InternalIo { .. } => break, - _ => panic!("Not IO error, err is {}", e), + _ => panic!("Not IO error, err is {e}"), } } } @@ -250,10 +250,7 @@ async fn test_query_concurrently() -> Result<()> { let stream = TcpStream::connect(addr).await.unwrap(); let mut connection = Connection::new(stream); for i in 0..expect_executed_queries_per_worker { - connection - .write_line(format!("put {} 1 1", i)) - .await - .unwrap(); + connection.write_line(format!("put {i} 1 1")).await.unwrap(); let should_recreate_conn = rand.gen_range(0..100) == 1; if should_recreate_conn { diff --git a/src/servers/tests/postgres/mod.rs b/src/servers/tests/postgres/mod.rs index 556fb52875..a6b4ab977a 100644 --- a/src/servers/tests/postgres/mod.rs +++ b/src/servers/tests/postgres/mod.rs @@ -162,8 +162,7 @@ async fn test_query_pg_concurrently() -> Result<()> { let result: u32 = unwrap_results( client .simple_query(&format!( - "SELECT uint32s FROM numbers WHERE uint32s = {}", - expected + "SELECT uint32s FROM numbers WHERE uint32s = {expected}" )) .await .unwrap() @@ -284,14 +283,10 @@ async fn create_secure_connection( ) -> std::result::Result { let url = if with_pwd { format!( - "sslmode=require host=127.0.0.1 port={} user=test_user password=test_pwd connect_timeout=2, dbname={}", - port, DEFAULT_SCHEMA_NAME + "sslmode=require host=127.0.0.1 port={port} user=test_user password=test_pwd connect_timeout=2, dbname={DEFAULT_SCHEMA_NAME}", ) } else { - format!( - "host=127.0.0.1 port={} connect_timeout=2 dbname={}", - port, DEFAULT_SCHEMA_NAME - ) + format!("host=127.0.0.1 port={port} connect_timeout=2 dbname={DEFAULT_SCHEMA_NAME}") }; let mut config = rustls::ClientConfig::builder() @@ -315,14 +310,10 @@ async fn create_plain_connection( ) -> std::result::Result { let url = if with_pwd { format!( - "host=127.0.0.1 port={} user=test_user password=test_pwd connect_timeout=2 dbname={}", - port, DEFAULT_SCHEMA_NAME + "host=127.0.0.1 port={port} user=test_user password=test_pwd connect_timeout=2 dbname={DEFAULT_SCHEMA_NAME}", ) } else { - format!( - "host=127.0.0.1 port={} connect_timeout=2 dbname={}", - port, DEFAULT_SCHEMA_NAME - ) + format!("host=127.0.0.1 port={port} connect_timeout=2 dbname={DEFAULT_SCHEMA_NAME}") }; let (client, conn) = tokio_postgres::connect(&url, NoTls).await?; tokio::spawn(conn); @@ -333,17 +324,14 @@ async fn create_connection_with_given_db( port: u16, db: &str, ) -> std::result::Result { - let url = format!( - "host=127.0.0.1 port={} connect_timeout=2 dbname={}", - port, db - ); + let url = format!("host=127.0.0.1 port={port} connect_timeout=2 dbname={db}"); let (client, conn) = tokio_postgres::connect(&url, NoTls).await?; tokio::spawn(conn); Ok(client) } async fn create_connection_without_db(port: u16) -> std::result::Result { - let url = format!("host=127.0.0.1 port={} connect_timeout=2", port); + let url = format!("host=127.0.0.1 port={port} connect_timeout=2"); let (client, conn) = tokio_postgres::connect(&url, NoTls).await?; tokio::spawn(conn); Ok(client) @@ -351,7 +339,7 @@ async fn create_connection_without_db(port: u16) -> std::result::Result Option<&str> { match resp { - &SimpleQueryMessage::Row(ref r) => r.get(col_index), + SimpleQueryMessage::Row(r) => r.get(col_index), _ => None, } } diff --git a/src/sql/src/parser.rs b/src/sql/src/parser.rs index 3a14fb0666..b2c4513a65 100644 --- a/src/sql/src/parser.rs +++ b/src/sql/src/parser.rs @@ -322,8 +322,7 @@ impl<'a> ParserContext<'a> { // Report unexpected token pub(crate) fn expected(&self, expected: &str, found: Token) -> Result { Err(ParserError::ParserError(format!( - "Expected {}, found: {}", - expected, found + "Expected {expected}, found: {found}", ))) .context(SyntaxSnafu { sql: self.sql }) } diff --git a/src/sql/src/parsers/insert_parser.rs b/src/sql/src/parsers/insert_parser.rs index 43709407ad..0f8c0b0aa7 100644 --- a/src/sql/src/parsers/insert_parser.rs +++ b/src/sql/src/parsers/insert_parser.rs @@ -65,6 +65,6 @@ mod tests { pub fn test_parse_invalid_insert() { let sql = r"INSERT INTO table_1 VALUES ("; // intentionally a bad sql let result = ParserContext::create_with_dialect(sql, &GenericDialect {}); - assert!(result.is_err(), "result is: {:?}", result); + assert!(result.is_err(), "result is: {result:?}"); } } diff --git a/src/sql/src/statements.rs b/src/sql/src/statements.rs index 24b1527819..afcd0eb1bc 100644 --- a/src/sql/src/statements.rs +++ b/src/sql/src/statements.rs @@ -65,8 +65,7 @@ pub fn table_idents_to_full_name(obj_name: &ObjectName) -> Result<(String, Strin )), _ => error::InvalidSqlSnafu { msg: format!( - "expect table name to be ..
, .
or
, actual: {}", - obj_name + "expect table name to be ..
, .
or
, actual: {obj_name}", ), } .fail(), @@ -94,7 +93,7 @@ fn parse_string_to_value( Ok(Value::Date(date)) } else { ParseSqlValueSnafu { - msg: format!("Failed to parse {} to Date value", s), + msg: format!("Failed to parse {s} to Date value"), } .fail() } @@ -104,7 +103,7 @@ fn parse_string_to_value( Ok(Value::DateTime(datetime)) } else { ParseSqlValueSnafu { - msg: format!("Failed to parse {} to DateTime value", s), + msg: format!("Failed to parse {s} to DateTime value"), } .fail() } @@ -117,7 +116,7 @@ fn parse_string_to_value( ))) } else { ParseSqlValueSnafu { - msg: format!("Failed to parse {} to Timestamp value", s), + msg: format!("Failed to parse {s} to Timestamp value"), } .fail() } @@ -172,7 +171,7 @@ where match n.parse::() { Ok(n) => Ok(n), Err(e) => ParseSqlValueSnafu { - msg: format!("Fail to parse number {}, {:?}", n, e), + msg: format!("Fail to parse number {n}, {e:?}"), } .fail(), } @@ -220,7 +219,7 @@ fn parse_column_default_constraint( } ColumnOption::Default(Expr::Function(func)) => { // Always use lowercase for function expression - ColumnDefaultConstraint::Function(format!("{}", func).to_lowercase()) + ColumnDefaultConstraint::Function(format!("{func}").to_lowercase()) } ColumnOption::Default(expr) => { return UnsupportedDefaultValueSnafu { @@ -391,7 +390,7 @@ mod tests { assert_eq!(Value::Int32(999), v); let v = sql_number_to_value(&ConcreteDataType::string_datatype(), "999"); - assert!(v.is_err(), "parse value error is: {:?}", v); + assert!(v.is_err(), "parse value error is: {v:?}"); } #[test] @@ -417,18 +416,17 @@ mod tests { let sql_val = SqlValue::Number("3.0".to_string(), false); let v = sql_value_to_value("a", &ConcreteDataType::boolean_datatype(), &sql_val); assert!(v.is_err()); - assert!(format!("{:?}", v) + assert!(format!("{v:?}") .contains("Fail to parse number 3.0, invalid column type: Boolean(BooleanType)")); let sql_val = SqlValue::Boolean(true); let v = sql_value_to_value("a", &ConcreteDataType::float64_datatype(), &sql_val); assert!(v.is_err()); assert!( - format!("{:?}", v).contains( + format!("{v:?}").contains( "column_name: \"a\", expect: Float64(Float64Type), actual: Boolean(BooleanType)" ), - "v is {:?}", - v + "v is {v:?}", ); } diff --git a/src/sql/src/statements/insert.rs b/src/sql/src/statements/insert.rs index f105648ea8..fe2ad373e2 100644 --- a/src/sql/src/statements/insert.rs +++ b/src/sql/src/statements/insert.rs @@ -72,20 +72,20 @@ fn sql_exprs_to_values(exprs: &Vec>) -> Result>> { { if let Expr::Value(Value::Number(s, b)) = &**expr { match op { - UnaryOperator::Minus => Value::Number(format!("-{}", s), *b), + UnaryOperator::Minus => Value::Number(format!("-{s}"), *b), UnaryOperator::Plus => Value::Number(s.to_string(), *b), _ => unreachable!(), } } else { return error::ParseSqlValueSnafu { - msg: format!("{:?}", expr), + msg: format!("{expr:?}"), } .fail(); } } _ => { return error::ParseSqlValueSnafu { - msg: format!("{:?}", expr), + msg: format!("{expr:?}"), } .fail() } @@ -103,8 +103,7 @@ impl TryFrom for Insert { match value { Statement::Insert { .. } => Ok(Insert { inner: value }), unexp => Err(ParserError::ParserError(format!( - "Not expected to be {}", - unexp + "Not expected to be {unexp}" ))), } } diff --git a/src/sql/src/statements/show.rs b/src/sql/src/statements/show.rs index 29b6d38baf..a137c3e7b1 100644 --- a/src/sql/src/statements/show.rs +++ b/src/sql/src/statements/show.rs @@ -28,8 +28,8 @@ impl fmt::Display for ShowKind { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match self { ShowKind::All => write!(f, "ALL"), - ShowKind::Like(ident) => write!(f, "LIKE {}", ident), - ShowKind::Where(expr) => write!(f, "WHERE {}", expr), + ShowKind::Like(ident) => write!(f, "LIKE {ident}"), + ShowKind::Where(expr) => write!(f, "WHERE {expr}"), } } } diff --git a/src/storage/benches/memtable/bench_memtable_read_write_ratio.rs b/src/storage/benches/memtable/bench_memtable_read_write_ratio.rs index d9757b8471..ec3f417741 100644 --- a/src/storage/benches/memtable/bench_memtable_read_write_ratio.rs +++ b/src/storage/benches/memtable/bench_memtable_read_write_ratio.rs @@ -126,21 +126,20 @@ fn bench_memtable_read_write_ratio(c: &mut Criterion) { let read_num = READ_NUM.load(Ordering::Relaxed); let read_time = READ_SECS.load(Ordering::Relaxed); let read_tps = if read_time != 0.0 { - read_num as f64 / read_time as f64 + read_num as f64 / read_time } else { 0.0 }; let write_num = WRITE_NUM.load(Ordering::Relaxed); let write_time = WRITE_SECS.load(Ordering::Relaxed); let write_tps = if write_time != 0.0 { - write_num as f64 / write_time as f64 + write_num as f64 / write_time } else { 0.0 }; if read_num != 0 || write_num != 0 { println!( - "\nread numbers: {}, read thrpt: {}\nwrite numbers: {}, write thrpt {}\n", - read_num, read_tps, write_num, write_tps + "\nread numbers: {read_num}, read thrpt: {read_tps}\nwrite numbers: {write_num}, write thrpt {write_tps}\n", ); } } diff --git a/src/storage/src/engine.rs b/src/storage/src/engine.rs index ac1588458e..ca31701342 100644 --- a/src/storage/src/engine.rs +++ b/src/storage/src/engine.rs @@ -95,14 +95,14 @@ impl EngineImpl { /// parent_dir is resolved in function `region_store_config` to ensure it's ended with '/'. #[inline] pub fn region_sst_dir(parent_dir: &str, region_name: &str) -> String { - format!("{}{}/", parent_dir, region_name) + format!("{parent_dir}{region_name}/") } /// Generate region manifest path, /// parent_dir is resolved in function `region_store_config` to ensure it's ended with '/'. #[inline] pub fn region_manifest_dir(parent_dir: &str, region_name: &str) -> String { - format!("{}{}/manifest/", parent_dir, region_name) + format!("{parent_dir}{region_name}/manifest/") } /// A slot for region in the engine. diff --git a/src/storage/src/flush.rs b/src/storage/src/flush.rs index 51c8f00565..bc8fa292af 100644 --- a/src/storage/src/flush.rs +++ b/src/storage/src/flush.rs @@ -263,8 +263,7 @@ mod tests { let regex = Regex::new(r"^[a-f\d]{8}(-[a-f\d]{4}){3}-[a-f\d]{12}.parquet$").unwrap(); assert!( regex.is_match(&file_name), - "illegal sst file name: {}", - file_name + "Illegal sst file name: {file_name}", ); } } diff --git a/src/storage/src/lib.rs b/src/storage/src/lib.rs index 0c41d5b678..8e58817490 100644 --- a/src/storage/src/lib.rs +++ b/src/storage/src/lib.rs @@ -13,7 +13,7 @@ // limitations under the License. //! Storage engine implementation. -#![feature(map_first_last)] + mod background; mod chunk; pub mod codec; diff --git a/src/storage/src/manifest/storage.rs b/src/storage/src/manifest/storage.rs index 744f97a6eb..8e217e95ce 100644 --- a/src/storage/src/manifest/storage.rs +++ b/src/storage/src/manifest/storage.rs @@ -38,12 +38,12 @@ const LAST_CHECKPOINT_FILE: &str = "_last_checkpoint"; #[inline] pub fn delta_file(version: ManifestVersion) -> String { - format!("{:020}.json", version) + format!("{version:020}.json") } #[inline] pub fn checkpoint_file(version: ManifestVersion) -> String { - format!("{:020}.checkpoint", version) + format!("{version:020}.checkpoint") } /// Return's the delta file version from path @@ -54,7 +54,7 @@ pub fn checkpoint_file(version: ManifestVersion) -> String { pub fn delta_version(path: &str) -> ManifestVersion { let s = path.split('.').next().unwrap(); s.parse() - .unwrap_or_else(|_| panic!("Invalid delta file: {}", path)) + .unwrap_or_else(|_| panic!("Invalid delta file: {path}")) } #[inline] @@ -298,7 +298,7 @@ mod tests { for v in 0..5 { log_store - .save(v, format!("hello, {}", v).as_bytes()) + .save(v, format!("hello, {v}").as_bytes()) .await .unwrap(); } @@ -307,7 +307,7 @@ mod tests { for v in 1..4 { let (version, bytes) = it.next_log().await.unwrap().unwrap(); assert_eq!(v, version); - assert_eq!(format!("hello, {}", v).as_bytes(), bytes); + assert_eq!(format!("hello, {v}").as_bytes(), bytes); } assert!(it.next_log().await.unwrap().is_none()); @@ -315,7 +315,7 @@ mod tests { for v in 0..5 { let (version, bytes) = it.next_log().await.unwrap().unwrap(); assert_eq!(v, version); - assert_eq!(format!("hello, {}", v).as_bytes(), bytes); + assert_eq!(format!("hello, {v}").as_bytes(), bytes); } assert!(it.next_log().await.unwrap().is_none()); @@ -327,7 +327,7 @@ mod tests { for v in 3..5 { let (version, bytes) = it.next_log().await.unwrap().unwrap(); assert_eq!(v, version); - assert_eq!(format!("hello, {}", v).as_bytes(), bytes); + assert_eq!(format!("hello, {v}").as_bytes(), bytes); } assert!(it.next_log().await.unwrap().is_none()); diff --git a/src/storage/src/metadata.rs b/src/storage/src/metadata.rs index 02fc437509..af31388a22 100644 --- a/src/storage/src/metadata.rs +++ b/src/storage/src/metadata.rs @@ -450,7 +450,7 @@ where { if let Some(value) = metadata.get(key) { return value.parse().with_context(|_| ParseMetaIntSnafu { - key_value: format!("{}={}", key, value), + key_value: format!("{key}={value}"), }); } // No such key in metadata. diff --git a/src/storage/src/read/merge.rs b/src/storage/src/read/merge.rs index b4f76b1f41..ab973e9fbc 100644 --- a/src/storage/src/read/merge.rs +++ b/src/storage/src/read/merge.rs @@ -644,10 +644,10 @@ mod tests { assert_eq!(left, right); // Check Debug is implemented. - let output = format!("{:?}", left); + let output = format!("{left:?}"); assert!(output.contains("cursor")); assert!(output.contains("pos: 1")); - let output = format!("{:?}", right); + let output = format!("{right:?}"); assert!(output.contains("cursor")); let output = format!("{:?}", left.first_row()); assert!(output.contains("pos: 1")); diff --git a/src/storage/src/schema/compat.rs b/src/storage/src/schema/compat.rs index d8d5f9a08a..ae3f6e4ce1 100644 --- a/src/storage/src/schema/compat.rs +++ b/src/storage/src/schema/compat.rs @@ -567,8 +567,7 @@ mod tests { let err = is_source_column_compatible(&source, &dest).unwrap_err(); assert!( matches!(err, Error::CompatRead { .. }), - "{:?} is not CompatRead", - err + "{err:?} is not CompatRead", ); } @@ -606,8 +605,7 @@ mod tests { let err = is_source_column_compatible(&source, &dest).unwrap_err(); assert!( matches!(err, Error::CompatRead { .. }), - "{:?} is not CompatRead", - err + "{err:?} is not CompatRead", ); } } diff --git a/src/storage/src/schema/store.rs b/src/storage/src/schema/store.rs index 691320e8bd..e20a5c1770 100644 --- a/src/storage/src/schema/store.rs +++ b/src/storage/src/schema/store.rs @@ -236,7 +236,7 @@ fn parse_index_from_metadata(metadata: &HashMap, key: &str) -> R .get(key) .context(metadata::MetaNotFoundSnafu { key })?; value.parse().with_context(|_| metadata::ParseMetaIntSnafu { - key_value: format!("{}={}", key, value), + key_value: format!("{key}={value}"), }) } diff --git a/src/storage/src/test_util/config_util.rs b/src/storage/src/test_util/config_util.rs index 451c478188..41d994a5b8 100644 --- a/src/storage/src/test_util/config_util.rs +++ b/src/storage/src/test_util/config_util.rs @@ -28,7 +28,7 @@ use crate::region::StoreConfig; use crate::sst::FsAccessLayer; fn log_store_dir(store_dir: &str) -> String { - format!("{}/logstore", store_dir) + format!("{store_dir}/logstore") } /// Create a new StoreConfig for test. diff --git a/src/storage/src/test_util/descriptor_util.rs b/src/storage/src/test_util/descriptor_util.rs index 10d682745b..21e5a966f7 100644 --- a/src/storage/src/test_util/descriptor_util.rs +++ b/src/storage/src/test_util/descriptor_util.rs @@ -129,7 +129,7 @@ pub fn desc_with_value_columns(region_name: &str, num_value_columns: usize) -> R let mut builder = RegionDescBuilder::new(region_name).push_key_column(("k0", LogicalTypeId::Int64, false)); for i in 0..num_value_columns { - let name = format!("v{}", i); + let name = format!("v{i}"); builder = builder.push_value_column((&name, LogicalTypeId::Int64, true)); } builder.build() diff --git a/src/storage/src/write_batch.rs b/src/storage/src/write_batch.rs index 25c51fef9b..eaaeef6fe7 100644 --- a/src/storage/src/write_batch.rs +++ b/src/storage/src/write_batch.rs @@ -215,7 +215,7 @@ impl WriteRequest for WriteBatch { Mutation::Put(put_data) => { let column = put_data .column_by_name(ts_col_name) - .unwrap_or_else(|| panic!("Cannot find column by name: {}", ts_col_name)); + .unwrap_or_else(|| panic!("Cannot find column by name: {ts_col_name}")); if column.is_const() { let ts = match column.get(0) { Value::Timestamp(ts) => ts, diff --git a/src/storage/src/write_batch/codec.rs b/src/storage/src/write_batch/codec.rs index 56bc387bb2..15dad0ada2 100644 --- a/src/storage/src/write_batch/codec.rs +++ b/src/storage/src/write_batch/codec.rs @@ -149,7 +149,7 @@ impl Decoder for WriteBatchArrowDecoder { } _ => { return DataCorruptedSnafu { - message: format!("Unexpceted mutation type: {}", mutation_type), + message: format!("Unexpected mutation type: {mutation_type}"), } .fail() } diff --git a/src/storage/src/write_batch/compat.rs b/src/storage/src/write_batch/compat.rs index ce45ffc1db..b7d6758bb7 100644 --- a/src/storage/src/write_batch/compat.rs +++ b/src/storage/src/write_batch/compat.rs @@ -188,8 +188,7 @@ mod tests { let err = batch.compat_write(&schema_old).unwrap_err(); assert!( matches!(err, Error::WriteToOldVersion { .. }), - "err {} is not WriteToOldVersion", - err + "err {err} is not WriteToOldVersion", ); } @@ -209,8 +208,7 @@ mod tests { let err = batch.compat_write(&schema_no_column).unwrap_err(); assert!( matches!(err, Error::NotInSchemaToCompat { .. }), - "err {} is not NotInSchemaToCompat", - err + "err {err} is not NotInSchemaToCompat", ); } } diff --git a/src/table/src/engine.rs b/src/table/src/engine.rs index 55f68c31cf..23e2e4e7ba 100644 --- a/src/table/src/engine.rs +++ b/src/table/src/engine.rs @@ -86,14 +86,14 @@ pub trait TableEngine: Send + Sync { ) -> Result; /// Returns the table by it's name. - fn get_table<'a>( + fn get_table( &self, ctx: &EngineContext, - table_ref: &'a TableReference, + table_ref: &TableReference, ) -> Result>; /// Returns true when the given table is exists. - fn table_exists<'a>(&self, ctx: &EngineContext, table_ref: &'a TableReference) -> bool; + fn table_exists(&self, ctx: &EngineContext, table_ref: &TableReference) -> bool; /// Drops the given table. Return true if the table is dropped, or false if the table doesn't exist. async fn drop_table(&self, ctx: &EngineContext, request: DropTableRequest) -> Result; diff --git a/src/table/src/metadata.rs b/src/table/src/metadata.rs index e481acbc7e..3ae85784dc 100644 --- a/src/table/src/metadata.rs +++ b/src/table/src/metadata.rs @@ -211,10 +211,7 @@ impl TableMeta { let mut builder = SchemaBuilder::try_from(columns) .with_context(|_| error::SchemaBuildSnafu { - msg: format!( - "Failed to convert column schemas into schema for table {}", - table_name - ), + msg: format!("Failed to convert column schemas into schema for table {table_name}"), })? // Also bump the schema version. .version(table_schema.version() + 1); @@ -222,10 +219,7 @@ impl TableMeta { builder = builder.add_metadata(k, v); } let new_schema = builder.build().with_context(|_| error::SchemaBuildSnafu { - msg: format!( - "Table {} cannot add new columns {:?}", - table_name, column_names - ), + msg: format!("Table {table_name} cannot add new columns {column_names:?}"), })?; // value_indices would be generated automatically. @@ -288,10 +282,7 @@ impl TableMeta { let mut builder = SchemaBuilder::try_from_columns(columns) .with_context(|_| error::SchemaBuildSnafu { - msg: format!( - "Failed to convert column schemas into schema for table {}", - table_name - ), + msg: format!("Failed to convert column schemas into schema for table {table_name}"), })? // Also bump the schema version. .version(table_schema.version() + 1); @@ -299,10 +290,7 @@ impl TableMeta { builder = builder.add_metadata(k, v); } let new_schema = builder.build().with_context(|_| error::SchemaBuildSnafu { - msg: format!( - "Table {} cannot add remove columns {:?}", - table_name, column_names - ), + msg: format!("Table {table_name} cannot add remove columns {column_names:?}"), })?; // Rebuild the indices of primary key columns. diff --git a/src/table/src/table/numbers.rs b/src/table/src/table/numbers.rs index 473d80dd0a..455199023a 100644 --- a/src/table/src/table/numbers.rs +++ b/src/table/src/table/numbers.rs @@ -136,7 +136,7 @@ impl Stream for NumbersStream { let numbers: Vec = (0..self.limit).collect(); let batch = DfRecordBatch::try_new( self.schema.arrow_schema().clone(), - vec![Arc::new(UInt32Array::from_slice(&numbers))], + vec![Arc::new(UInt32Array::from_slice(numbers))], ) .unwrap(); diff --git a/src/table/src/test_util/mock_engine.rs b/src/table/src/test_util/mock_engine.rs index 2b19b1889a..916b460605 100644 --- a/src/table/src/test_util/mock_engine.rs +++ b/src/table/src/test_util/mock_engine.rs @@ -85,15 +85,11 @@ impl TableEngine for MockTableEngine { unimplemented!() } - fn get_table<'a>( - &self, - _ctx: &EngineContext, - _ref: &'a TableReference, - ) -> Result> { + fn get_table(&self, _ctx: &EngineContext, _ref: &TableReference) -> Result> { unimplemented!() } - fn table_exists<'a>(&self, _ctx: &EngineContext, _name: &'a TableReference) -> bool { + fn table_exists(&self, _ctx: &EngineContext, _name: &TableReference) -> bool { unimplemented!() } diff --git a/tests-integration/src/test_util.rs b/tests-integration/src/test_util.rs index 6c77b28d52..67feb62269 100644 --- a/tests-integration/src/test_util.rs +++ b/tests-integration/src/test_util.rs @@ -106,7 +106,7 @@ fn get_test_store_config( (config, Some(TempDirGuard::S3(TempFolder::new(&store, "/")))) } StorageType::File => { - let data_tmp_dir = TempDir::new(&format!("gt_data_{}", name)).unwrap(); + let data_tmp_dir = TempDir::new(&format!("gt_data_{name}")).unwrap(); ( ObjectStoreConfig::File { @@ -142,7 +142,7 @@ pub fn create_tmp_dir_and_datanode_opts( store_type: StorageType, name: &str, ) -> (DatanodeOptions, TestGuard) { - let wal_tmp_dir = TempDir::new(&format!("gt_wal_{}", name)).unwrap(); + let wal_tmp_dir = TempDir::new(&format!("gt_wal_{name}")).unwrap(); let (storage, data_tmp_dir) = get_test_store_config(&store_type, name); diff --git a/tests/runner/src/env.rs b/tests/runner/src/env.rs index 0d1bd56cf9..c70dfa3506 100644 --- a/tests/runner/src/env.rs +++ b/tests/runner/src/env.rs @@ -41,7 +41,7 @@ impl Environment for Env { match mode { "standalone" => Self::start_standalone().await, "distributed" => Self::start_distributed().await, - _ => panic!("Unexpected mode: {}", mode), + _ => panic!("Unexpected mode: {mode}"), } } @@ -75,7 +75,7 @@ impl Env { .write(true) .truncate(true) .open(SERVER_LOG_FILE) - .unwrap_or_else(|_| panic!("Cannot open log file at {}", SERVER_LOG_FILE)); + .unwrap_or_else(|_| panic!("Cannot open log file at {SERVER_LOG_FILE}")); // Start the DB let server_process = Command::new("./greptime") .current_dir(util::get_binary_dir("debug")) @@ -88,10 +88,7 @@ impl Env { if !is_up { panic!("Server doesn't up in 10 seconds, quit.") } - println!( - "Started, going to test. Log will be write to {}", - SERVER_LOG_FILE - ); + println!("Started, going to test. Log will be write to {SERVER_LOG_FILE}"); let client = Client::with_urls(vec![SERVER_ADDR]); let db = DB::new("greptime", client.clone()); @@ -143,10 +140,10 @@ impl Display for ResultDisplayer { ) } ObjectResult::Mutate(mutate_result) => { - write!(f, "{:?}", mutate_result) + write!(f, "{mutate_result:?}") } }, - Err(e) => write!(f, "Failed to execute, error: {:?}", e), + Err(e) => write!(f, "Failed to execute, error: {e:?}"), } } } diff --git a/tests/runner/src/util.rs b/tests/runner/src/util.rs index f417f19968..652e1257bb 100644 --- a/tests/runner/src/util.rs +++ b/tests/runner/src/util.rs @@ -124,7 +124,7 @@ pub fn values_to_string( values .binary_values .into_iter() - .map(|val| format!("{:?}", val)), + .map(|val| format!("{val:?}")), row_count ), ColumnDataType::Datetime => {