From ed8252157a2519b0155048e29d3432eb9478667d Mon Sep 17 00:00:00 2001 From: Weny Xu Date: Wed, 8 Mar 2023 16:10:12 +0800 Subject: [PATCH] chore: code styling (#1137) Co-authored-by: Ruihang Xia --- Cargo.lock | 1 - src/datanode/Cargo.toml | 5 ++--- src/datanode/src/sql/copy_table_from.rs | 26 ++++++++++--------------- 3 files changed, 12 insertions(+), 20 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index cde0a5087c..4e75da5c0e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2272,7 +2272,6 @@ dependencies = [ "futures-util", "humantime-serde", "hyper", - "lazy_static", "log-store", "meta-client", "meta-srv", diff --git a/src/datanode/Cargo.toml b/src/datanode/Cargo.toml index af2d26cffb..eae2a9cd69 100644 --- a/src/datanode/Cargo.toml +++ b/src/datanode/Cargo.toml @@ -9,6 +9,7 @@ default = ["python"] python = ["dep:script"] [dependencies] +async-compat = "0.2" async-stream.workspace = true async-trait.workspace = true api = { path = "../api" } @@ -44,6 +45,7 @@ object-store = { path = "../object-store" } pin-project = "1.0" prost.workspace = true query = { path = "../query" } +regex = "1.6" script = { path = "../script", features = ["python"], optional = true } serde = "1.0" serde_json = "1.0" @@ -61,9 +63,6 @@ tokio-stream = { version = "0.1", features = ["net"] } tonic.workspace = true tower = { version = "0.4", features = ["full"] } tower-http = { version = "0.3", features = ["full"] } -regex = "1.6" -lazy_static = "1.4" -async-compat = "0.2" url = "2.3.1" [dev-dependencies] diff --git a/src/datanode/src/sql/copy_table_from.rs b/src/datanode/src/sql/copy_table_from.rs index fb938c7d11..bedb36cf8e 100644 --- a/src/datanode/src/sql/copy_table_from.rs +++ b/src/datanode/src/sql/copy_table_from.rs @@ -22,7 +22,6 @@ use datatypes::arrow::record_batch::RecordBatch; use datatypes::vectors::{Helper, VectorRef}; use futures::future; use futures_util::TryStreamExt; -use lazy_static::lazy_static; use object_store::services::{Fs, S3}; use object_store::{Object, ObjectStore, ObjectStoreBuilder}; use regex::Regex; @@ -35,10 +34,6 @@ use url::{ParseError, Url}; use crate::error::{self, Result}; use crate::sql::SqlHandler; -lazy_static! { - static ref SCHEMA_PATTERN: Regex = Regex::new(r"^\w*://").unwrap(); -} - const S3_SCHEMA: &str = "S3"; const ENDPOINT_URL: &str = "ENDPOINT_URL"; const ACCESS_KEY_ID: &str = "ACCESS_KEY_ID"; @@ -223,18 +218,17 @@ impl DataSource { } if let Some(enable_str) = connection.get(ENABLE_VIRTUAL_HOST_STYLE) { - let enable = enable_str.as_str().parse::(); - - match enable { - Ok(true) => { - builder.enable_virtual_host_style(); + let enable = enable_str.as_str().parse::().map_err(|e| { + error::InvalidConnectionSnafu { + msg: format!( + "failed to parse the option {}={}, {}", + ENABLE_VIRTUAL_HOST_STYLE, enable_str, e + ), } - Err(_) => { - return Err(error::Error::InvalidConnection { - msg: format!("failed to parse the {}", ENABLE_VIRTUAL_HOST_STYLE), - }) - } - _ => (), + .build() + })?; + if enable { + builder.enable_virtual_host_style(); } }