Skip to content

Commit

Permalink
Update src/cmd/src/cli/import.rs
Browse files Browse the repository at this point in the history
Co-authored-by: Weny Xu <[email protected]>
  • Loading branch information
fengjiachun and WenyXu committed Sep 3, 2024
1 parent 724661e commit c74bb0a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
1 change: 1 addition & 0 deletions src/cmd/src/cli/export.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ impl Export {
return Ok(db_names);
};

// Check if the schema exists
db_names
.into_iter()
.find(|db_name| db_name.to_lowercase() == schema.to_lowercase())
Expand Down
23 changes: 10 additions & 13 deletions src/cmd/src/cli/import.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use async_trait::async_trait;
use clap::{Parser, ValueEnum};
use common_catalog::consts::DEFAULT_SCHEMA_NAME;
use common_telemetry::{error, info, warn};
use snafu::ResultExt;
use snafu::{OptionExt, ResultExt};
use tokio::sync::Semaphore;
use tokio::time::Instant;
use tracing_appender::non_blocking::WorkerGuard;
Expand Down Expand Up @@ -165,18 +165,15 @@ impl Import {
return Ok(db_names);
};

for db_name in db_names {
// Check if the schema exists
if db_name.to_lowercase() == schema.to_lowercase() {
return Ok(vec![db_name]);
}
}

SchemaNotFoundSnafu {
catalog: &self.catalog,
schema,
}
.fail()
// Check if the schema exists
db_names
.into_iter()
.find(|db_name| db_name.to_lowercase() == schema.to_lowercase())
.map(|name| vec![name])
.context(SchemaNotFoundSnafu {
catalog: &self.catalog,
schema,
})
}

// Get all database names in the input directory.
Expand Down

0 comments on commit c74bb0a

Please sign in to comment.