melgenek commented on code in PR #5033:
URL: https://github.com/apache/arrow-datafusion/pull/5033#discussion_r1085600344


##########
datafusion/core/tests/sqllogictests/src/main.rs:
##########
@@ -110,13 +104,38 @@ async fn run_complete_file(
     Ok(())
 }
 
-fn read_test_files(options: &Options) -> Vec<PathBuf> {
-    std::fs::read_dir(TEST_DIRECTORY)
-        .unwrap()
-        .map(|path| path.unwrap().path())
-        .filter(|path| options.check_test_file(path.as_path()))
-        .filter(|path| options.check_pg_compat_file(path.as_path()))
-        .collect()
+fn read_test_files<'a>(
+    options: &'a Options,
+) -> Box<dyn Iterator<Item = (PathBuf, String)> + 'a> {
+    Box::new(
+        read_dir_recursive(TEST_DIRECTORY)
+            .map(|path| {
+                (
+                    path.clone(),
+                    path.to_string_lossy()
+                        .strip_prefix(TEST_DIRECTORY)
+                        .unwrap()
+                        .to_string(),
+                )
+            })
+            .filter(|(_, file_name)| options.check_test_file(file_name))
+            .filter(|(path, _)| options.check_pg_compat_file(path.as_path())),
+    )
+}
+
+fn read_dir_recursive<P: AsRef<Path>>(path: P) -> Box<dyn Iterator<Item = 
PathBuf>> {

Review Comment:
   The thing is that the resolved type for the whole implementation inside this 
function is `FlatMap`. But inside `flat_map` there is also `std::iter::once` 
for the case when there is only one file. And then rust cannot resolve a 
concrete implementation based on these options.
   
   It is probably possible to apply your suggestion, but my rust skills were 
not good enough.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to