Skip to content

Conversation

@crwen
Copy link
Contributor

@crwen crwen commented Aug 23, 2025

What changes are included in this PR?

  • Supports composite primary key
  • generate {struct}Key and {struct}KeyRef at compile time
  • implement Key and PkArray for {struct}Key; implement KeyRef for {struct}KeyRef

User can define composite primary key like this:

#[t::record(key(id, name))]
#[derive(Debug, Default)]
pub struct User {
    #[record(primary_key)]
    id: u64,
    #[record(primary_key)]
    name: String,
    age: u8,
}

quote! {
impl ::tonbo::record::typed::PkArray for #struct_key_name {
fn rewrite_pk_column(
column: &::tonbo::arrow::array::ArrayRef,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't found a good way to implement PkArray, I think we may need to reconsider how to implement the replacement.

#[t::record(key(id, name))]
#[derive(Debug, Default)]
pub struct User {
#[record(primary_key)]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an example of how to use a composite primary key

@codecov
Copy link

codecov bot commented Aug 23, 2025

Codecov Report

❌ Patch coverage is 80.29279% with 175 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/record/typed.rs 76.11% 91 Missing ⚠️
tonbo_macros/src/lib.rs 70.79% 33 Missing ⚠️
tonbo_macros/src/typed_codegen.rs 91.36% 26 Missing ⚠️
tonbo_macros/src/data_type.rs 11.11% 24 Missing ⚠️
tonbo_macros/src/record.rs 98.21% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants