You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@fluss.apache.org by "AndreaBozzo (via GitHub)" <gi...@apache.org> on 2025/12/26 11:52:17 UTC
[PR] chore: add integration tests for subscribe_batch and project_by_name [fluss-rust]
AndreaBozzo opened a new pull request, #116:
URL: https://github.com/apache/fluss-rust/pull/116
- Add `test_subscribe_batch`: tests `LogScanner::subscribe_batch()` with HashMap
- Add `test_project_by_name`: tests `TableScan::project_by_name()` with column names
- Both tests include error case validation
Linked issue: #31
--
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: issues-unsubscribe@fluss.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] chore: add integration tests for subscribe_batch and project_by_name [fluss-rust]
Posted by "leekeiabstraction (via GitHub)" <gi...@apache.org>.
leekeiabstraction commented on PR #116:
URL: https://github.com/apache/fluss-rust/pull/116#issuecomment-3702420751
> The `sort_by_key` is needed because `poll()` does not guarantee ordering as records may arrive from different buckets or be processed asynchronously. Also thank you again on this becouse that's how i noticed the pattern!
>
> This follows the existing pattern in the codebase:
>
> * [table.rs:159](https://github.com/apache/fluss-rust/blob/main/crates/fluss/tests/integration/table.rs#L159) - `append_record_batch_and_scan`
> * [table.rs:189](https://github.com/apache/fluss-rust/blob/main/crates/fluss/tests/integration/table.rs#L189), same test with projection
You're right. Java side uses inAnyOrder assertion: https://github.com/apache/fluss/blob/bcebe7f48dde96f7085bf14af41ff18afc1f99e6/fluss-client/src/test/java/org/apache/fluss/client/table/scanner/log/RemoteLogScannerITCase.java#L114
Approving!
--
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: issues-unsubscribe@fluss.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] chore: add integration tests for subscribe_batch and project_by_name [fluss-rust]
Posted by "AndreaBozzo (via GitHub)" <gi...@apache.org>.
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: issues-unsubscribe@fluss.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] chore: add integration tests for subscribe_batch and project_by_name [fluss-rust]
Posted by "leekeiabstraction (via GitHub)" <gi...@apache.org>.
leekeiabstraction commented on code in PR #116:
URL: https://github.com/apache/fluss-rust/pull/116#discussion_r2649690588
##########
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:
Should we check the ordering of the records?
--
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: issues-unsubscribe@fluss.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] chore: add integration tests for subscribe_batch and project_by_name [fluss-rust]
Posted by "luoyuxia (via GitHub)" <gi...@apache.org>.
luoyuxia commented on PR #116:
URL: https://github.com/apache/fluss-rust/pull/116#issuecomment-3704865317
> > @AndreaBozzo Thanks for the pr. LGTM! I only append a small commit to improve test.
>
> Thanks @luoyuxia , looking forward to further help on this promising project, take care !
Cool! Look forward to it.
--
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: issues-unsubscribe@fluss.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] chore: add integration tests for subscribe_batch and project_by_name [fluss-rust]
Posted by "luoyuxia (via GitHub)" <gi...@apache.org>.
luoyuxia merged PR #116:
URL: https://github.com/apache/fluss-rust/pull/116
--
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: issues-unsubscribe@fluss.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] chore: add integration tests for subscribe_batch and project_by_name [fluss-rust]
Posted by "leekeiabstraction (via GitHub)" <gi...@apache.org>.
leekeiabstraction commented on code in PR #116:
URL: https://github.com/apache/fluss-rust/pull/116#discussion_r2650820922
##########
crates/fluss/tests/integration/table.rs:
##########
@@ -446,22 +446,32 @@ mod table_test {
.await
.expect("Failed to poll");
- let records: Vec<_> = scan_records.into_iter().collect();
+ let mut records: Vec<_> = scan_records.into_iter().collect();
+ records.sort_by_key(|r| r.offset());
Review Comment:
Curious, is this sort_by_key needed? What happens if you do not sort?
My assumption is that poll_batch should already return records ordered by offset.
--
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: issues-unsubscribe@fluss.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] chore: add integration tests for subscribe_batch and project_by_name [fluss-rust]
Posted by "AndreaBozzo (via GitHub)" <gi...@apache.org>.
AndreaBozzo commented on PR #116:
URL: https://github.com/apache/fluss-rust/pull/116#issuecomment-3693858980
Good morning and thanks for running the workflows!
i updated the assertion to `value` in `list_offsets` with commit [9cc0250](https://github.com/apache/fluss-rust/pull/116/commits/9cc0250fda1e2b2867524d1e19a741507752fc67), all tests now pass locally
--
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: issues-unsubscribe@fluss.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] chore: add integration tests for subscribe_batch and project_by_name [fluss-rust]
Posted by "AndreaBozzo (via GitHub)" <gi...@apache.org>.
AndreaBozzo commented on PR #116:
URL: https://github.com/apache/fluss-rust/pull/116#issuecomment-3697069849
The `sort_by_key` is needed because `poll()` does not guarantee ordering as records may arrive from different buckets or be processed asynchronously. Also thank you again on this becouse that's how i noticed the pattern!
This follows the existing pattern in the codebase:
- [table.rs:159](https://github.com/apache/fluss-rust/blob/main/crates/fluss/tests/integration/table.rs#L159) - `append_record_batch_and_scan`
- [table.rs:189](https://github.com/apache/fluss-rust/blob/main/crates/fluss/tests/integration/table.rs#L189), same test with projection
--
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: issues-unsubscribe@fluss.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] chore: add integration tests for subscribe_batch and project_by_name [fluss-rust]
Posted by "AndreaBozzo (via GitHub)" <gi...@apache.org>.
AndreaBozzo commented on PR #116:
URL: https://github.com/apache/fluss-rust/pull/116#issuecomment-3702423750
> > The `sort_by_key` is needed because `poll()` does not guarantee ordering as records may arrive from different buckets or be processed asynchronously. Also thank you again on this becouse that's how i noticed the pattern!
> > This follows the existing pattern in the codebase:
> >
> > * [table.rs:159](https://github.com/apache/fluss-rust/blob/main/crates/fluss/tests/integration/table.rs#L159) - `append_record_batch_and_scan`
> > * [table.rs:189](https://github.com/apache/fluss-rust/blob/main/crates/fluss/tests/integration/table.rs#L189), same test with projection
>
> You're right. Java side uses inAnyOrder assertion: https://github.com/apache/fluss/blob/bcebe7f48dde96f7085bf14af41ff18afc1f99e6/fluss-client/src/test/java/org/apache/fluss/client/table/scanner/log/RemoteLogScannerITCase.java#L114
>
> Approving!
Kudos Mr.Lee !
--
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: issues-unsubscribe@fluss.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] chore: add integration tests for subscribe_batch and project_by_name [fluss-rust]
Posted by "AndreaBozzo (via GitHub)" <gi...@apache.org>.
AndreaBozzo commented on PR #116:
URL: https://github.com/apache/fluss-rust/pull/116#issuecomment-3704782675
> @AndreaBozzo Thanks for the pr. LGTM! I only append a small commit to improve test.
Thanks @luoyuxia , looking forward to further help on this promising project, take care !
--
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: issues-unsubscribe@fluss.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org