[ 
https://issues.apache.org/jira/browse/AVRO-2256?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16690977#comment-16690977
 ] 

ASF GitHub Bot commented on AVRO-2256:
--------------------------------------

Fokko closed pull request #368: AVRO-2256 Prevent error checking compatibility 
of a record reading a union in Ruby
URL: https://github.com/apache/avro/pull/368
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/lang/ruby/lib/avro/schema_compatibility.rb 
b/lang/ruby/lib/avro/schema_compatibility.rb
index 1842b3e0a..37401fc0a 100644
--- a/lang/ruby/lib/avro/schema_compatibility.rb
+++ b/lang/ruby/lib/avro/schema_compatibility.rb
@@ -141,6 +141,8 @@ def match_union_schemas(writers_schema, readers_schema)
       end
 
       def match_record_schemas(writers_schema, readers_schema)
+        return false if writers_schema.type_sym == :union
+
         writer_fields_hash = writers_schema.fields_hash
         readers_schema.fields.each do |field|
           if writer_fields_hash.key?(field.name)
diff --git a/lang/ruby/test/test_schema_compatibility.rb 
b/lang/ruby/test/test_schema_compatibility.rb
index 138c8956b..4ec60ef76 100644
--- a/lang/ruby/test/test_schema_compatibility.rb
+++ b/lang/ruby/test/test_schema_compatibility.rb
@@ -75,7 +75,9 @@ def test_compatible_reader_writer_pairs
       long_list_record_schema, long_list_record_schema,
       long_list_record_schema, int_list_record_schema,
 
-      null_schema, null_schema
+      null_schema, null_schema,
+
+      nested_optional_record, nested_record
     ].each_slice(2) do |(reader, writer)|
       assert_true(can_read?(writer, reader), "expecting #{reader} to read 
#{writer}")
     end
@@ -130,7 +132,9 @@ def test_incompatible_reader_writer_pairs
 
       int_list_record_schema, long_list_record_schema,
 
-      null_schema, int_schema
+      null_schema, int_schema,
+
+      nested_record, nested_optional_record
     ].each_slice(2) do |(reader, writer)|
       assert_false(can_read?(writer, reader), "expecting #{reader} not to read 
#{writer}")
     end
@@ -413,6 +417,14 @@ def a_dint_b_dint_record1_schema
     Avro::Schema.parse('{"type":"record", "name":"Record1", 
"fields":[{"name":"a", "type":"int", "default":0}, {"name":"b", "type":"int", 
"default":0}]}')
   end
 
+  def nested_record
+    
Avro::Schema.parse('{"type":"record","name":"parent","fields":[{"name":"attribute","type":{"type":"record","name":"child","fields":[{"name":"id","type":"string"}]}}]}')
+  end
+
+  def nested_optional_record
+    
Avro::Schema.parse('{"type":"record","name":"parent","fields":[{"name":"attribute","type":["null",{"type":"record","name":"child","fields":[{"name":"id","type":"string"}]}],"default":null}]}')
+  end
+
   def int_list_record_schema
     Avro::Schema.parse <<-SCHEMA
       {


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


> Error checking compatibility of record reader schema with union writer schema
> -----------------------------------------------------------------------------
>
>                 Key: AVRO-2256
>                 URL: https://issues.apache.org/jira/browse/AVRO-2256
>             Project: Apache Avro
>          Issue Type: Bug
>          Components: ruby
>    Affects Versions: 1.9.0
>            Reporter: Tim Perkins
>            Assignee: Tim Perkins
>            Priority: Critical
>             Fix For: 1.9.0
>
>
> This raises a missing method error because the comparison is invalid.
> Fix: https://github.com/apache/avro/pull/368



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to