Skip to content

Commit

Permalink
Fix broken link in README.md
Browse files Browse the repository at this point in the history
Remove a link to an issue/PR at flavray/avro-rs/pull/76 because it is
already resolved. Enable (uncomment) the tests related to this issue.

Signed-off-by: Martin Tzvetanov Grigorov <mgrigorov@apache.org>
  • Loading branch information
martin-g committed Feb 3, 2022
1 parent a5f5c4b commit bdca75f
Show file tree
Hide file tree
Showing 3 changed files with 97 additions and 109 deletions.
7 changes: 2 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
[![Latest Version](https://img.shields.io/crates/v/apache-avro.svg)](https://crates.io/crates/apache-avro)
[![Rust Continuous Integration](https://github.com/apache/avro/actions/workflows/test-lang-rust-ci.yml/badge.svg)](https://github.com/apache/avro/actions/workflows/test-lang-rust-ci.yml)
[![Latest Documentation](https://docs.rs/apache-avro/badge.svg)](https://docs.rs/apache-avro)
[![Apache License 2.0](https://img.shields.io/badge/license-Apache%202-blue.svg](https://github.com/apache/avro/blob/master/LICENSE.txt)
[![Apache License 2.0](https://img.shields.io/badge/license-Apache%202-blue.svg)](https://github.com/apache/avro/blob/master/LICENSE.txt)

A library for working with [Apache Avro](https://avro.apache.org/) in Rust.
A library for working with [Apache Avro](https://avro.apache.org/) in Rust language.

Please check our [documentation](https://docs.rs/apache-avro) for examples, tutorials and API reference.

Expand Down Expand Up @@ -614,9 +614,6 @@ max_allocation_bytes(2 * 1024 * 1024 * 1024); // 2GB

This library supports checking for schemas compatibility.

Note: It does not yet support named schemas (more on
https://github.com/flavray/apache-avro/pull/76).

Examples of checking for compatibility:

1. Compatible schemas
Expand Down
3 changes: 0 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -692,9 +692,6 @@
//!
//! This library supports checking for schemas compatibility.
//!
//! Note: It does not yet support named schemas (more on
//! <https://github.com/flavray/avro-rs/pull/76>).
//!
//! Examples of checking for compatibility:
//!
//! 1. Compatible schemas
Expand Down
196 changes: 95 additions & 101 deletions src/schema_compatibility.rs
Original file line number Diff line number Diff line change
Expand Up @@ -763,20 +763,17 @@ mod tests {
assert!(SchemaCompatibility::can_read(&enum_schema1, &enum_schema2));
}

// unused
/*
fn point_2d_schema() -> Schema {
Schema::parse_str(
r#"
{"type":"record", "name":"Point2D", "fields":[
{"name":"x", "type":"double"},
{"name":"y", "type":"double"}
]}
"#,
)
.unwrap()
}
*/
fn point_2d_schema() -> Schema {
Schema::parse_str(
r#"
{"type":"record", "name":"Point2D", "fields":[
{"name":"x", "type":"double"},
{"name":"y", "type":"double"}
]}
"#,
)
.unwrap()
}

fn point_2d_fullname_schema() -> Schema {
Schema::parse_str(
Expand All @@ -803,34 +800,31 @@ mod tests {
.unwrap()
}

// unused
/*
fn point_3d_schema() -> Schema {
Schema::parse_str(
r#"
{"type":"record", "name":"Point3D", "fields":[
{"name":"x", "type":"double"},
{"name":"y", "type":"double"},
{"name":"z", "type":"double", "default": 0.0}
]}
"#,
)
.unwrap()
}
fn point_3d_schema() -> Schema {
Schema::parse_str(
r#"
{"type":"record", "name":"Point3D", "fields":[
{"name":"x", "type":"double"},
{"name":"y", "type":"double"},
{"name":"z", "type":"double", "default": 0.0}
]}
"#,
)
.unwrap()
}

fn point_3d_match_name_schema() -> Schema {
Schema::parse_str(
r#"
{"type":"record", "name":"Point", "fields":[
{"name":"x", "type":"double"},
{"name":"y", "type":"double"},
{"name":"z", "type":"double", "default": 0.0}
]}
"#,
)
.unwrap()
}
*/
fn point_3d_match_name_schema() -> Schema {
Schema::parse_str(
r#"
{"type":"record", "name":"Point", "fields":[
{"name":"x", "type":"double"},
{"name":"y", "type":"double"},
{"name":"z", "type":"double", "default": 0.0}
]}
"#,
)
.unwrap()
}

#[test]
fn test_union_resolution_no_structure_match() {
Expand All @@ -842,64 +836,64 @@ mod tests {
));
}

// TODO(nlopes): the below require named schemas to be fully supported. See:
// https://github.com/flavray/avro-rs/pull/76
//
// #[test]
// fn test_union_resolution_first_structure_match_2d() {
// // multiple structure matches with no name matches
// let read_schema = union_schema(vec![
// Schema::Null,
// point_3d_no_default_schema(),
// point_2d_schema(),
// point_3d_schema(),
// ]);
// assert!(
// !SchemaCompatibility::can_read(&point_2d_fullname_schema(), &read_schema)
// );
// }

// #[test]
// fn test_union_resolution_first_structure_match_3d() {
// // multiple structure matches with no name matches
// let read_schema = union_schema(vec![
// Schema::Null,
// point_3d_no_default_schema(),
// point_3d_schema(),
// point_2d_schema(),
// ]);
// assert!(
// !SchemaCompatibility::can_read(&point_2d_fullname_schema(), &read_schema)
// );
// }

// #[test]
// fn test_union_resolution_named_structure_match() {
// // multiple structure matches with a short name match
// let read_schema = union_schema(vec![
// Schema::Null,
// point_2d_schema(),
// point_3d_match_name_schema(),
// point_3d_schema(),
// ]);
// assert!(
// !SchemaCompatibility::can_read(&point_2d_fullname_schema(), &read_schema)
// );
// }

// #[test]
// fn test_union_resolution_full_name_match() {
// // there is a full name match that should be chosen
// let read_schema = union_schema(vec![
// Schema::Null,
// point_2d_schema(),
// point_3d_match_name_schema(),
// point_3d_schema(),
// point_2d_fullname_schema(),
// ]);
// assert!(SchemaCompatibility::can_read(
// &point_2d_fullname_schema(),
// &read_schema
// ));
// }
#[test]
fn test_union_resolution_first_structure_match_2d() {
// multiple structure matches with no name matches
let read_schema = union_schema(vec![
Schema::Null,
point_3d_no_default_schema(),
point_2d_schema(),
point_3d_schema(),
]);
assert!(!SchemaCompatibility::can_read(
&point_2d_fullname_schema(),
&read_schema
));
}

#[test]
fn test_union_resolution_first_structure_match_3d() {
// multiple structure matches with no name matches
let read_schema = union_schema(vec![
Schema::Null,
point_3d_no_default_schema(),
point_3d_schema(),
point_2d_schema(),
]);
assert!(!SchemaCompatibility::can_read(
&point_2d_fullname_schema(),
&read_schema
));
}

#[test]
fn test_union_resolution_named_structure_match() {
// multiple structure matches with a short name match
let read_schema = union_schema(vec![
Schema::Null,
point_2d_schema(),
point_3d_match_name_schema(),
point_3d_schema(),
]);
assert!(!SchemaCompatibility::can_read(
&point_2d_fullname_schema(),
&read_schema
));
}

#[test]
fn test_union_resolution_full_name_match() {
// there is a full name match that should be chosen
let read_schema = union_schema(vec![
Schema::Null,
point_2d_schema(),
point_3d_match_name_schema(),
point_3d_schema(),
point_2d_fullname_schema(),
]);
assert!(SchemaCompatibility::can_read(
&point_2d_fullname_schema(),
&read_schema
));
}
}

0 comments on commit bdca75f

Please sign in to comment.