| 909 | } |
| 910 | |
| 911 | fn process_assert( |
| 912 | bench: &mut SqlBenchmark, |
| 913 | reader: &mut BenchmarkFileReader, |
| 914 | line: &mut String, |
| 915 | splits: &[&str], |
| 916 | ) -> Result<()> { |
| 917 | // count the amount of columns based on character count. The actual |
| 918 | // character used is irrelevant. |
| 919 | if splits.len() <= 1 || splits[1].is_empty() { |
| 920 | return Err(exec_datafusion_err!( |
| 921 | "{}", |
| 922 | reader.format_exception( |
| 923 | "assert must be followed by a column count (e.g. assert III)" |
| 924 | ) |
| 925 | )); |
| 926 | } |
| 927 | |
| 928 | line.clear(); |
| 929 | |
| 930 | // read the actual query |
| 931 | let mut found_break = false; |
| 932 | let mut sql = String::new(); |
| 933 | let mut reader_result = reader.read_line(line); |
| 934 | |
| 935 | loop { |
| 936 | match reader_result { |
| 937 | Some(Ok(_)) => { |
| 938 | if line.trim() == "----" { |
| 939 | found_break = true; |
| 940 | break; |
| 941 | } |
| 942 | sql.push('\n'); |
| 943 | sql.push_str(line); |
| 944 | } |
| 945 | Some(Err(e)) => return Err(e), |
| 946 | None => break, |
| 947 | } |
| 948 | |
| 949 | // Clear the line buffer for the next iteration. |
| 950 | line.clear(); |
| 951 | reader_result = reader.read_line(line); |
| 952 | } |
| 953 | |
| 954 | if !found_break { |
| 955 | return Err(exec_datafusion_err!( |
| 956 | "{}", |
| 957 | reader.format_exception( |
| 958 | "assert must be followed by a query and a result (separated by ----)" |
| 959 | ) |
| 960 | )); |
| 961 | } |
| 962 | |
| 963 | bench |
| 964 | .assert_queries |
| 965 | .push(read_query_from_reader(reader, &sql, splits[1])?); |
| 966 | |
| 967 | Ok(()) |
| 968 | } |