title: Avro multiple record of same type in single schema
body: <p>I like to use the same record type in an Avro schema multiple times. Consider this schema definition</p>
  
  <pre>
  {
      "type": "record",
      "name": "OrderBook",
      "namespace": "my.types",
      "doc": "Test order update",
      "fields": [
          {
              "name": "bids",
              "type": {
                  "type": "array",
                  "items": {
                      "type": "record",
                      "name": "OrderBookVolume",
                      "namespace": "my.types",
                      "fields": [
                          {
                              "name": "price",
                              "type": "double"
                          },
                          {
                              "name": "volume",
                              "type": "double"
                          }
                      ]
                  }
              }
          },
          {
              "name": "asks",
              "type": {
                  "type": "array",
                  "items": {
                      "type": "record",
                      "name": "OrderBookVolume",
                      "namespace": "my.types",
                      "fields": [
                          {
                              "name": "price",
                              "type": "double"
                          },
                          {
                              "name": "volume",
                              "type": "double"
                          }
                      ]
                  }
              }
          }
      ]
  }
  </pre>
  
  <p>This is not a valid Avro schema and the Avro schema parser fails with</p>
  
  <blockquote>
    <p>org.apache.avro.SchemaParseException: Can't redefine: my.types.OrderBookVolume </p>
  </blockquote>
  
  <p>I can fix this by making the type unique by moving the OrderBookVolume into two different namespaces:</p>
  
  <pre>
  {
      "type": "record",
      "name": "OrderBook",
      "namespace": "my.types",
      "doc": "Test order update",
      "fields": [
          {
              "name": "bids",
              "type": {
                  "type": "array",
                  "items": {
                      "type": "record",
                      "name": "OrderBookVolume",
                      "namespace": "my.types.bid",
                      "fields": [
                          {
                              "name": "price",
                              "type": "double"
                          },
                          {
                              "name": "volume",
                              "type": "double"
                          }
                      ]
                  }
              }
          },
          {
              "name": "asks",
              "type": {
                  "type": "array",
                  "items": {
                      "type": "record",
                      "name": "OrderBookVolume",
                      "namespace": "my.types.ask",
                      "fields": [
                          {
                              "name": "price",
                              "type": "double"
                          },
                          {
                              "name": "volume",
                              "type": "double"
                          }
                      ]
                  }
              }
          }
      ]
  }
  </pre>
  
  <p>This is not a valid solution as the Avro code generation would generate two different classes, which is very annoying if I like to use the type also for other things and not just for deser and ser.</p>
  
  <p>This problem is related to this issue here:
  <a href="https://github.com/databricks/spark-avro/pull/73" rel="noreferrer">Avro Spark issue #73</a></p>
  
  <p>Which added differentiation of nested records with the same name by prepending the namespace with the outer record names. Their use case may be purely storage related so it may work for them but not for us.</p>
  
  <p>Does anybody know a better solution? Is this a hard limitation of Avro? </p>