@@ -21,7 +21,7 @@ use datafusion_sqllogictest::{DataFusion, TestContext};
2121use futures:: stream:: StreamExt ;
2222use itertools:: Itertools ;
2323use log:: info;
24- use sqllogictest:: strict_column_validator;
24+ use sqllogictest:: { strict_column_validator, Normalizer } ;
2525use std:: ffi:: OsStr ;
2626use std:: fs;
2727use std:: path:: { Path , PathBuf } ;
@@ -40,19 +40,25 @@ pub fn main() -> Result<()> {
4040 . block_on ( run_tests ( ) )
4141}
4242
43- fn value_validator ( actual : & [ Vec < String > ] , expected : & [ String ] ) -> bool {
44- let expected = expected
45- . iter ( )
46- // Trailing whitespace from lines in SLT will typically be removed, but do not fail if it is not
47- // If particular test wants to cover trailing whitespace on a value,
48- // it should project additional non-whitespace column on the right.
49- . map ( |s| s. trim_end ( ) . to_owned ( ) )
50- . collect :: < Vec < _ > > ( ) ;
43+ #[ allow( clippy:: ptr_arg) ]
44+ fn normalizer ( s : & String ) -> String {
45+ // Trailing whitespace from lines in SLT will typically be removed, but do not fail if it is not
46+ // If particular test wants to cover trailing whitespace on a value,
47+ // it should project additional non-whitespace column on the right.
48+ s. trim_end ( ) . to_owned ( )
49+ }
50+
51+ fn value_validator (
52+ normalizer : Normalizer ,
53+ actual : & [ Vec < String > ] ,
54+ expected : & [ String ] ,
55+ ) -> bool {
56+ let expected = expected. iter ( ) . map ( normalizer) . collect :: < Vec < _ > > ( ) ;
5157 let actual = actual
5258 . iter ( )
5359 . map ( |strs| strs. iter ( ) . join ( " " ) )
5460 // Editors do not preserve trailing whitespace, so expected may or may not lack it included
55- . map ( |s| s . trim_end ( ) . to_owned ( ) )
61+ . map ( |str| normalizer ( & str ) )
5662 . collect :: < Vec < _ > > ( ) ;
5763 actual == expected
5864}
@@ -159,6 +165,7 @@ async fn run_test_file(test_file: TestFile) -> Result<()> {
159165 ) )
160166 } ) ;
161167 runner. with_column_validator ( strict_column_validator) ;
168+ runner. with_normalizer ( normalizer) ;
162169 runner. with_validator ( value_validator) ;
163170 runner
164171 . run_file_async ( path)
@@ -178,6 +185,7 @@ async fn run_test_file_with_postgres(test_file: TestFile) -> Result<()> {
178185 let mut runner =
179186 sqllogictest:: Runner :: new ( || Postgres :: connect ( relative_path. clone ( ) ) ) ;
180187 runner. with_column_validator ( strict_column_validator) ;
188+ runner. with_normalizer ( normalizer) ;
181189 runner. with_validator ( value_validator) ;
182190 runner
183191 . run_file_async ( path)
@@ -217,6 +225,7 @@ async fn run_complete_file(test_file: TestFile) -> Result<()> {
217225 path,
218226 col_separator,
219227 value_validator,
228+ normalizer,
220229 strict_column_validator,
221230 )
222231 . await
@@ -246,6 +255,7 @@ async fn run_complete_file_with_postgres(test_file: TestFile) -> Result<()> {
246255 path,
247256 col_separator,
248257 value_validator,
258+ normalizer,
249259 strict_column_validator,
250260 )
251261 . await
0 commit comments