avro 1.9.0 → 1.11.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/LICENSE +2 -2
- data/Manifest +1 -1
- data/NOTICE +2 -2
- data/Rakefile +21 -30
- data/avro.gemspec +36 -29
- data/interop/test_interop.rb +14 -3
- data/lib/avro/VERSION.txt +1 -0
- data/lib/avro/data_file.rb +30 -6
- data/lib/avro/io.rb +42 -36
- data/lib/avro/ipc.rb +12 -8
- data/lib/avro/logical_types.rb +187 -3
- data/lib/avro/protocol.rb +2 -1
- data/lib/avro/schema.rb +234 -32
- data/lib/avro/schema_compatibility.rb +32 -21
- data/lib/avro/schema_normalization.rb +2 -1
- data/lib/avro/schema_validator.rb +41 -35
- data/lib/avro.rb +16 -3
- data/test/case_finder.rb +10 -4
- data/test/random_data.rb +9 -7
- data/test/sample_ipc_client.rb +2 -1
- data/test/sample_ipc_http_client.rb +2 -1
- data/test/sample_ipc_http_server.rb +2 -1
- data/test/sample_ipc_server.rb +2 -1
- data/test/test_datafile.rb +15 -1
- data/test/test_fingerprints.rb +21 -1
- data/test/test_help.rb +2 -1
- data/test/test_io.rb +114 -18
- data/test/test_logical_types.rb +139 -2
- data/test/test_protocol.rb +3 -2
- data/test/test_schema.rb +399 -1
- data/test/test_schema_compatibility.rb +177 -1
- data/test/test_schema_normalization.rb +3 -1
- data/test/test_schema_validator.rb +27 -6
- data/test/test_socket_transport.rb +2 -1
- data/test/tool.rb +10 -9
- metadata +32 -34
- data/CHANGELOG +0 -1
@@ -1,4 +1,5 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
|
+
# frozen_string_literal: true
|
2
3
|
# Licensed to the Apache Software Foundation (ASF) under one
|
3
4
|
# or more contributor license agreements. See the NOTICE file
|
4
5
|
# distributed with this work for additional information
|
@@ -7,7 +8,7 @@
|
|
7
8
|
# "License"); you may not use this file except in compliance
|
8
9
|
# with the License. You may obtain a copy of the License at
|
9
10
|
#
|
10
|
-
#
|
11
|
+
# https://www.apache.org/licenses/LICENSE-2.0
|
11
12
|
#
|
12
13
|
# Unless required by applicable law or agreed to in writing, software
|
13
14
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
@@ -166,6 +167,7 @@ class TestSchemaNormalization < Test::Unit::TestCase
|
|
166
167
|
CaseFinder.cases.each do |test_case|
|
167
168
|
schema = Avro::Schema.parse(test_case.input)
|
168
169
|
assert_equal test_case.canonical, Avro::SchemaNormalization.to_parsing_form(schema)
|
170
|
+
assert_equal test_case.fingerprint, schema.crc_64_avro_fingerprint
|
169
171
|
end
|
170
172
|
end
|
171
173
|
end
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
# Licensed to the Apache Software Foundation (ASF) under one
|
2
3
|
# or more contributor license agreements. See the NOTICE file
|
3
4
|
# distributed with this work for additional information
|
@@ -6,7 +7,7 @@
|
|
6
7
|
# "License"); you may not use this file except in compliance
|
7
8
|
# with the License. You may obtain a copy of the License at
|
8
9
|
#
|
9
|
-
#
|
10
|
+
# https://www.apache.org/licenses/LICENSE-2.0
|
10
11
|
#
|
11
12
|
# Unless required by applicable law or agreed to in writing, software
|
12
13
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
@@ -16,8 +17,8 @@
|
|
16
17
|
|
17
18
|
require 'test_help'
|
18
19
|
|
19
|
-
class
|
20
|
-
def validate!(schema, value, options=
|
20
|
+
class TestSchemaValidator < Test::Unit::TestCase
|
21
|
+
def validate!(schema, value, options = {})
|
21
22
|
Avro::SchemaValidator.validate!(schema, value, options)
|
22
23
|
end
|
23
24
|
|
@@ -169,13 +170,13 @@ class TestSchema < Test::Unit::TestCase
|
|
169
170
|
def test_validate_float
|
170
171
|
schema = hash_to_schema(type: 'float', name: 'name')
|
171
172
|
|
172
|
-
assert_valid_schema(schema, [1.1, 1, Avro::Schema::LONG_MAX_VALUE], ['string'], true)
|
173
|
+
assert_valid_schema(schema, [1.1, 1, BigDecimal('1.1'), Avro::Schema::LONG_MAX_VALUE], ['string'], true)
|
173
174
|
end
|
174
175
|
|
175
176
|
def test_validate_double
|
176
177
|
schema = hash_to_schema(type: 'double', name: 'name')
|
177
178
|
|
178
|
-
assert_valid_schema(schema, [1.1, 1, Avro::Schema::LONG_MAX_VALUE], ['string'], true)
|
179
|
+
assert_valid_schema(schema, [1.1, 1, BigDecimal('1.1'), Avro::Schema::LONG_MAX_VALUE], ['string'], true)
|
179
180
|
end
|
180
181
|
|
181
182
|
def test_validate_fixed
|
@@ -196,6 +197,12 @@ class TestSchema < Test::Unit::TestCase
|
|
196
197
|
assert_valid_schema(schema, [{ 'sub' => nil }], [{ 'sub' => 1 }])
|
197
198
|
end
|
198
199
|
|
200
|
+
def test_validate_record_with_symbol_keys
|
201
|
+
schema = hash_to_schema(type: 'record', name: 'name', fields: [{ type: 'int', name: 'sub' }])
|
202
|
+
|
203
|
+
assert_valid_schema(schema, [{ sub: 1 }], [{ sub: '1' }])
|
204
|
+
end
|
205
|
+
|
199
206
|
def test_validate_shallow_record
|
200
207
|
schema = hash_to_schema(
|
201
208
|
type: 'record', name: 'name', fields: [{ type: 'int', name: 'sub' }]
|
@@ -277,7 +284,7 @@ class TestSchema < Test::Unit::TestCase
|
|
277
284
|
|
278
285
|
def test_validate_union_of_nil_and_record_inside_array
|
279
286
|
schema = hash_to_schema(
|
280
|
-
name: '
|
287
|
+
name: 'this_does_not_matter',
|
281
288
|
type: 'record',
|
282
289
|
fields: [
|
283
290
|
{
|
@@ -551,4 +558,18 @@ class TestSchema < Test::Unit::TestCase
|
|
551
558
|
assert_equal(1, exception.result.errors.size)
|
552
559
|
assert_equal("at . extra field 'color' - not in schema", exception.to_s)
|
553
560
|
end
|
561
|
+
|
562
|
+
def test_validate_bytes_decimal
|
563
|
+
schema = hash_to_schema(type: 'bytes', logicalType: 'decimal', precision: 4, scale: 2)
|
564
|
+
assert_valid_schema(schema, [BigDecimal('1.23'), 4.2, 1], ['4.2', BigDecimal('233.2')], true)
|
565
|
+
|
566
|
+
schema = hash_to_schema(type: 'bytes', logicalType: 'decimal', precision: 4, scale: 4)
|
567
|
+
assert_valid_schema(schema, [BigDecimal('0.2345'), 0.2, 0.1], ['4.2', BigDecimal('233.2')], true)
|
568
|
+
|
569
|
+
schema = hash_to_schema(type: 'bytes', logicalType: 'decimal', precision: 4, scale: 0)
|
570
|
+
assert_valid_schema(schema, [BigDecimal('123'), 2], ['4.2', BigDecimal('233.2')], true)
|
571
|
+
|
572
|
+
schema = hash_to_schema(type: 'bytes', logicalType: 'decimal', precision: 4)
|
573
|
+
assert_valid_schema(schema, [BigDecimal('123'), 2], ['4.2', BigDecimal('233.2')], true)
|
574
|
+
end
|
554
575
|
end
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
# Licensed to the Apache Software Foundation (ASF) under one
|
2
3
|
# or more contributor license agreements. See the NOTICE file
|
3
4
|
# distributed with this work for additional information
|
@@ -6,7 +7,7 @@
|
|
6
7
|
# "License"); you may not use this file except in compliance
|
7
8
|
# with the License. You may obtain a copy of the License at
|
8
9
|
#
|
9
|
-
#
|
10
|
+
# https://www.apache.org/licenses/LICENSE-2.0
|
10
11
|
#
|
11
12
|
# Unless required by applicable law or agreed to in writing, software
|
12
13
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
data/test/tool.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
# Licensed to the Apache Software Foundation (ASF) under one
|
2
3
|
# or more contributor license agreements. See the NOTICE file
|
3
4
|
# distributed with this work for additional information
|
@@ -6,7 +7,7 @@
|
|
6
7
|
# "License"); you may not use this file except in compliance
|
7
8
|
# with the License. You may obtain a copy of the License at
|
8
9
|
#
|
9
|
-
#
|
10
|
+
# https://www.apache.org/licenses/LICENSE-2.0
|
10
11
|
#
|
11
12
|
# Unless required by applicable law or agreed to in writing, software
|
12
13
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
@@ -21,13 +22,13 @@ require 'logger'
|
|
21
22
|
|
22
23
|
class GenericResponder < Avro::IPC::Responder
|
23
24
|
def initialize(proto, msg, datum)
|
24
|
-
proto_json = open(proto).read
|
25
|
+
proto_json = File.open(proto).read
|
25
26
|
super(Avro::Protocol.parse(proto_json))
|
26
27
|
@msg = msg
|
27
28
|
@datum = datum
|
28
29
|
end
|
29
30
|
|
30
|
-
def call(message,
|
31
|
+
def call(message, _request)
|
31
32
|
if message.name == @msg
|
32
33
|
STDERR.puts "Message: #{message.name} Datum: #{@datum.inspect}"
|
33
34
|
@datum
|
@@ -62,14 +63,14 @@ end
|
|
62
63
|
def send_message(uri, proto, msg, datum)
|
63
64
|
uri = URI.parse(uri)
|
64
65
|
trans = Avro::IPC::HTTPTransceiver.new(uri.host, uri.port)
|
65
|
-
proto_json = open(proto).read
|
66
|
+
proto_json = File.open(proto).read
|
66
67
|
requestor = Avro::IPC::Requestor.new(Avro::Protocol.parse(proto_json),
|
67
68
|
trans)
|
68
69
|
p requestor.request(msg, datum)
|
69
70
|
end
|
70
71
|
|
71
72
|
def file_or_stdin(f)
|
72
|
-
f == "-" ? STDIN : open(f)
|
73
|
+
f == "-" ? STDIN : File.open(f)
|
73
74
|
end
|
74
75
|
|
75
76
|
def main
|
@@ -100,9 +101,9 @@ def main
|
|
100
101
|
if ARGV.size > 4
|
101
102
|
case ARGV[4]
|
102
103
|
when "-file"
|
103
|
-
Avro::DataFile.open(ARGV[5])
|
104
|
-
|
105
|
-
|
104
|
+
Avro::DataFile.open(ARGV[5]) do |f|
|
105
|
+
datum = f.first
|
106
|
+
end
|
106
107
|
when "-data"
|
107
108
|
puts "JSON Decoder not yet implemented."
|
108
109
|
return 1
|
@@ -124,7 +125,7 @@ def main
|
|
124
125
|
if ARGV.size > 4
|
125
126
|
case ARGV[4]
|
126
127
|
when "-file"
|
127
|
-
Avro::DataFile.open(ARGV[5]){|f|
|
128
|
+
Avro::DataFile.open(ARGV[5]){ |f| datum = f.first }
|
128
129
|
when "-data"
|
129
130
|
puts "JSON Decoder not yet implemented"
|
130
131
|
return 1
|
metadata
CHANGED
@@ -1,48 +1,35 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: avro
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.11.0
|
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: 2021-10-20 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: '0'
|
19
|
+
version: '1.0'
|
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: '0'
|
26
|
+
version: '1.0'
|
27
27
|
description: Avro is a data serialization and RPC format
|
28
28
|
email: dev@avro.apache.org
|
29
29
|
executables: []
|
30
30
|
extensions: []
|
31
|
-
extra_rdoc_files:
|
32
|
-
- CHANGELOG
|
33
|
-
- LICENSE
|
34
|
-
- lib/avro.rb
|
35
|
-
- lib/avro/data_file.rb
|
36
|
-
- lib/avro/io.rb
|
37
|
-
- lib/avro/ipc.rb
|
38
|
-
- lib/avro/logical_types.rb
|
39
|
-
- lib/avro/protocol.rb
|
40
|
-
- lib/avro/schema.rb
|
41
|
-
- lib/avro/schema_compatibility.rb
|
42
|
-
- lib/avro/schema_normalization.rb
|
43
|
-
- lib/avro/schema_validator.rb
|
31
|
+
extra_rdoc_files: []
|
44
32
|
files:
|
45
|
-
- CHANGELOG
|
46
33
|
- LICENSE
|
47
34
|
- Manifest
|
48
35
|
- NOTICE
|
@@ -50,6 +37,7 @@ files:
|
|
50
37
|
- avro.gemspec
|
51
38
|
- interop/test_interop.rb
|
52
39
|
- lib/avro.rb
|
40
|
+
- lib/avro/VERSION.txt
|
53
41
|
- lib/avro/data_file.rb
|
54
42
|
- lib/avro/io.rb
|
55
43
|
- lib/avro/ipc.rb
|
@@ -77,10 +65,14 @@ files:
|
|
77
65
|
- test/test_schema_validator.rb
|
78
66
|
- test/test_socket_transport.rb
|
79
67
|
- test/tool.rb
|
80
|
-
homepage:
|
68
|
+
homepage: https://avro.apache.org/
|
81
69
|
licenses:
|
82
|
-
- Apache
|
83
|
-
metadata:
|
70
|
+
- Apache-2.0
|
71
|
+
metadata:
|
72
|
+
homepage_uri: https://avro.apache.org/
|
73
|
+
bug_tracker_uri: https://issues.apache.org/jira/browse/AVRO
|
74
|
+
source_code_uri: https://github.com/apache/avro
|
75
|
+
documentation_uri: https://avro.apache.org/docs/1.11.0/
|
84
76
|
post_install_message:
|
85
77
|
rdoc_options:
|
86
78
|
- "--line-numbers"
|
@@ -92,27 +84,33 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
92
84
|
requirements:
|
93
85
|
- - ">="
|
94
86
|
- !ruby/object:Gem::Version
|
95
|
-
version: '
|
87
|
+
version: '2.6'
|
96
88
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
97
89
|
requirements:
|
98
90
|
- - ">="
|
99
91
|
- !ruby/object:Gem::Version
|
100
|
-
version: '
|
92
|
+
version: '0'
|
101
93
|
requirements: []
|
102
|
-
|
103
|
-
rubygems_version: 2.5.2.1
|
94
|
+
rubygems_version: 3.1.2
|
104
95
|
signing_key:
|
105
96
|
specification_version: 4
|
106
97
|
summary: Apache Avro for Ruby
|
107
98
|
test_files:
|
108
|
-
- test/
|
109
|
-
- test/
|
110
|
-
- test/
|
99
|
+
- test/case_finder.rb
|
100
|
+
- test/random_data.rb
|
101
|
+
- test/sample_ipc_client.rb
|
102
|
+
- test/sample_ipc_http_client.rb
|
103
|
+
- test/sample_ipc_http_server.rb
|
104
|
+
- test/sample_ipc_server.rb
|
111
105
|
- test/test_datafile.rb
|
112
|
-
- test/
|
106
|
+
- test/test_fingerprints.rb
|
107
|
+
- test/test_help.rb
|
113
108
|
- test/test_io.rb
|
114
|
-
- test/test_socket_transport.rb
|
115
|
-
- test/test_schema_compatibility.rb
|
116
109
|
- test/test_logical_types.rb
|
117
|
-
- test/test_fingerprints.rb
|
118
110
|
- test/test_protocol.rb
|
111
|
+
- test/test_schema.rb
|
112
|
+
- test/test_schema_compatibility.rb
|
113
|
+
- test/test_schema_normalization.rb
|
114
|
+
- test/test_schema_validator.rb
|
115
|
+
- test/test_socket_transport.rb
|
116
|
+
- test/tool.rb
|
data/CHANGELOG
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
v0.0.1 stuff
|