From 49d54be06e717b56a07e692d0ebc1f3a88258f57 Mon Sep 17 00:00:00 2001 From: shuiyisong Date: Mon, 6 Nov 2023 11:13:32 +0800 Subject: [PATCH] chore: fix cr issue --- src/cmd/src/cli/export.rs | 39 ++++++++++++++++++--------------------- 1 file changed, 18 insertions(+), 21 deletions(-) diff --git a/src/cmd/src/cli/export.rs b/src/cmd/src/cli/export.rs index e9d67875cd21..fabebe8ebdeb 100644 --- a/src/cmd/src/cli/export.rs +++ b/src/cmd/src/cli/export.rs @@ -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; @@ -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");