Skip to content

feat!:Make AvroSchemaComponent available without derive feature - #394

Merged
martin-g merged 8 commits into
mainfrom
363-make-AvroSchemaComponent-always-available
Jan 13, 2026
Merged

martin-g merged 8 commits into
mainfrom
363-make-AvroSchemaComponent-always-available

Conversation

@martin-g

@martin-g martin-g commented Jan 8, 2026

Copy link
Copy Markdown
Member

Fixes #363

@martin-g martin-g added this to the 0.22.0 milestone Jan 8, 2026
@Kriskras99

Copy link
Copy Markdown
Contributor

I think everything in the derive module should always be available. Otherwise you have the trait available, but can't use it because you can't implement foreign traits on foreign types.

Do not use wildcard import for apache_avro_derive::* types
@martin-g
martin-g requested a review from Kriskras99 January 12, 2026 13:42
…AvroSchemaComponent::get_schema_in_ctxt()

Fix docstring example
Comment thread avro/src/schema.rs Resolved
Comment thread avro/src/schema.rs Resolved
Comment thread avro/src/schema.rs Resolved
Comment on lines +28 to +42
#[test]
fn avro_rs_394_avro_schema_component_nested_options() {
use apache_avro::{AvroSchemaComponent, Schema};
use std::collections::HashMap;

type VeryOptional = Option<Option<Option<Option<Option<i32>>>>>;

let schema = VeryOptional::get_schema_in_ctxt(&mut HashMap::default(), &None);
match schema {
Schema::Union(union_schema) => {
assert_eq!(union_schema.variants(), &[Schema::Null, Schema::Int]);
}
_ => panic!("Unexpected schema type: {schema}"),
};
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
#[test]
fn avro_rs_394_avro_schema_component_nested_options() {
use apache_avro::{AvroSchemaComponent, Schema};
use std::collections::HashMap;
type VeryOptional = Option<Option<Option<Option<Option<i32>>>>>;
let schema = VeryOptional::get_schema_in_ctxt(&mut HashMap::default(), &None);
match schema {
Schema::Union(union_schema) => {
assert_eq!(union_schema.variants(), &[Schema::Null, Schema::Int]);
}
_ => panic!("Unexpected schema type: {schema}"),
};
}
#[test]
#[should_panic(expected = "Option<T> must produce a valid (non-nested) union")]
fn avro_rs_394_avro_schema_component_nested_options() {
use apache_avro::{AvroSchemaComponent, Schema};
use std::collections::HashMap;
type VeryOptional = Option<Option<Option<Option<Option<i32>>>>>;
let _schema = VeryOptional::get_schema_in_ctxt(&mut HashMap::default(), &None);
}

@martin-g
martin-g merged commit 6492782 into main Jan 13, 2026
@martin-g
martin-g deleted the 363-make-AvroSchemaComponent-always-available branch January 13, 2026 08:56

@jklamer jklamer left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hey, seems like a super reasonable change. Is this part of a larger workstream that is going on?

@Kriskras99

Copy link
Copy Markdown
Contributor

We are currently revamping the Serde and derive(AvroSchema) part of this crate. See also #361 and #365.

I'm also personally working on async support (Kriskras99/avro-rs:rfc2), but that's currently still in a prototyping phase.

@Kriskras99 Kriskras99 mentioned this pull request Jun 28, 2026
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.

Shouldn't AvroSchemaComponent always be available

3 participants