gabotechs commented on code in PR #127:
URL: 
https://github.com/apache/datafusion-iceberg/pull/127#discussion_r4736223791


##########
crates/datafusion/tests/file_scan_task_provider.rs:
##########
@@ -269,6 +263,131 @@ async fn 
the_scan_keeps_its_construction_time_reader_settings() -> Result<()> {
     Ok(())
 }
 
+#[tokio::test]
+async fn reset_scans_read_the_same_files_independently() -> Result<()> {
+    let mut table = empty_items().await?;
+    table
+        .append()
+        .file(id_batch(vec![1, 2])?)
+        .file(id_batch(vec![3, 4])?)
+        .commit()
+        .await?;
+    let harness = IcebergTestHarness::builder()
+        .with_iceberg_table_factory(IcebergTableProviderFactory::new())
+        .with_table(table)
+        .with_config_option("datafusion.execution.target_partitions", 4)
+        .build()
+        .await?;
+    let scan = harness.scan().await?;
+    assert_eq!(scan.output_partitioning().partition_count(), 4);
+    let next_run = reset_plan_states(scan.clone())?;
+    let context = harness.state().task_ctx();
+    let (original_rows, reset_rows) =
+        tokio::try_join!(collect(scan, context.clone()), collect(next_run, 
context),)?;
+
+    let expected = [
+        "+----+", "| id |", "+----+", "| 1  |", "| 2  |", "| 3  |", "| 4  |", 
"+----+",
+    ];
+    datafusion::assert_batches_sorted_eq!(expected, &original_rows);
+    datafusion::assert_batches_sorted_eq!(expected, &reset_rows);
+    Ok(())

Review Comment:
   This part could be a bit more readable/mantainable. I bet that if someone 
needs to change this assertion in the future the diff is going to be impossible 
to understand.
   
   Maybe just using `insta` as well?



##########
crates/datafusion/tests/file_scan_task_provider.rs:
##########
@@ -269,6 +263,131 @@ async fn 
the_scan_keeps_its_construction_time_reader_settings() -> Result<()> {
     Ok(())
 }
 
+#[tokio::test]
+async fn reset_scans_read_the_same_files_independently() -> Result<()> {
+    let mut table = empty_items().await?;
+    table
+        .append()
+        .file(id_batch(vec![1, 2])?)
+        .file(id_batch(vec![3, 4])?)
+        .commit()
+        .await?;
+    let harness = IcebergTestHarness::builder()
+        .with_iceberg_table_factory(IcebergTableProviderFactory::new())
+        .with_table(table)
+        .with_config_option("datafusion.execution.target_partitions", 4)
+        .build()
+        .await?;
+    let scan = harness.scan().await?;
+    assert_eq!(scan.output_partitioning().partition_count(), 4);
+    let next_run = reset_plan_states(scan.clone())?;
+    let context = harness.state().task_ctx();
+    let (original_rows, reset_rows) =
+        tokio::try_join!(collect(scan, context.clone()), collect(next_run, 
context),)?;
+
+    let expected = [
+        "+----+", "| id |", "+----+", "| 1  |", "| 2  |", "| 3  |", "| 4  |", 
"+----+",
+    ];
+    datafusion::assert_batches_sorted_eq!(expected, &original_rows);
+    datafusion::assert_batches_sorted_eq!(expected, &reset_rows);
+    Ok(())
+}
+
+#[tokio::test]
+async fn a_late_partition_reads_only_the_unclaimed_file() -> Result<()> {
+    let mut table = empty_items().await?;
+    table
+        .append()
+        .file(id_batch(vec![1])?)
+        .file(id_batch(vec![2])?)
+        .commit()
+        .await?;
+    let harness = IcebergTestHarness::builder()
+        .with_iceberg_table_factory(IcebergTableProviderFactory::new())
+        .with_table(table)
+        .with_config_option("datafusion.execution.target_partitions", 2)
+        .build()
+        .await?;
+    let scan = harness.scan().await?;
+    let context = harness.state().task_ctx();
+
+    let mut active = scan.execute(0, context.clone())?;
+    let first = active.try_next().await?.expect("one row in the first file");
+    assert_eq!(first.num_rows(), 1);
+    drop(active);
+
+    let mut rows = scan.execute(1, context)?.try_collect::<Vec<_>>().await?;
+    rows.push(first);
+    datafusion::assert_batches_sorted_eq!(
+        ["+----+", "| id |", "+----+", "| 1  |", "| 2  |", "+----+"],
+        &rows
+    );
+    Ok(())

Review Comment:
   Same as above



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to