mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-11-26 20:54:08 +00:00
fix(servers): report the dryrun row limit instead of "data is required" (#10491)
* test(servers): expect the dryrun row limit in the error message Signed-off-by: dayan02dev <pawarudayan92@gmail.com> * fix(servers): report the dryrun row limit instead of "data is required" Signed-off-by: dayan02dev <pawarudayan92@gmail.com> --------- Signed-off-by: dayan02dev <pawarudayan92@gmail.com>
This commit is contained in:
@@ -571,12 +571,15 @@ fn check_pipeline_name_exists(pipeline_name: Option<String>) -> Result<String> {
|
||||
})
|
||||
}
|
||||
|
||||
/// Check if the data length less than 10
|
||||
/// The maximum number of rows the pipeline dryrun API accepts.
|
||||
const MAX_DRYRUN_ROWS: usize = 10;
|
||||
|
||||
/// Check that the dryrun data has at most [`MAX_DRYRUN_ROWS`] rows.
|
||||
fn check_data_valid(data_len: usize) -> Result<()> {
|
||||
ensure!(
|
||||
data_len <= 10,
|
||||
data_len <= MAX_DRYRUN_ROWS,
|
||||
InvalidParameterSnafu {
|
||||
reason: "data is required",
|
||||
reason: format!("dryrun data must not exceed {MAX_DRYRUN_ROWS} rows, got {data_len}"),
|
||||
}
|
||||
);
|
||||
Ok(())
|
||||
@@ -1124,6 +1127,17 @@ mod tests {
|
||||
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_check_data_valid() {
|
||||
assert!(check_data_valid(0).is_ok());
|
||||
assert!(check_data_valid(10).is_ok());
|
||||
let err = check_data_valid(11).unwrap_err();
|
||||
assert_eq!(
|
||||
err.output_msg(),
|
||||
"Invalid request parameter: dryrun data must not exceed 10 rows, got 11"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_transform_ndjson() {
|
||||
let s = "{\"a\": 1}\n{\"b\": 2}";
|
||||
|
||||
Reference in New Issue
Block a user