mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-05-23 16:30:39 +00:00
feat: update proto and remove create_if_not_exists (#2467)
This commit is contained in:
2
Cargo.lock
generated
2
Cargo.lock
generated
@@ -4186,7 +4186,7 @@ checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b"
|
||||
[[package]]
|
||||
name = "greptime-proto"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/GreptimeTeam/greptime-proto.git?rev=9d3f28d07d29607d0e3c1823f4a4d2bc229d05b9#9d3f28d07d29607d0e3c1823f4a4d2bc229d05b9"
|
||||
source = "git+https://github.com/GreptimeTeam/greptime-proto.git?rev=115c1080773be8a819e50b257fece9f839a0c836#115c1080773be8a819e50b257fece9f839a0c836"
|
||||
dependencies = [
|
||||
"prost",
|
||||
"serde",
|
||||
|
||||
@@ -78,7 +78,7 @@ datafusion-substrait = { git = "https://github.com/waynexia/arrow-datafusion.git
|
||||
derive_builder = "0.12"
|
||||
futures = "0.3"
|
||||
futures-util = "0.3"
|
||||
greptime-proto = { git = "https://github.com/GreptimeTeam/greptime-proto.git", rev = "9d3f28d07d29607d0e3c1823f4a4d2bc229d05b9" }
|
||||
greptime-proto = { git = "https://github.com/GreptimeTeam/greptime-proto.git", rev = "115c1080773be8a819e50b257fece9f839a0c836" }
|
||||
humantime-serde = "1.1"
|
||||
itertools = "0.10"
|
||||
lazy_static = "1.4"
|
||||
|
||||
@@ -161,7 +161,6 @@ impl CreateTableProcedure {
|
||||
engine: create_table_expr.engine.to_string(),
|
||||
column_defs,
|
||||
primary_key,
|
||||
create_if_not_exists: true,
|
||||
path: String::new(),
|
||||
options: create_table_expr.table_options.clone(),
|
||||
})
|
||||
|
||||
@@ -33,8 +33,7 @@ use tokio::sync::{Mutex, RwLock};
|
||||
|
||||
use crate::config::EngineConfig;
|
||||
use crate::error::{
|
||||
RegionExistsSnafu, RegionNotFoundSnafu, Result as EngineResult, UnexpectedEngineSnafu,
|
||||
UnsupportedSnafu,
|
||||
RegionNotFoundSnafu, Result as EngineResult, UnexpectedEngineSnafu, UnsupportedSnafu,
|
||||
};
|
||||
use crate::region::{FileRegion, FileRegionRef};
|
||||
|
||||
@@ -168,11 +167,7 @@ impl EngineInner {
|
||||
);
|
||||
|
||||
if self.exists(region_id).await {
|
||||
return if request.create_if_not_exists {
|
||||
Ok(Output::AffectedRows(0))
|
||||
} else {
|
||||
RegionExistsSnafu { region_id }.fail()
|
||||
};
|
||||
return Ok(Output::AffectedRows(0));
|
||||
}
|
||||
|
||||
info!("Try to create region, region_id: {}", region_id);
|
||||
@@ -180,11 +175,7 @@ impl EngineInner {
|
||||
let _lock = self.region_mutex.lock().await;
|
||||
// Check again after acquiring the lock
|
||||
if self.exists(region_id).await {
|
||||
return if request.create_if_not_exists {
|
||||
Ok(Output::AffectedRows(0))
|
||||
} else {
|
||||
RegionExistsSnafu { region_id }.fail()
|
||||
};
|
||||
return Ok(Output::AffectedRows(0));
|
||||
}
|
||||
|
||||
let res = FileRegion::create(region_id, request, &self.object_store).await;
|
||||
|
||||
@@ -40,12 +40,6 @@ pub enum Error {
|
||||
location: Location,
|
||||
},
|
||||
|
||||
#[snafu(display("Region {} already exists", region_id))]
|
||||
RegionExists {
|
||||
region_id: RegionId,
|
||||
location: Location,
|
||||
},
|
||||
|
||||
#[snafu(display("Region not found, region_id: {}", region_id))]
|
||||
RegionNotFound {
|
||||
region_id: RegionId,
|
||||
@@ -191,7 +185,6 @@ impl ErrorExt for Error {
|
||||
| CreateDefault { .. }
|
||||
| MissingColumnNoDefault { .. } => StatusCode::InvalidArguments,
|
||||
|
||||
RegionExists { .. } => StatusCode::RegionAlreadyExists,
|
||||
RegionNotFound { .. } => StatusCode::RegionNotFound,
|
||||
|
||||
BuildBackend { source, .. } => source.status_code(),
|
||||
|
||||
@@ -112,7 +112,6 @@ mod tests {
|
||||
engine: "file".to_string(),
|
||||
column_metadatas: new_test_column_metadata(),
|
||||
primary_key: vec![1],
|
||||
create_if_not_exists: true,
|
||||
options: new_test_options(),
|
||||
region_dir: "create_region_dir/".to_string(),
|
||||
};
|
||||
@@ -151,7 +150,6 @@ mod tests {
|
||||
engine: "file".to_string(),
|
||||
column_metadatas: new_test_column_metadata(),
|
||||
primary_key: vec![1],
|
||||
create_if_not_exists: true,
|
||||
options: new_test_options(),
|
||||
region_dir: region_dir.clone(),
|
||||
};
|
||||
@@ -189,7 +187,6 @@ mod tests {
|
||||
engine: "file".to_string(),
|
||||
column_metadatas: new_test_column_metadata(),
|
||||
primary_key: vec![1],
|
||||
create_if_not_exists: true,
|
||||
options: new_test_options(),
|
||||
region_dir: region_dir.clone(),
|
||||
};
|
||||
|
||||
@@ -151,7 +151,6 @@ fn test_create_region_request_template() {
|
||||
},
|
||||
],
|
||||
primary_key: vec![2, 1],
|
||||
create_if_not_exists: true,
|
||||
path: String::new(),
|
||||
options: HashMap::new(),
|
||||
};
|
||||
|
||||
@@ -98,12 +98,6 @@ pub enum Error {
|
||||
location: Location,
|
||||
},
|
||||
|
||||
#[snafu(display("Region {} already exists", region_id))]
|
||||
RegionExists {
|
||||
region_id: RegionId,
|
||||
location: Location,
|
||||
},
|
||||
|
||||
#[snafu(display("Failed to create RecordBatch from vectors"))]
|
||||
NewRecordBatch {
|
||||
location: Location,
|
||||
@@ -405,7 +399,6 @@ impl ErrorExt for Error {
|
||||
| CreateDefault { .. }
|
||||
| InvalidParquet { .. } => StatusCode::Unexpected,
|
||||
RegionNotFound { .. } => StatusCode::RegionNotFound,
|
||||
RegionExists { .. } => StatusCode::RegionAlreadyExists,
|
||||
InvalidScanIndex { .. }
|
||||
| InvalidMeta { .. }
|
||||
| InvalidRequest { .. }
|
||||
|
||||
@@ -304,7 +304,6 @@ impl CreateRequestBuilder {
|
||||
column_metadatas,
|
||||
primary_key: self.primary_key.clone().unwrap_or(primary_key),
|
||||
options: self.options.clone(),
|
||||
create_if_not_exists: false,
|
||||
region_dir: self.region_dir.clone(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,7 +79,6 @@ impl RegionRequest {
|
||||
engine: create.engine,
|
||||
column_metadatas,
|
||||
primary_key: create.primary_key,
|
||||
create_if_not_exists: create.create_if_not_exists,
|
||||
options: create.options,
|
||||
region_dir,
|
||||
}),
|
||||
@@ -150,9 +149,6 @@ pub struct RegionCreateRequest {
|
||||
pub column_metadatas: Vec<ColumnMetadata>,
|
||||
/// Columns in the primary key.
|
||||
pub primary_key: Vec<ColumnId>,
|
||||
/// Create region if not exists.
|
||||
// TODO(yingwen): Remove this.
|
||||
pub create_if_not_exists: bool,
|
||||
/// Options of the created region.
|
||||
pub options: HashMap<String, String>,
|
||||
/// Directory for region's data home. Usually is composed by catalog and table id
|
||||
|
||||
Reference in New Issue
Block a user