Skip to content

Commit

Permalink
feat: update proto and remove create_if_not_exists
Browse files Browse the repository at this point in the history
  • Loading branch information
evenyag committed Sep 21, 2023
1 parent 6306aea commit 7e73530
Show file tree
Hide file tree
Showing 10 changed files with 5 additions and 38 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 0 additions & 1 deletion src/common/meta/src/ddl/create_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
})
Expand Down
15 changes: 3 additions & 12 deletions src/file-engine/src/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand Down Expand Up @@ -168,23 +167,15 @@ 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);

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;
Expand Down
7 changes: 0 additions & 7 deletions src/file-engine/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -191,7 +185,6 @@ impl ErrorExt for Error {
| CreateDefault { .. }
| MissingColumnNoDefault { .. } => StatusCode::InvalidArguments,

RegionExists { .. } => StatusCode::RegionAlreadyExists,
RegionNotFound { .. } => StatusCode::RegionNotFound,

BuildBackend { source, .. } => source.status_code(),
Expand Down
3 changes: 0 additions & 3 deletions src/file-engine/src/region.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
};
Expand Down Expand Up @@ -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(),
};
Expand Down Expand Up @@ -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(),
};
Expand Down
1 change: 0 additions & 1 deletion src/meta-srv/src/procedure/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
};
Expand Down
7 changes: 0 additions & 7 deletions src/mito2/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -405,7 +399,6 @@ impl ErrorExt for Error {
| CreateDefault { .. }
| InvalidParquet { .. } => StatusCode::Unexpected,
RegionNotFound { .. } => StatusCode::RegionNotFound,
RegionExists { .. } => StatusCode::RegionAlreadyExists,
InvalidScanIndex { .. }
| InvalidMeta { .. }
| InvalidRequest { .. }
Expand Down
1 change: 0 additions & 1 deletion src/mito2/src/test_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
}
}
Expand Down
4 changes: 0 additions & 4 deletions src/store-api/src/region_request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}),
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 7e73530

Please sign in to comment.