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


##########
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:
   I think https://docs.rs/itertools/latest/itertools/enum.Either.html# is one 
way to handle this. However, I don't think it matters at all. 



##########
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:
   I think https://docs.rs/itertools/latest/itertools/enum.Either.html# is one 
way to handle this. However, I don't think it is important to change



-- 
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