avro-resolution_canonical_form 0.1.0.rc0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +2 -0
- data/.rubocop.yml +0 -1
- data/.travis.yml +7 -3
- data/Appraisals +3 -0
- data/CHANGELOG.md +12 -0
- data/Gemfile +0 -2
- data/README.md +10 -9
- data/Rakefile +0 -1
- data/avro-resolution_canonical_form.gemspec +21 -5
- data/gemfiles/avro_patches_0.x.gemfile +7 -0
- data/gemfiles/avro_patches_1.x.gemfile +7 -0
- data/lib/avro-resolution_canonical_form.rb +1 -1
- data/lib/avro-resolution_canonical_form/version.rb +3 -0
- data/lib/avro/resolution_canonical_form.rb +41 -13
- metadata +59 -17
- data/lib/avro/resolution_canonical_form/version.rb +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 92db806c8c64c020593f72c0915c506a6f644f732025e1b1188a6312999a1b7c
|
4
|
+
data.tar.gz: 352466440aa35ee0743aca9880b974c2a60db65e9b0326e985c42cdda3c47a35
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d33a9ce1bb91751e437c15c379afc95bd0d7249b32f3d88be6a2c24ed9e5bb64de38927a90cdaab06fca39391c608a07a066222bc41e9dd424ad6c84432d1af9
|
7
|
+
data.tar.gz: 3597d4ebb038f45750aeb926b099bdb0f7cd07c6e7458f4f398507200090392f66cf026df28098c4daa914f7726a0066df4525b836c74cee369a803408f77c95
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
data/.travis.yml
CHANGED
@@ -1,7 +1,11 @@
|
|
1
1
|
language: ruby
|
2
2
|
rvm:
|
3
|
-
- 2.
|
4
|
-
|
3
|
+
- 2.5.8
|
4
|
+
- 2.6.6
|
5
|
+
- 2.7.1
|
6
|
+
before_install: gem install bundler -v 2.0.1 --no-document
|
7
|
+
before_script:
|
8
|
+
- bundle exec appraisal install --jobs=3
|
5
9
|
script:
|
6
10
|
- bundle exec rubocop
|
7
|
-
- bundle exec rspec
|
11
|
+
- bundle exec appraisal rspec
|
data/Appraisals
ADDED
data/CHANGELOG.md
CHANGED
@@ -1,4 +1,16 @@
|
|
1
1
|
# avro-resolution_canonical_form
|
2
2
|
|
3
|
+
## v0.3.0
|
4
|
+
- Require Avro v1.10.
|
5
|
+
- Include aliases, enum defaults, and decimal logical types in the resolution
|
6
|
+
canonical form. Schemas that use any of these parts of the Avro spec will
|
7
|
+
get a different fingerprint with this version.
|
8
|
+
|
9
|
+
## v0.2.1
|
10
|
+
- Restrict to `avro-patches` versions < 2.0.0.
|
11
|
+
|
12
|
+
## v0.2.0
|
13
|
+
- Require `avro-patches` instead of `avro-salsify-fork`.
|
14
|
+
|
3
15
|
## v0.1.0
|
4
16
|
- Initial version
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -23,24 +23,25 @@ Or install it yourself as:
|
|
23
23
|
|
24
24
|
## Resolution Canonical Form
|
25
25
|
|
26
|
-
The Resolution Canonical Form extends the [Parsing Canonical Form](http://avro.apache.org/docs/1.
|
27
|
-
to include `default` and `aliases` attributes:
|
26
|
+
The Resolution Canonical Form extends the [Parsing Canonical Form](http://avro.apache.org/docs/1.10.0/spec.html#Parsing+Canonical+Form+for+Schemas)
|
27
|
+
to include `default` and `aliases` attributes and logical type for decimals:
|
28
28
|
|
29
|
+
* [STRIP] Keep only attributes that are relevant to resolution, which are:
|
30
|
+
`name, type, fields, symbols, items, values, size, default, aliases, logical_type(=decimal), precision, scale`
|
29
31
|
* [ORDER] Order the appearance of fields in JSON objects as follows:
|
30
32
|
`name, type, fields, symbols, items, values, size, default, aliases`
|
31
|
-
* [ALIASES] [Aliases](http://avro.apache.org/docs/1.
|
33
|
+
* [ALIASES] [Aliases](http://avro.apache.org/docs/1.10.0/spec.html#Aliases) for
|
32
34
|
named types and fields are converted to their fullname, using applicable
|
33
35
|
namespace, and sorted.
|
34
36
|
|
35
37
|
## Ruby Support
|
36
38
|
|
37
|
-
This currently gem requires the [avro-
|
38
|
-
gem
|
39
|
-
will be included in Avro v1.8.2.
|
39
|
+
This currently gem requires the [avro-patches](https://github.com/salsify/avro-patches)
|
40
|
+
gem.
|
40
41
|
|
41
42
|
### Aliases
|
42
43
|
|
43
|
-
The Avro Ruby gem, including the avro-
|
44
|
+
The Avro Ruby gem, including the avro-patches, does not yet include support
|
44
45
|
for aliases. Aliases are included in the specification of the Resolution Canonical
|
45
46
|
Form above, but not yet supported by this gem.
|
46
47
|
|
@@ -68,7 +69,7 @@ schema = Avro::Schema.parse(<<-JSON)
|
|
68
69
|
JSON
|
69
70
|
|
70
71
|
Avro::ResolutionCanonicalForm.to_resolution_form(schema)
|
71
|
-
#=> {"name"
|
72
|
+
#=> => "{\"name\":\"example.dimensions\",\"type\":\"record\",\"fields\":[{\"name\":\"height\",\"type\":\"int\",\"default\":1},{\"name\":\"width\",\"type\":\"int\",\"aliases\":[\"across\"]}],\"aliases\":[\"eg.sizing\",\"example.dims\"]}"
|
72
73
|
```
|
73
74
|
|
74
75
|
A new method, `#sha256_resolution_fingerprint`, is added to `Avro::Schema` to
|
@@ -78,7 +79,7 @@ the existing `#sha256_fingerprint` which is based on the Parsing Canonical Form.
|
|
78
79
|
```ruby
|
79
80
|
schema.sha256_resolution_fingerprint
|
80
81
|
|
81
|
-
#=>
|
82
|
+
#=> 71676413924523555041213790831440929350080614901361467355865523343334332562796
|
82
83
|
```
|
83
84
|
|
84
85
|
## Development
|
data/Rakefile
CHANGED
@@ -1,11 +1,12 @@
|
|
1
1
|
# coding: utf-8
|
2
|
+
|
2
3
|
lib = File.expand_path('../lib', __FILE__)
|
3
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require 'avro
|
5
|
+
require 'avro-resolution_canonical_form/version'
|
5
6
|
|
6
7
|
Gem::Specification.new do |spec|
|
7
8
|
spec.name = 'avro-resolution_canonical_form'
|
8
|
-
spec.version =
|
9
|
+
spec.version = AvroResolutionCanonicalForm::VERSION
|
9
10
|
spec.authors = ['Salsify, Inc']
|
10
11
|
spec.email = ['engineering@salsify.com']
|
11
12
|
|
@@ -18,7 +19,6 @@ Gem::Specification.new do |spec|
|
|
18
19
|
# Set 'allowed_push_post' to control where this gem can be published.
|
19
20
|
if spec.respond_to?(:metadata)
|
20
21
|
spec.metadata['allowed_push_host'] = 'https://rubygems.org'
|
21
|
-
|
22
22
|
else
|
23
23
|
raise 'RubyGems 2.0 or newer is required to protect against public gem pushes.'
|
24
24
|
end
|
@@ -28,11 +28,27 @@ Gem::Specification.new do |spec|
|
|
28
28
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
29
29
|
spec.require_paths = ['lib']
|
30
30
|
|
31
|
-
spec.add_development_dependency '
|
31
|
+
spec.add_development_dependency 'appraisal'
|
32
|
+
spec.add_development_dependency 'bundler', '~> 2.0'
|
32
33
|
spec.add_development_dependency 'rake', '~> 10.0'
|
33
34
|
spec.add_development_dependency 'rspec', '~> 3.4'
|
34
35
|
spec.add_development_dependency 'salsify_rubocop', '~> 0.46.0'
|
35
36
|
spec.add_development_dependency 'overcommit'
|
36
37
|
spec.add_development_dependency 'simplecov'
|
37
|
-
|
38
|
+
|
39
|
+
spec.add_runtime_dependency 'avro', '~> 1.10.0'
|
40
|
+
spec.add_runtime_dependency 'avro-patches', '< 2.0.0'
|
41
|
+
|
42
|
+
spec.post_install_message = %(
|
43
|
+
avro-resolution_canonical_form now requires Avro v1.10.
|
44
|
+
|
45
|
+
New features in Avro Ruby v1.10 are now included in the canonical form:
|
46
|
+
- aliases
|
47
|
+
- enum defaults
|
48
|
+
- decimal logical types
|
49
|
+
|
50
|
+
Schemas that use any of these features will get a different fingerprint with
|
51
|
+
this version. For projects that only use Ruby, use of these features is unlikely
|
52
|
+
as they were previously unsupported.
|
53
|
+
)
|
38
54
|
end
|
@@ -1,7 +1,9 @@
|
|
1
|
-
require 'avro'
|
1
|
+
require 'avro-patches'
|
2
2
|
|
3
3
|
module Avro
|
4
4
|
class ResolutionCanonicalForm < SchemaNormalization
|
5
|
+
DECIMAL_LOGICAL_TYPE = 'decimal'.freeze
|
6
|
+
|
5
7
|
def self.to_resolution_form(schema)
|
6
8
|
new.to_resolution_form(schema)
|
7
9
|
end
|
@@ -12,20 +14,46 @@ module Avro
|
|
12
14
|
|
13
15
|
private
|
14
16
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
17
|
+
def normalize_schema(schema)
|
18
|
+
if schema.type_sym == :bytes && schema.logical_type == DECIMAL_LOGICAL_TYPE
|
19
|
+
add_logical_type(schema, type: schema.type)
|
20
|
+
else
|
21
|
+
super
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
19
25
|
def normalize_field(field)
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
+
extensions = {}
|
27
|
+
extensions[:default] = field.default if field.default?
|
28
|
+
if field.aliases && !field.aliases.empty?
|
29
|
+
extensions[:aliases] = field.aliases.sort
|
30
|
+
end
|
31
|
+
|
32
|
+
super.merge(extensions)
|
26
33
|
end
|
27
34
|
|
28
|
-
|
29
|
-
|
35
|
+
def add_logical_type(schema, serialized)
|
36
|
+
if schema.logical_type == DECIMAL_LOGICAL_TYPE
|
37
|
+
extensions = { logicalType: DECIMAL_LOGICAL_TYPE }
|
38
|
+
extensions[:precision] = schema.precision if schema.respond_to?(:precision) && schema.precision
|
39
|
+
extensions[:scale] = schema.scale if schema.respond_to?(:scale) && schema.scale
|
40
|
+
serialized.merge(extensions)
|
41
|
+
else
|
42
|
+
serialized
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def normalize_named_type(schema, attributes = {})
|
47
|
+
extensions = {}
|
48
|
+
if schema.respond_to?(:default)
|
49
|
+
# For enum defaults
|
50
|
+
extensions[:default] = schema.default unless schema.default.nil?
|
51
|
+
end
|
52
|
+
|
53
|
+
aliases = schema.fullname_aliases
|
54
|
+
extensions[:aliases] = aliases.sort unless aliases.empty?
|
55
|
+
extensions = add_logical_type(schema, extensions)
|
56
|
+
super.merge(extensions)
|
57
|
+
end
|
30
58
|
end
|
31
59
|
end
|
metadata
CHANGED
@@ -1,29 +1,43 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: avro-resolution_canonical_form
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Salsify, Inc
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-07-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: appraisal
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: bundler
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
16
30
|
requirements:
|
17
31
|
- - "~>"
|
18
32
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
33
|
+
version: '2.0'
|
20
34
|
type: :development
|
21
35
|
prerelease: false
|
22
36
|
version_requirements: !ruby/object:Gem::Requirement
|
23
37
|
requirements:
|
24
38
|
- - "~>"
|
25
39
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
40
|
+
version: '2.0'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: rake
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -95,19 +109,33 @@ dependencies:
|
|
95
109
|
- !ruby/object:Gem::Version
|
96
110
|
version: '0'
|
97
111
|
- !ruby/object:Gem::Dependency
|
98
|
-
name: avro
|
112
|
+
name: avro
|
99
113
|
requirement: !ruby/object:Gem::Requirement
|
100
114
|
requirements:
|
101
|
-
- - "
|
115
|
+
- - "~>"
|
102
116
|
- !ruby/object:Gem::Version
|
103
|
-
version: 1.
|
117
|
+
version: 1.10.0
|
104
118
|
type: :runtime
|
105
119
|
prerelease: false
|
106
120
|
version_requirements: !ruby/object:Gem::Requirement
|
107
121
|
requirements:
|
108
|
-
- - "
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: 1.10.0
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: avro-patches
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - "<"
|
109
130
|
- !ruby/object:Gem::Version
|
110
|
-
version:
|
131
|
+
version: 2.0.0
|
132
|
+
type: :runtime
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - "<"
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: 2.0.0
|
111
139
|
description: Unique identification of Avro schemas for schema resolution
|
112
140
|
email:
|
113
141
|
- engineering@salsify.com
|
@@ -122,6 +150,7 @@ files:
|
|
122
150
|
- ".rspec"
|
123
151
|
- ".rubocop.yml"
|
124
152
|
- ".travis.yml"
|
153
|
+
- Appraisals
|
125
154
|
- CHANGELOG.md
|
126
155
|
- Gemfile
|
127
156
|
- LICENSE.txt
|
@@ -130,16 +159,29 @@ files:
|
|
130
159
|
- avro-resolution_canonical_form.gemspec
|
131
160
|
- bin/console
|
132
161
|
- bin/setup
|
162
|
+
- gemfiles/avro_patches_0.x.gemfile
|
163
|
+
- gemfiles/avro_patches_1.x.gemfile
|
133
164
|
- lib/avro-resolution_canonical_form.rb
|
165
|
+
- lib/avro-resolution_canonical_form/version.rb
|
134
166
|
- lib/avro/resolution_canonical_form.rb
|
135
|
-
- lib/avro/resolution_canonical_form/version.rb
|
136
167
|
- lib/avro/resolution_fingerprint.rb
|
137
168
|
homepage: https://github.com/salsify/avro-resolution_canonical_form
|
138
169
|
licenses:
|
139
170
|
- MIT
|
140
171
|
metadata:
|
141
172
|
allowed_push_host: https://rubygems.org
|
142
|
-
post_install_message:
|
173
|
+
post_install_message: |2
|
174
|
+
|
175
|
+
avro-resolution_canonical_form now requires Avro v1.10.
|
176
|
+
|
177
|
+
New features in Avro Ruby v1.10 are now included in the canonical form:
|
178
|
+
- aliases
|
179
|
+
- enum defaults
|
180
|
+
- decimal logical types
|
181
|
+
|
182
|
+
Schemas that use any of these features will get a different fingerprint with
|
183
|
+
this version. For projects that only use Ruby, use of these features is unlikely
|
184
|
+
as they were previously unsupported.
|
143
185
|
rdoc_options: []
|
144
186
|
require_paths:
|
145
187
|
- lib
|
@@ -150,13 +192,13 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
150
192
|
version: '0'
|
151
193
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
152
194
|
requirements:
|
153
|
-
- - "
|
195
|
+
- - ">="
|
154
196
|
- !ruby/object:Gem::Version
|
155
|
-
version:
|
197
|
+
version: '0'
|
156
198
|
requirements: []
|
157
|
-
rubyforge_project:
|
158
|
-
rubygems_version: 2.6.
|
159
|
-
signing_key:
|
199
|
+
rubyforge_project:
|
200
|
+
rubygems_version: 2.7.6.2
|
201
|
+
signing_key:
|
160
202
|
specification_version: 4
|
161
203
|
summary: Unique identification of Avro schemas for schema resolution
|
162
204
|
test_files: []
|