Skip to content

Commit

Permalink
chore: fix cr issue
Browse files Browse the repository at this point in the history
  • Loading branch information
shuiyisong committed Nov 6, 2023
1 parent 4765673 commit 49d54be
Showing 1 changed file with 18 additions and 21 deletions.
39 changes: 18 additions & 21 deletions src/cmd/src/cli/export.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.

use std::fmt::Write;
use std::path::Path;
use std::sync::Arc;

Expand Down Expand Up @@ -349,28 +348,26 @@ impl Export {
Path::new(&self.output_dir).join(format!("{catalog}-{schema}_copy_from.sql"));
let mut file = File::create(copy_from_file).await.context(FileIoSnafu)?;

let copy_from_sql =
dir_filenames
.into_iter()
.fold(String::new(), |mut acc, file| {
let file = file.unwrap();
let table_name = file
.file_name()
.into_string()
.unwrap()
.replace(".parquet", "");
let _ = writeln!(
acc,
"copy {} from '{}' with (format='parquet');",
table_name,
file.path().to_str().unwrap()
);
acc
});

file.write_all(copy_from_sql.as_bytes())
for table_file in dir_filenames {
let table_file = table_file.unwrap();
let table_name = table_file
.file_name()
.into_string()
.unwrap()
.replace(".parquet", "");

file.write(
format!(
"copy {} from '{}' with (format='parquet');\n",
table_name,
table_file.path().to_str().unwrap()
)
.as_bytes(),
)
.await
.context(FileIoSnafu)?;
file.flush().await.context(FileIoSnafu)?;
}

info!("finished exporting {catalog}.{schema} copy_from.sql");

Expand Down

0 comments on commit 49d54be

Please sign in to comment.