AndreaBozzo commented on code in PR #116:
URL: https://github.com/apache/fluss-rust/pull/116#discussion_r2649701521
##########
crates/fluss/tests/integration/table.rs:
##########
@@ -382,4 +383,207 @@ mod table_test {
"Timestamp after append should resolve to offset 0 (no newer
records)"
);
}
+
+ #[tokio::test]
+ async fn test_subscribe_batch() {
+ let cluster = get_fluss_cluster();
+ let connection = cluster.get_fluss_connection().await;
+
+ let admin = connection.get_admin().await.expect("Failed to get admin");
+
+ let table_path = TablePath::new("fluss".to_string(),
"test_subscribe_batch".to_string());
+
+ let table_descriptor = TableDescriptor::builder()
+ .schema(
+ Schema::builder()
+ .column("id", DataTypes::int())
+ .column("value", DataTypes::string())
+ .build()
+ .expect("Failed to build schema"),
+ )
+ .build()
+ .expect("Failed to build table");
+
+ create_table(&admin, &table_path, &table_descriptor).await;
+
+ let table = connection
+ .get_table(&table_path)
+ .await
+ .expect("Failed to get table");
+
+ // Append 6 records
+ let append_writer = table
+ .new_append()
+ .expect("Failed to create append")
+ .create_writer();
+
+ let batch = record_batch!(
+ ("id", Int32, [1, 2, 3, 4, 5, 6]),
+ ("value", Utf8, ["a", "b", "c", "d", "e", "f"])
+ )
+ .unwrap();
+ append_writer
+ .append_arrow_batch(batch)
+ .await
+ .expect("Failed to append batch");
+ append_writer.flush().await.expect("Failed to flush");
+
+ // Test subscribe_batch with HashMap
+ let log_scanner = table
+ .new_scan()
+ .create_log_scanner()
+ .expect("Failed to create log scanner");
+
+ let mut bucket_offsets = HashMap::new();
+ bucket_offsets.insert(0, 0i64);
+ log_scanner
+ .subscribe_batch(bucket_offsets)
+ .await
+ .expect("Failed to subscribe batch");
+
+ let scan_records = log_scanner
+ .poll(std::time::Duration::from_secs(60))
+ .await
+ .expect("Failed to poll");
+
+ let records: Vec<_> = scan_records.into_iter().collect();
+ assert_eq!(
+ records.len(),
+ 6,
+ "Should have 6 records via subscribe_batch"
+ );
+
+ // Verify record contents
+ for record in records.iter() {
+ let row = record.row();
+ let id = row.get_int(0);
+ let value = row.get_string(1);
+ assert!((1..=6).contains(&id), "id should be between 1 and 6");
+ assert!(
+ ["a", "b", "c", "d", "e", "f"].contains(&value),
+ "value should be one of a-f"
+ );
Review Comment:
Agree
good catch, thank you
--
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]