-
Notifications
You must be signed in to change notification settings - Fork 761
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: Use CrudMgr to impl FileFormatMgr (#14999)
- Fix: #14934
- Loading branch information
1 parent
33090ea
commit 59d8fd6
Showing
12 changed files
with
118 additions
and
233 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
83 changes: 83 additions & 0 deletions
83
src/meta/app/src/principal/user_defined_file_format_ident.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
// Copyright 2021 Datafuse Labs | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
use crate::tenant_key::TIdent; | ||
|
||
/// Defines the meta-service key for user defined file format. | ||
pub type UserDefinedFileFormatIdent = TIdent<Resource>; | ||
|
||
pub use kvapi_impl::Resource; | ||
|
||
mod kvapi_impl { | ||
|
||
use databend_common_exception::ErrorCode; | ||
use databend_common_meta_kvapi::kvapi; | ||
|
||
use crate::principal::UserDefinedFileFormat; | ||
use crate::tenant_key::TenantResource; | ||
use crate::tenant_key_errors::ExistError; | ||
use crate::tenant_key_errors::UnknownError; | ||
|
||
pub struct Resource; | ||
impl TenantResource for Resource { | ||
const PREFIX: &'static str = "__fd_file_formats"; | ||
type ValueType = UserDefinedFileFormat; | ||
} | ||
|
||
impl kvapi::Value for UserDefinedFileFormat { | ||
fn dependency_keys(&self) -> impl IntoIterator<Item = String> { | ||
[] | ||
} | ||
} | ||
|
||
impl kvapi::ValueWithName for UserDefinedFileFormat { | ||
fn name(&self) -> &str { | ||
&self.name | ||
} | ||
} | ||
|
||
impl From<ExistError<Resource>> for ErrorCode { | ||
fn from(err: ExistError<Resource>) -> Self { | ||
ErrorCode::FileFormatAlreadyExists(err.to_string()) | ||
} | ||
} | ||
|
||
impl From<UnknownError<Resource>> for ErrorCode { | ||
fn from(err: UnknownError<Resource>) -> Self { | ||
ErrorCode::UnknownFileFormat(err.to_string()) | ||
} | ||
} | ||
} | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
use databend_common_meta_kvapi::kvapi::Key; | ||
|
||
use crate::principal::user_defined_file_format_ident::UserDefinedFileFormatIdent; | ||
use crate::tenant::Tenant; | ||
|
||
#[test] | ||
fn test_file_format_ident() { | ||
let tenant = Tenant::new("test".to_string()); | ||
let ident = UserDefinedFileFormatIdent::new(tenant, "test1"); | ||
|
||
let key = ident.to_string_key(); | ||
assert_eq!(key, "__fd_file_formats/test/test1"); | ||
|
||
assert_eq!( | ||
ident, | ||
UserDefinedFileFormatIdent::from_str_key(&key).unwrap() | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
158 changes: 0 additions & 158 deletions
158
src/query/management/src/file_format/file_format_mgr.rs
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.