Skip to content

Commit

Permalink
fix: handle version number field renames (substrait-io/substrait#362) (
Browse files Browse the repository at this point in the history
  • Loading branch information
mbrobbel authored Nov 21, 2022
1 parent 84cdae1 commit 5b4ff3a
Show file tree
Hide file tree
Showing 11 changed files with 21 additions and 14 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ older version. Refer to the table below for the version compatibility matrix.

| Substrait... | ... is supported by validator ... |
| -------------- | ------------------------------------ |
| 0.18.x | current version |
| 0.19.x | current version |
| 0.18.x | 0.0.9 |
| 0.9.x - 0.17.x | 0.0.8 |
| 0.7.x - 0.8.x | 0.0.7 |
| 0.5.x - 0.6.x | 0.0.6 |
Expand Down
2 changes: 1 addition & 1 deletion py/tests/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
BASIC_PLAN = """
{
"version": {
"minor": 1,
"minorNumber": 1,
"producer": "validator-test"
},
"extensionUris": [],
Expand Down
4 changes: 2 additions & 2 deletions py/tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def resolver(s):
sv.check_plan_valid(
{
"version": {
"minor": 1,
"minorNumber": 1,
"producer": "validator-test",
},
"extensionUris": [
Expand All @@ -160,7 +160,7 @@ def resolver(s):
sv.check_plan_valid(
{
"version": {
"minor": 1,
"minorNumber": 1,
"producer": "validator-test",
},
"extensionUris": [
Expand Down
12 changes: 9 additions & 3 deletions rs/src/parse/plan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,15 @@ fn parse_producer_id(x: &String, y: &mut context::Context) -> diagnostic::Result
/// Parse a version node.
fn parse_version(x: &substrait::Version, y: &mut context::Context) -> diagnostic::Result<()> {
// Parse the version information.
let major = proto_primitive_field!(x, y, major).1.unwrap_or_default() as u64;
let minor = proto_primitive_field!(x, y, minor).1.unwrap_or_default() as u64;
let patch = proto_primitive_field!(x, y, patch).1.unwrap_or_default() as u64;
let major = proto_primitive_field!(x, y, major_number)
.1
.unwrap_or_default() as u64;
let minor = proto_primitive_field!(x, y, minor_number)
.1
.unwrap_or_default() as u64;
let patch = proto_primitive_field!(x, y, patch_number)
.1
.unwrap_or_default() as u64;
let version = semver::Version::new(major, minor, patch);
if version == semver::Version::new(0, 0, 0) {
diagnostic!(y, Error, Versioning, "invalid plan version (0.0.0)");
Expand Down
2 changes: 1 addition & 1 deletion rs/src/resources/substrait-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.18.0
0.19.0
2 changes: 1 addition & 1 deletion substrait
2 changes: 1 addition & 1 deletion tests/tests/version/current-version.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ plan:
__test:
- level: i
version:
minor: 18
minorNumber: 19
producer: validator-test
2 changes: 1 addition & 1 deletion tests/tests/version/incompatible-version.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ plan:
__test:
- level: i
version:
major: 1
majorNumber: 1
producer: validator-test
__test: [ diag: { level: w, code: 0007, msg: "*version*is not compatible*" } ]
2 changes: 1 addition & 1 deletion tests/tests/version/invalid-hash.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ plan:
__test:
- level: iw
version:
minor: 1
minorNumber: 1
gitHash: foobar
gitHash__test:
- diag: { level: e, code: 0002, msg: "*40-character lowercase hexadecimal string*" }
Expand Down
2 changes: 1 addition & 1 deletion tests/tests/version/unknown-version.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ plan:
__test:
- level: i
version:
minor: 1
minorNumber: 1
producer: validator-test
__test: [ diag: { level: w, code: 0007, msg: "*cannot automatically determine*compat*" } ]
2 changes: 1 addition & 1 deletion tests/tests/version/valid-hash.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ plan:
__test:
- level: iw
version:
minor: 1
minorNumber: 1
gitHash: "0123456789012345678901234567890123456789"
gitHash__test:
- diag: { level: w, code: 0007, msg: "*git hash was specified*" }
Expand Down

0 comments on commit 5b4ff3a

Please sign in to comment.