Skip to content

Commit

Permalink
chore: remove unnecessary option
Browse files Browse the repository at this point in the history
  • Loading branch information
v3g42 committed Oct 5, 2023
1 parent 209d5b6 commit 312009f
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 48 deletions.
2 changes: 1 addition & 1 deletion dozer-cli/src/cli/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ pub fn generate_connection(connection_name: &str) -> Connection {
bucket_name: "<your_bucket_name>".to_owned(),
};
let s3_config = S3Storage {
details: Some(s3_details),
details: s3_details,
tables: vec![],
};
let connection: Connection = Connection {
Expand Down
14 changes: 3 additions & 11 deletions dozer-ingestion/src/connectors/object_store/adapters.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::errors::ObjectStoreObjectError::{MissingStorageDetails, TableDefinitionNotFound};
use crate::errors::ObjectStoreObjectError::TableDefinitionNotFound;
use crate::errors::{ConnectorError, ObjectStoreConnectorError};
use dozer_types::ingestion_types::{LocalStorage, S3Storage, Table};
use object_store::aws::{AmazonS3, AmazonS3Builder};
Expand Down Expand Up @@ -54,7 +54,7 @@ impl DozerObjectStore for S3Storage {
&self,
table: &Table,
) -> Result<DozerObjectStoreParams<Self::ObjectStore>, ConnectorError> {
let details = get_details(&self.details)?;
let details = &self.details;

let retry_config = RetryConfig {
backoff: BackoffConfig::default(),
Expand Down Expand Up @@ -116,7 +116,7 @@ impl DozerObjectStore for LocalStorage {
&self,
table: &Table,
) -> Result<DozerObjectStoreParams<Self::ObjectStore>, ConnectorError> {
let path = get_details(&self.details)?.path.as_str();
let path = &self.details.path.as_str();

let object_store = LocalFileSystem::new_with_prefix(path)
.map_err(|e| ConnectorError::InitializationError(e.to_string()))?;
Expand Down Expand Up @@ -158,11 +158,3 @@ impl DozerObjectStore for LocalStorage {
&self.tables
}
}

fn get_details<T>(details: &Option<T>) -> Result<&T, ObjectStoreConnectorError> {
details
.as_ref()
.ok_or(ObjectStoreConnectorError::DataFusionStorageObjectError(
MissingStorageDetails,
))
}
6 changes: 2 additions & 4 deletions dozer-types/src/ingestion_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -335,16 +335,14 @@ pub struct LocalDetails {

#[derive(Debug, Serialize, Deserialize, Eq, PartialEq, Clone, Hash, JsonSchema)]
pub struct LocalStorage {
pub details: Option<LocalDetails>,
pub details: LocalDetails,

pub tables: Vec<Table>,
}

impl LocalStorage {
pub fn convert_to_table(&self) -> PrettyTable {
self.details
.as_ref()
.map_or_else(|| table!(), |details| table!(["path", details.path]))
table!(["path", self.details.path])
}
}

Expand Down
20 changes: 4 additions & 16 deletions json_schemas/connections.json
Original file line number Diff line number Diff line change
Expand Up @@ -387,18 +387,12 @@
"title": "S3Storage",
"type": "object",
"required": [
"details",
"tables"
],
"properties": {
"details": {
"anyOf": [
{
"$ref": "#/definitions/S3Details"
},
{
"type": "null"
}
]
"$ref": "#/definitions/S3Details"
},
"tables": {
"type": "array",
Expand Down Expand Up @@ -555,18 +549,12 @@
"title": "LocalStorage",
"type": "object",
"required": [
"details",
"tables"
],
"properties": {
"details": {
"anyOf": [
{
"$ref": "#/definitions/LocalDetails"
},
{
"type": "null"
}
]
"$ref": "#/definitions/LocalDetails"
},
"tables": {
"type": "array",
Expand Down
20 changes: 4 additions & 16 deletions json_schemas/dozer.json
Original file line number Diff line number Diff line change
Expand Up @@ -1051,18 +1051,12 @@
"LocalStorage": {
"type": "object",
"required": [
"details",
"tables"
],
"properties": {
"details": {
"anyOf": [
{
"$ref": "#/definitions/LocalDetails"
},
{
"type": "null"
}
]
"$ref": "#/definitions/LocalDetails"
},
"tables": {
"type": "array",
Expand Down Expand Up @@ -1406,18 +1400,12 @@
"S3Storage": {
"type": "object",
"required": [
"details",
"tables"
],
"properties": {
"details": {
"anyOf": [
{
"$ref": "#/definitions/S3Details"
},
{
"type": "null"
}
]
"$ref": "#/definitions/S3Details"
},
"tables": {
"type": "array",
Expand Down

0 comments on commit 312009f

Please sign in to comment.