avro 1.9.1 → 1.10.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Manifest +1 -0
- data/Rakefile +10 -13
- data/avro.gemspec +10 -10
- data/interop/test_interop.rb +12 -2
- data/lib/avro.rb +14 -2
- data/lib/avro/VERSION.txt +1 -0
- data/lib/avro/data_file.rb +23 -0
- data/lib/avro/io.rb +23 -21
- data/lib/avro/ipc.rb +2 -2
- data/lib/avro/schema.rb +170 -27
- data/lib/avro/schema_compatibility.rb +16 -11
- data/test/case_finder.rb +8 -3
- data/test/random_data.rb +3 -2
- data/test/sample_ipc_client.rb +0 -0
- data/test/sample_ipc_http_client.rb +0 -0
- data/test/sample_ipc_http_server.rb +0 -0
- data/test/sample_ipc_server.rb +0 -0
- data/test/test_datafile.rb +13 -0
- data/test/test_fingerprints.rb +19 -0
- data/test/test_io.rb +82 -1
- data/test/test_schema.rb +268 -0
- data/test/test_schema_compatibility.rb +68 -0
- data/test/test_schema_normalization.rb +1 -0
- data/test/test_schema_validator.rb +2 -2
- data/test/tool.rb +3 -3
- metadata +16 -14
@@ -39,7 +39,12 @@ class TestSchemaCompatibility < Test::Unit::TestCase
|
|
39
39
|
long_map_schema, int_map_schema,
|
40
40
|
|
41
41
|
enum1_ab_schema, enum1_ab_schema,
|
42
|
+
enum1_ab_aliased_schema, enum1_ab_schema,
|
42
43
|
enum1_abc_schema, enum1_ab_schema,
|
44
|
+
enum1_ab_default_schema, enum1_abc_schema,
|
45
|
+
|
46
|
+
fixed1_schema, fixed1_schema,
|
47
|
+
fixed1_aliased_schema, fixed1_schema,
|
43
48
|
|
44
49
|
string_schema, bytes_schema,
|
45
50
|
bytes_schema, string_schema,
|
@@ -55,6 +60,7 @@ class TestSchemaCompatibility < Test::Unit::TestCase
|
|
55
60
|
|
56
61
|
empty_record1_schema, empty_record1_schema,
|
57
62
|
empty_record1_schema, a_int_record1_schema,
|
63
|
+
empty_record1_aliased_schema, empty_record1_schema,
|
58
64
|
|
59
65
|
a_int_record1_schema, a_int_record1_schema,
|
60
66
|
a_dint_record1_schema, a_int_record1_schema,
|
@@ -117,16 +123,22 @@ class TestSchemaCompatibility < Test::Unit::TestCase
|
|
117
123
|
int_map_schema, long_map_schema,
|
118
124
|
|
119
125
|
enum1_ab_schema, enum1_abc_schema,
|
126
|
+
enum1_ab_schema, enum1_ab_aliased_schema,
|
120
127
|
enum1_bc_schema, enum1_abc_schema,
|
121
128
|
|
122
129
|
enum1_ab_schema, enum2_ab_schema,
|
123
130
|
int_schema, enum2_ab_schema,
|
124
131
|
enum2_ab_schema, int_schema,
|
125
132
|
|
133
|
+
fixed1_schema, fixed2_schema,
|
134
|
+
fixed1_schema, fixed1_size3_schema,
|
135
|
+
fixed1_schema, fixed1_aliased_schema,
|
136
|
+
|
126
137
|
int_union_schema, int_string_union_schema,
|
127
138
|
string_union_schema, int_string_union_schema,
|
128
139
|
|
129
140
|
empty_record2_schema, empty_record1_schema,
|
141
|
+
empty_record1_schema, empty_record1_aliased_schema,
|
130
142
|
a_int_record1_schema, empty_record1_schema,
|
131
143
|
a_int_b_dint_record1_schema, empty_record1_schema,
|
132
144
|
|
@@ -169,6 +181,17 @@ class TestSchemaCompatibility < Test::Unit::TestCase
|
|
169
181
|
assert_false(can_read?(reader_schema, writer_schema))
|
170
182
|
end
|
171
183
|
|
184
|
+
def test_aliased_field
|
185
|
+
reader_schema = Avro::Schema.parse(<<-SCHEMA)
|
186
|
+
{"type":"record", "name":"Record", "fields":[
|
187
|
+
{"name":"newname1", "aliases":["oldfield1"], "type":"int"},
|
188
|
+
{"name":"oldfield2", "type":"string"}
|
189
|
+
]}
|
190
|
+
SCHEMA
|
191
|
+
assert_true(can_read?(writer_schema, reader_schema))
|
192
|
+
assert_false(can_read?(reader_schema, writer_schema))
|
193
|
+
end
|
194
|
+
|
172
195
|
def test_all_fields
|
173
196
|
reader_schema = Avro::Schema.parse <<-SCHEMA
|
174
197
|
{"type":"record", "name":"Record", "fields":[
|
@@ -250,6 +273,23 @@ class TestSchemaCompatibility < Test::Unit::TestCase
|
|
250
273
|
assert_true(can_read?(enum_schema1, enum_schema2))
|
251
274
|
end
|
252
275
|
|
276
|
+
def test_crossed_aliases
|
277
|
+
writer_schema = Avro::Schema.parse(<<-SCHEMA)
|
278
|
+
{"type":"record", "name":"Record", "fields":[
|
279
|
+
{"name":"field1", "type": "int"},
|
280
|
+
{"name":"field2", "type": "string"}
|
281
|
+
]}
|
282
|
+
SCHEMA
|
283
|
+
reader_schema = Avro::Schema.parse(<<-SCHEMA)
|
284
|
+
{"type":"record", "name":"Record", "fields":[
|
285
|
+
{"name":"field1", "aliases":["field2"], "type":"string"},
|
286
|
+
{"name":"field2", "aliases":["field1"], "type":"int"}
|
287
|
+
]}
|
288
|
+
SCHEMA
|
289
|
+
# Not supported; alias is not used if there is a redirect match
|
290
|
+
assert_false(can_read?(writer_schema, reader_schema))
|
291
|
+
end
|
292
|
+
|
253
293
|
# Tests from lang/java/avro/src/test/java/org/apache/avro/io/parsing/TestResolvingGrammarGenerator2.java
|
254
294
|
|
255
295
|
def point_2d_schema
|
@@ -373,6 +413,14 @@ class TestSchemaCompatibility < Test::Unit::TestCase
|
|
373
413
|
Avro::Schema.parse('{"type":"enum", "name":"Enum1", "symbols":["A","B"]}')
|
374
414
|
end
|
375
415
|
|
416
|
+
def enum1_ab_default_schema
|
417
|
+
Avro::Schema.parse('{"type":"enum", "name":"Enum1", "symbols":["A","B"], "default":"A"}')
|
418
|
+
end
|
419
|
+
|
420
|
+
def enum1_ab_aliased_schema
|
421
|
+
Avro::Schema.parse('{"type":"enum", "name":"Enum2", "aliases":["Enum1"], "symbols":["A","B"]}')
|
422
|
+
end
|
423
|
+
|
376
424
|
def enum1_abc_schema
|
377
425
|
Avro::Schema.parse('{"type":"enum", "name":"Enum1", "symbols":["A","B","C"]}')
|
378
426
|
end
|
@@ -385,10 +433,30 @@ class TestSchemaCompatibility < Test::Unit::TestCase
|
|
385
433
|
Avro::Schema.parse('{"type":"enum", "name":"Enum2", "symbols":["A","B"]}')
|
386
434
|
end
|
387
435
|
|
436
|
+
def fixed1_schema
|
437
|
+
Avro::Schema.parse('{"type":"fixed", "name":"Fixed1", "size": 2}')
|
438
|
+
end
|
439
|
+
|
440
|
+
def fixed1_aliased_schema
|
441
|
+
Avro::Schema.parse('{"type":"fixed", "name":"Fixed2", "aliases":["Fixed1"], "size": 2}')
|
442
|
+
end
|
443
|
+
|
444
|
+
def fixed2_schema
|
445
|
+
Avro::Schema.parse('{"type":"fixed", "name":"Fixed2", "size": 2}')
|
446
|
+
end
|
447
|
+
|
448
|
+
def fixed1_size3_schema
|
449
|
+
Avro::Schema.parse('{"type":"fixed", "name":"Fixed1", "size": 3}')
|
450
|
+
end
|
451
|
+
|
388
452
|
def empty_record1_schema
|
389
453
|
Avro::Schema.parse('{"type":"record", "name":"Record1"}')
|
390
454
|
end
|
391
455
|
|
456
|
+
def empty_record1_aliased_schema
|
457
|
+
Avro::Schema.parse('{"type":"record", "name":"Record2", "aliases":["Record1"]}')
|
458
|
+
end
|
459
|
+
|
392
460
|
def empty_record2_schema
|
393
461
|
Avro::Schema.parse('{"type":"record", "name":"Record2"}')
|
394
462
|
end
|
@@ -166,6 +166,7 @@ class TestSchemaNormalization < Test::Unit::TestCase
|
|
166
166
|
CaseFinder.cases.each do |test_case|
|
167
167
|
schema = Avro::Schema.parse(test_case.input)
|
168
168
|
assert_equal test_case.canonical, Avro::SchemaNormalization.to_parsing_form(schema)
|
169
|
+
assert_equal test_case.fingerprint, schema.crc_64_avro_fingerprint
|
169
170
|
end
|
170
171
|
end
|
171
172
|
end
|
@@ -16,7 +16,7 @@
|
|
16
16
|
|
17
17
|
require 'test_help'
|
18
18
|
|
19
|
-
class
|
19
|
+
class TestSchemaValidator < Test::Unit::TestCase
|
20
20
|
def validate!(schema, value, options=nil)
|
21
21
|
Avro::SchemaValidator.validate!(schema, value, options)
|
22
22
|
end
|
@@ -277,7 +277,7 @@ class TestSchema < Test::Unit::TestCase
|
|
277
277
|
|
278
278
|
def test_validate_union_of_nil_and_record_inside_array
|
279
279
|
schema = hash_to_schema(
|
280
|
-
name: '
|
280
|
+
name: 'this_does_not_matter',
|
281
281
|
type: 'record',
|
282
282
|
fields: [
|
283
283
|
{
|
data/test/tool.rb
CHANGED
@@ -27,7 +27,7 @@ class GenericResponder < Avro::IPC::Responder
|
|
27
27
|
@datum = datum
|
28
28
|
end
|
29
29
|
|
30
|
-
def call(message,
|
30
|
+
def call(message, _request)
|
31
31
|
if message.name == @msg
|
32
32
|
STDERR.puts "Message: #{message.name} Datum: #{@datum.inspect}"
|
33
33
|
@datum
|
@@ -101,7 +101,7 @@ def main
|
|
101
101
|
case ARGV[4]
|
102
102
|
when "-file"
|
103
103
|
Avro::DataFile.open(ARGV[5]) {|f|
|
104
|
-
f.each{|
|
104
|
+
f.each{|e| datum = e; break }
|
105
105
|
}
|
106
106
|
when "-data"
|
107
107
|
puts "JSON Decoder not yet implemented."
|
@@ -124,7 +124,7 @@ def main
|
|
124
124
|
if ARGV.size > 4
|
125
125
|
case ARGV[4]
|
126
126
|
when "-file"
|
127
|
-
Avro::DataFile.open(ARGV[5]){|f| f.each{|
|
127
|
+
Avro::DataFile.open(ARGV[5]){|f| f.each{|e| datum = e; break } }
|
128
128
|
when "-data"
|
129
129
|
puts "JSON Decoder not yet implemented"
|
130
130
|
return 1
|
metadata
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: avro
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.10.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Apache Software Foundation
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-11-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: multi_json
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '1'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '1'
|
27
27
|
description: Avro is a data serialization and RPC format
|
28
28
|
email: dev@avro.apache.org
|
29
29
|
executables: []
|
@@ -32,6 +32,7 @@ extra_rdoc_files:
|
|
32
32
|
- CHANGELOG
|
33
33
|
- LICENSE
|
34
34
|
- lib/avro.rb
|
35
|
+
- lib/avro/VERSION.txt
|
35
36
|
- lib/avro/data_file.rb
|
36
37
|
- lib/avro/io.rb
|
37
38
|
- lib/avro/ipc.rb
|
@@ -50,6 +51,7 @@ files:
|
|
50
51
|
- avro.gemspec
|
51
52
|
- interop/test_interop.rb
|
52
53
|
- lib/avro.rb
|
54
|
+
- lib/avro/VERSION.txt
|
53
55
|
- lib/avro/data_file.rb
|
54
56
|
- lib/avro/io.rb
|
55
57
|
- lib/avro/ipc.rb
|
@@ -79,7 +81,7 @@ files:
|
|
79
81
|
- test/tool.rb
|
80
82
|
homepage: https://avro.apache.org/
|
81
83
|
licenses:
|
82
|
-
- Apache
|
84
|
+
- Apache-2.0
|
83
85
|
metadata: {}
|
84
86
|
post_install_message:
|
85
87
|
rdoc_options:
|
@@ -105,14 +107,14 @@ signing_key:
|
|
105
107
|
specification_version: 4
|
106
108
|
summary: Apache Avro for Ruby
|
107
109
|
test_files:
|
108
|
-
- test/test_schema_validator.rb
|
109
|
-
- test/test_help.rb
|
110
|
-
- test/test_schema_normalization.rb
|
111
|
-
- test/test_datafile.rb
|
112
110
|
- test/test_schema.rb
|
113
|
-
- test/test_io.rb
|
114
111
|
- test/test_socket_transport.rb
|
115
|
-
- test/
|
112
|
+
- test/test_io.rb
|
116
113
|
- test/test_logical_types.rb
|
117
|
-
- test/
|
114
|
+
- test/test_help.rb
|
115
|
+
- test/test_datafile.rb
|
118
116
|
- test/test_protocol.rb
|
117
|
+
- test/test_schema_validator.rb
|
118
|
+
- test/test_schema_compatibility.rb
|
119
|
+
- test/test_schema_normalization.rb
|
120
|
+
- test/test_fingerprints.rb
|