Uploaded image for project: 'Apache Avro'
  1. Apache Avro
  2. AVRO-2444

Fix gen_interop_data.py to work with interop.avsc

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • None
    • 1.9.2
    • interop, python
    • None

    Description

      The following command fails, since the value assigned to bytesField in gen_interop_data.py is a str, not bytes.

      $ python3 lang/py3/avro/tests/gen_interop_data.py share/test/schemas/interop.avsc /tmp/py3.avro                
      Traceback (most recent call last):
        File "lang/py3/avro/tests/gen_interop_data.py", line 55, in <module>
          dfw.append(DATUM)      
        File "/home/sekikn/.local/lib/python3.6/site-packages/avro/datafile.py", line 303, in append
          self.datum_writer.write(datum, self.buffer_encoder)
        File "/home/sekikn/.local/lib/python3.6/site-packages/avro/io.py", line 817, in write
          raise AvroTypeException(self.writer_schema, datum)
      avro.io.AvroTypeException: The datum {'intField': 12, 'longField': 15234324, 'stringField': 'hey', 'boolField': True, 'floatField': 1234.0, 'doubleField': -1234.0, 'bytesField': '12312adf', 'nullField': None, 'arrayField': [5.0, 0.0, 12.0], 'mapField': {'a': {'label': 'a'}, 'bee': {'label': 'cee'}}, 'unionField': 12.0, 'enumField': 'C', 'fixedField': b'1019181716151413', 'recordField': {'label': 'blah', 'children': [{'label': 'inner', 'children': []}]}} is not an example of the schema {
        "type": "record",           
        "name": "Interop",                         
        "namespace": "org.apache.avro",
        "fields": [                 
          {                    
            "type": "int",                   
            "name": "intField"  
          },                     
          {         
            "type": "long",
            "name": "longField"
          },                                      
          {                      
            "type": "string", 
            "name": "stringField"                                           
          },                                                          
          {                              
            "type": "boolean",                                                                                                    
            "name": "boolField"              
          },                                                                
          {                               
            "type": "float",             
            "name": "floatField"                                                                                                        
          },                  
          {                             
            "type": "double",                                               
            "name": "doubleField"
          },                                                                                        
          {                                                  
            "type": "bytes",                                                                 
            "name": "bytesField"                            
          },                                                                                                                            
          {                                                                                                                             
            "type": "null",                                                                                                             
            "name": "nullField"                                                                            
          },                        
          {                                        
            "type": {                  
              "type": "array",      
              "items": "double"
            },                               
            "name": "arrayField"
          },                     
          {         
            "type": {      
              "type": "map",   
              "values": {                         
                "type": "record",
                "name": "Foo",
                "namespace": "org.apache.avro",
                "namespace": "org.apache.avro",
                "fields": [
                  {
                    "type": "string",
                    "name": "label"
                  }
                ]
              }
            },
            "name": "mapField"
          },
          {
            "type": [
              "boolean",
              "double",
              {
                "type": "array",
                "items": "bytes"
              }
            ],
            "name": "unionField"
          },
          {
            "type": {
              "type": "enum",
              "name": "Kind",
              "namespace": "org.apache.avro",
              "symbols": [
                "A",
                "B",
                "C"
              ]
            },
            "name": "enumField"
          },
          {
            "type": {
              "type": "fixed",
              "name": "MD5",
              "namespace": "org.apache.avro",
              "size": 16
            },
            "name": "fixedField"
          },
          {
            "type": {
              "type": "record",
              "name": "Node",
              "namespace": "org.apache.avro",
              "fields": [
                {
                  "type": "string",
                  "name": "label"
                },
                {
                  "type": {
                    "type": "array",
                    "items": "org.apache.avro.Node"
                  },
                  "name": "children"
                }
              ]
            },
            "name": "recordField"
          }
        ]
      }
      

      Attachments

        Issue Links

          Activity

            People

              sekikn Kengo Seki
              sekikn Kengo Seki
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: