Skip to content

Commit

Permalink
feat: CopyIntoLocation support output. (#14315)
Browse files Browse the repository at this point in the history
* refactor unload.

* feat: CopyIntoLocation support output.

* update tests.

* fix test.

* fix test.
  • Loading branch information
youngsofun authored Jan 14, 2024
1 parent 094e1db commit b9a4726
Show file tree
Hide file tree
Showing 40 changed files with 673 additions and 142 deletions.
7 changes: 5 additions & 2 deletions src/meta/app/src/principal/user_stage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -478,10 +478,13 @@ pub struct CopyOptions {
pub max_files: usize,
pub split_size: usize,
pub purge: bool,
pub single: bool,
pub max_file_size: usize,
pub disable_variant_check: bool,
pub return_failed_only: bool,

// unload only
pub max_file_size: usize,
pub single: bool,
pub detailed_output: bool,
}

impl CopyOptions {
Expand Down
1 change: 1 addition & 0 deletions src/meta/proto-conv/src/stage_from_to_protobuf_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ impl FromToProto for mt::principal::CopyOptions {
max_file_size,
disable_variant_check: p.disable_variant_check,
return_failed_only: p.return_failed_only,
detailed_output: false,
})
}

Expand Down
11 changes: 11 additions & 0 deletions src/meta/proto-conv/tests/it/user_proto_conv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ pub(crate) fn test_fs_stage_info() -> mt::principal::StageInfo {
max_file_size: 0,
disable_variant_check: false,
return_failed_only: false,
detailed_output: false,
},
comment: "test".to_string(),

Expand Down Expand Up @@ -142,6 +143,7 @@ pub(crate) fn test_s3_stage_info() -> mt::principal::StageInfo {
max_file_size: 0,
disable_variant_check: false,
return_failed_only: false,
detailed_output: false,
},
comment: "test".to_string(),
..Default::default()
Expand Down Expand Up @@ -181,6 +183,7 @@ pub(crate) fn test_s3_stage_info_v16() -> mt::principal::StageInfo {
max_file_size: 0,
disable_variant_check: false,
return_failed_only: false,
detailed_output: false,
},
comment: "test".to_string(),
..Default::default()
Expand Down Expand Up @@ -220,6 +223,7 @@ pub(crate) fn test_s3_stage_info_v14() -> mt::principal::StageInfo {
max_file_size: 0,
disable_variant_check: false,
return_failed_only: false,
detailed_output: false,
},
comment: "test".to_string(),
..Default::default()
Expand Down Expand Up @@ -255,6 +259,7 @@ pub(crate) fn test_gcs_stage_info() -> mt::principal::StageInfo {
max_file_size: 0,
disable_variant_check: false,
return_failed_only: false,
detailed_output: false,
},
comment: "test".to_string(),
..Default::default()
Expand Down Expand Up @@ -294,6 +299,7 @@ pub(crate) fn test_oss_stage_info() -> mt::principal::StageInfo {
max_file_size: 0,
disable_variant_check: false,
return_failed_only: false,
detailed_output: false,
},
comment: "test".to_string(),
..Default::default()
Expand Down Expand Up @@ -328,6 +334,7 @@ pub(crate) fn test_webhdfs_stage_info() -> mt::principal::StageInfo {
max_file_size: 0,
disable_variant_check: false,
return_failed_only: false,
detailed_output: false,
},
comment: "test".to_string(),
..Default::default()
Expand Down Expand Up @@ -363,6 +370,7 @@ pub(crate) fn test_obs_stage_info() -> mt::principal::StageInfo {
max_file_size: 0,
disable_variant_check: false,
return_failed_only: false,
detailed_output: false,
},
comment: "test".to_string(),
..Default::default()
Expand Down Expand Up @@ -398,6 +406,7 @@ pub(crate) fn test_cos_stage_info() -> mt::principal::StageInfo {
max_file_size: 0,
disable_variant_check: false,
return_failed_only: false,
detailed_output: false,
},
comment: "test".to_string(),
..Default::default()
Expand Down Expand Up @@ -847,6 +856,7 @@ pub(crate) fn test_internal_stage_info_v17() -> mt::principal::StageInfo {
max_file_size: 0,
disable_variant_check: false,
return_failed_only: false,
detailed_output: false,
},
comment: "test".to_string(),
..Default::default()
Expand Down Expand Up @@ -878,6 +888,7 @@ pub(crate) fn test_stage_info_v18() -> mt::principal::StageInfo {
max_file_size: 0,
disable_variant_check: false,
return_failed_only: false,
detailed_output: false,
},
comment: "test".to_string(),
..Default::default()
Expand Down
20 changes: 20 additions & 0 deletions src/meta/proto-conv/tests/it/user_stage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ fn test_user_stage_webhdfs_v30() -> anyhow::Result<()> {
max_file_size: 0,
disable_variant_check: false,
return_failed_only: false,
detailed_output: false,
},
comment: "test".to_string(),
..Default::default()
Expand Down Expand Up @@ -156,6 +157,7 @@ fn test_user_stage_fs_v22() -> anyhow::Result<()> {
max_file_size: 0,
disable_variant_check: false,
return_failed_only: false,
detailed_output: false,
},
comment: "test".to_string(),
..Default::default()
Expand Down Expand Up @@ -200,6 +202,7 @@ fn test_user_stage_fs_v21() -> anyhow::Result<()> {
max_file_size: 0,
disable_variant_check: false,
return_failed_only: false,
detailed_output: false,
},
comment: "test".to_string(),
..Default::default()
Expand Down Expand Up @@ -243,6 +246,7 @@ fn test_user_stage_fs_v20() -> anyhow::Result<()> {
max_file_size: 0,
disable_variant_check: false,
return_failed_only: false,
detailed_output: false,
},
comment: "test".to_string(),
..Default::default()
Expand Down Expand Up @@ -287,6 +291,7 @@ fn test_user_stage_fs_v16() -> anyhow::Result<()> {
max_file_size: 0,
disable_variant_check: false,
return_failed_only: false,
detailed_output: false,
},
comment: "test".to_string(),
..Default::default()
Expand Down Expand Up @@ -343,6 +348,7 @@ fn test_user_stage_s3_v16() -> anyhow::Result<()> {
max_file_size: 0,
disable_variant_check: false,
return_failed_only: false,
detailed_output: false,
},
comment: "test".to_string(),
..Default::default()
Expand Down Expand Up @@ -393,6 +399,7 @@ fn test_user_stage_gcs_v16() -> anyhow::Result<()> {
max_file_size: 0,
disable_variant_check: false,
return_failed_only: false,
detailed_output: false,
},
comment: "test".to_string(),
..Default::default()
Expand Down Expand Up @@ -448,6 +455,7 @@ fn test_user_stage_oss_v16() -> anyhow::Result<()> {
max_file_size: 0,
disable_variant_check: false,
return_failed_only: false,
detailed_output: false,
},
comment: "test".to_string(),
..Default::default()
Expand Down Expand Up @@ -503,6 +511,7 @@ fn test_user_stage_oss_v13() -> anyhow::Result<()> {
max_file_size: 0,
disable_variant_check: false,
return_failed_only: false,
detailed_output: false,
},
comment: "test".to_string(),
..Default::default()
Expand Down Expand Up @@ -558,6 +567,7 @@ fn test_user_stage_s3_v11() -> anyhow::Result<()> {
max_file_size: 0,
disable_variant_check: false,
return_failed_only: false,
detailed_output: false,
},
comment: "test".to_string(),
..Default::default()
Expand Down Expand Up @@ -611,6 +621,7 @@ fn test_user_stage_s3_v8() -> anyhow::Result<()> {
max_file_size: 0,
disable_variant_check: false,
return_failed_only: false,
detailed_output: false,
},
comment: "test".to_string(),
..Default::default()
Expand Down Expand Up @@ -655,6 +666,7 @@ fn test_user_stage_fs_v6() -> anyhow::Result<()> {
max_file_size: 0,
disable_variant_check: false,
return_failed_only: false,
detailed_output: false,
},
comment: "test".to_string(),
..Default::default()
Expand Down Expand Up @@ -709,6 +721,7 @@ fn test_user_stage_s3_v6() -> anyhow::Result<()> {
max_file_size: 0,
disable_variant_check: false,
return_failed_only: false,
detailed_output: false,
},
comment: "test".to_string(),
..Default::default()
Expand Down Expand Up @@ -759,6 +772,7 @@ fn test_user_stage_gcs_v6() -> anyhow::Result<()> {
max_file_size: 0,
disable_variant_check: false,
return_failed_only: false,
detailed_output: false,
},
comment: "test".to_string(),
..Default::default()
Expand Down Expand Up @@ -802,6 +816,7 @@ fn test_user_stage_fs_v4() -> anyhow::Result<()> {
max_file_size: 0,
disable_variant_check: false,
return_failed_only: false,
detailed_output: false,
},
comment: "test".to_string(),
..Default::default()
Expand Down Expand Up @@ -856,6 +871,7 @@ fn test_user_stage_s3_v4() -> anyhow::Result<()> {
max_file_size: 0,
disable_variant_check: false,
return_failed_only: false,
detailed_output: false,
},
comment: "test".to_string(),
..Default::default()
Expand Down Expand Up @@ -905,6 +921,7 @@ fn test_user_stage_gcs_v4() -> anyhow::Result<()> {
max_file_size: 0,
disable_variant_check: false,
return_failed_only: false,
detailed_output: false,
},
comment: "test".to_string(),
..Default::default()
Expand Down Expand Up @@ -956,6 +973,7 @@ fn test_user_stage_s3_v1() -> anyhow::Result<()> {
max_file_size: 0,
disable_variant_check: false,
return_failed_only: false,
detailed_output: false,
},
comment: "test".to_string(),
..Default::default()
Expand Down Expand Up @@ -1002,6 +1020,7 @@ fn test_internal_stage_v17() -> anyhow::Result<()> {
max_file_size: 0,
disable_variant_check: false,
return_failed_only: false,
detailed_output: false,
},
comment: "test".to_string(),
..Default::default()
Expand Down Expand Up @@ -1047,6 +1066,7 @@ fn test_user_stage_v19() -> anyhow::Result<()> {
max_file_size: 0,
disable_variant_check: false,
return_failed_only: false,
detailed_output: false,
},
comment: "test".to_string(),
..Default::default()
Expand Down
1 change: 1 addition & 0 deletions src/meta/proto-conv/tests/it/v025_user_stage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ fn test_decode_v25_user_stage() -> anyhow::Result<()> {
max_file_size: 0,
disable_variant_check: false,
return_failed_only: false,
detailed_output: false,
},
comment: "test".to_string(),
number_of_files: 100,
Expand Down
1 change: 1 addition & 0 deletions src/meta/proto-conv/tests/it/v030_user_stage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ fn test_decode_v30_user_stage() -> anyhow::Result<()> {
max_file_size: 0,
disable_variant_check: false,
return_failed_only: false,
detailed_output: false,
},
comment: "test".to_string(),
..Default::default()
Expand Down
1 change: 1 addition & 0 deletions src/meta/proto-conv/tests/it/v031_copy_max_file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ fn test_decode_v31_copy_max_file() -> anyhow::Result<()> {
max_file_size: 0,
disable_variant_check: false,
return_failed_only: false,
detailed_output: false,
},
comment: "test".to_string(),
..Default::default()
Expand Down
1 change: 1 addition & 0 deletions src/meta/proto-conv/tests/it/v035_user_stage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ fn test_decode_v35_user_stage() -> anyhow::Result<()> {
max_file_size: 0,
disable_variant_check: true,
return_failed_only: false,
detailed_output: false,
},
comment: "test".to_string(),
number_of_files: 100,
Expand Down
1 change: 1 addition & 0 deletions src/meta/proto-conv/tests/it/v042_s3_stage_new_field.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ fn test_decode_v42_s3_stage_new_field() -> anyhow::Result<()> {
max_file_size: 0,
disable_variant_check: true,
return_failed_only: false,
detailed_output: false,
},
comment: "test".to_string(),
number_of_files: 100,
Expand Down
2 changes: 2 additions & 0 deletions src/meta/proto-conv/tests/it/v051_obs_and_cos_storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ fn test_decode_v51_obs_stage() -> anyhow::Result<()> {
max_file_size: 0,
disable_variant_check: false,
return_failed_only: false,
detailed_output: false,
},
comment: "test".to_string(),
..Default::default()
Expand Down Expand Up @@ -120,6 +121,7 @@ fn test_decode_v51_cos_stage() -> anyhow::Result<()> {
max_file_size: 0,
disable_variant_check: false,
return_failed_only: false,
detailed_output: false,
},
comment: "test".to_string(),
..Default::default()
Expand Down
1 change: 1 addition & 0 deletions src/meta/proto-conv/tests/it/v057_hdfs_storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ fn test_decode_v57_hdfs_storage() -> anyhow::Result<()> {
max_file_size: 0,
disable_variant_check: false,
return_failed_only: false,
detailed_output: false,
},
comment: "test".to_string(),
..Default::default()
Expand Down
1 change: 1 addition & 0 deletions src/meta/proto-conv/tests/it/v060_copy_options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ fn test_decode_v60_copy_options() -> anyhow::Result<()> {
max_file_size: 100,
disable_variant_check: true,
return_failed_only: true,
detailed_output: false,
};
common::test_pb_from_to(func_name!(), want())?;
common::test_load_old(func_name!(), copy_options_v60.as_slice(), 0, want())?;
Expand Down
1 change: 1 addition & 0 deletions src/meta/proto-conv/tests/it/v066_stage_create_on.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ fn test_decode_v66_stage() -> anyhow::Result<()> {
max_file_size: 0,
disable_variant_check: true,
return_failed_only: false,
detailed_output: false,
},
comment: "ccc".to_string(),
number_of_files: 100,
Expand Down
6 changes: 5 additions & 1 deletion src/query/ast/src/ast/statements/copy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ pub struct CopyIntoLocationStmt {
pub file_format: BTreeMap<String, String>,
pub single: bool,
pub max_file_size: usize,
pub detailed_output: bool,
}

impl Display for CopyIntoLocationStmt {
Expand All @@ -233,7 +234,8 @@ impl Display for CopyIntoLocationStmt {
write!(f, ")")?;
}
write!(f, " SINGLE = {}", self.single)?;
write!(f, " MAX_FILE_SIZE= {}", self.max_file_size)?;
write!(f, " MAX_FILE_SIZE = {}", self.max_file_size)?;
write!(f, " DETAILED_OUTPUT = {}", self.detailed_output)?;

Ok(())
}
Expand All @@ -245,6 +247,7 @@ impl CopyIntoLocationStmt {
CopyIntoLocationOption::FileFormat(v) => self.file_format = v,
CopyIntoLocationOption::Single(v) => self.single = v,
CopyIntoLocationOption::MaxFileSize(v) => self.max_file_size = v,
CopyIntoLocationOption::DetailedOutput(v) => self.detailed_output = v,
}
}
}
Expand Down Expand Up @@ -491,4 +494,5 @@ pub enum CopyIntoLocationOption {
FileFormat(BTreeMap<String, String>),
MaxFileSize(usize),
Single(bool),
DetailedOutput(bool),
}
Loading

0 comments on commit b9a4726

Please sign in to comment.