Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avro regenerates referenced definitions #2264

Closed
cptaffe opened this issue Sep 24, 2019 · 1 comment · Fixed by #2267
Closed

Avro regenerates referenced definitions #2264

cptaffe opened this issue Sep 24, 2019 · 1 comment · Fixed by #2267
Assignees
Labels
bug Something isn't working

Comments

@cptaffe
Copy link

cptaffe commented Sep 24, 2019

In Scio 0.7.4, @AvroType.fromSchema regenerates case classes for previously seen definitions instead of reusing them, which breaks types which have multiple members of the same type.

@AvroType.fromSchema(
  """
  |{
  |  "type" : "record",
  |  "name" : "A",
  |  "fields" : [ {
  |    "name" : "a",
  |    "type" : {
  |      "type" : "record",
  |      "name" : "B",
  |      "fields" : [ ]
  |    }
  |  }, {
  |    "name" : "b",
  |    "type" : "B"
  |  } ]
  |}""".stripMargin
)
class ReuseDef

This example fails with:

ReuseDef$B is already defined as case class ReuseDef$B

avro-tool idl2schemata will generate this case from this IDL input:

protocol test {
  record B {}

  record A {
    B a;
    B b;
  }
}
@clairemcginty clairemcginty added the bug Something isn't working label Sep 24, 2019
@clairemcginty
Copy link
Contributor

thanks for reporting! We should probably add a check to the Avro TypeProvider that keeps track of previously seen record definitions.

@clairemcginty clairemcginty self-assigned this Sep 24, 2019
nevillelyh pushed a commit that referenced this issue Oct 1, 2019
…#2267)

* AvroType macro shouldn't generate duplicate record classes fix #2264)

* Apply suggestions from code review
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants