jonahgao commented on code in PR #13936:
URL: https://github.com/apache/datafusion/pull/13936#discussion_r1899597047


##########
datafusion/sqllogictest/bin/sqllogictests.rs:
##########
@@ -147,60 +294,148 @@ async fn run_tests() -> Result<()> {
     }
 }
 
-async fn run_test_file(test_file: TestFile) -> Result<()> {
+#[cfg(feature = "postgres")]
+fn is_pg_uri_set() -> bool {
+    match env::var("PG_URI") {
+        Ok(_) => true,
+        Err(_) => false,
+    }
+}
+
+async fn run_test_file(
+    test_file: TestFile,
+    validator: Validator,
+    mp: MultiProgress,
+    mp_style: ProgressStyle,
+) -> Result<()> {
     let TestFile {
         path,
         relative_path,
     } = test_file;
-    info!("Running with DataFusion runner: {}", path.display());
     let Some(test_ctx) = 
TestContext::try_new_for_test_file(&relative_path).await else {
         info!("Skipping: {}", path.display());
         return Ok(());
     };
     setup_scratch_dir(&relative_path)?;
+
+    let count: u64 = get_record_count(&path, "Datafusion".to_string());
+    let pb = mp.add(ProgressBar::new(count));
+
+    pb.set_style(mp_style);
+    pb.set_message(format!("{:?}", &relative_path));
+
     let mut runner = sqllogictest::Runner::new(|| async {
         Ok(DataFusion::new(
             test_ctx.session_ctx().clone(),
             relative_path.clone(),
+            pb.clone(),
         ))
     });
+    runner.add_label("Datafusion");
     runner.with_column_validator(strict_column_validator);
-    runner.with_normalizer(normalizer);
-    runner.with_validator(value_validator);
-    runner
+    runner.with_normalizer(value_normalizer);
+    runner.with_validator(validator);
+
+    let res = runner
         .run_file_async(path)

Review Comment:
   Using `run_multi_async` can parse the file only once,  maybe try it in a 
follow-up PR.
   ```rust
    let records = parse_file(&path).unwrap();
    let count = get_record_count2(&records, "Datafusion");
    let res = runner
           .run_multi_async(records)
           .await
           .map_err(|e| DataFusionError::External(Box::new(e))); 
   
   
   ```
   ```rust
   fn get_record_count2(
       records: &[Record<<DataFusion as AsyncDB>::ColumnType>],
       label: &str,
   ) -> usize {
       fn runnable(cond: &Condition, label: &str) -> bool {
           match cond {
               Condition::SkipIf { label: l } => l != label,
               Condition::OnlyIf { label: l } => l == label,
           }
       }
       records
           .iter()
           .filter(|rec| match rec {
               Record::Query { conditions, .. } => {
                   conditions.iter().all(|c| runnable(c, &label))
               }
               Record::Statement { conditions, .. } => {
                   conditions.iter().all(|c| runnable(c, &label))
               }
               _ => false,
           })
           .count()
   }
   ```



-- 
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: github-unsubscr...@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org
For additional commands, e-mail: github-h...@datafusion.apache.org

Reply via email to