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

How to deal with two classes with the same name #43

Open
jurgispods opened this issue Sep 26, 2017 · 1 comment
Open

How to deal with two classes with the same name #43

jurgispods opened this issue Sep 26, 2017 · 1 comment

Comments

@jurgispods
Copy link

Hi,

first of all: great plugin! I'm trying to use it within the context of generating case classes for objects stored in Kafka messages. I have no direct way of modifying the schema, and of of those schemas has a nested record with the same name of the root record. Like so:

{
  "type" : "record",
  "name" : "Order",
  "namespace" : "my.namespace1",
  "fields" : [ {
    "name" : "id",
    "type" : "string"
  }, {
    "name" : "timestamp",
    "type" : "long"
  }, {
    "name" : "source",
    "type" : "string"
  }, {
    "name" : "type",
    "type" : "string"
  }, {
    "name" : "payload",
    "type" : {
      "type" : "record",
      "name" : "Order",
      "namespace" : "my.namespace2",
      "fields" : [ 
         // some fields
      ]
  }
}

When I use your plugin to generate the Scala class hierarchy, I end up with a top-level case class that looks like this:

/** MACHINE-GENERATED FROM AVRO SCHEMA. DO NOT EDIT DIRECTLY */
package my.namespace1

import my.namespace2.Order

case class Order(id: String, timestamp: Long, source: String, `type`: String, payload: Order)

As you can see, the imported my.namespace2.Order shadows the definition of the case class my.namespace1.Order itself.

Any idea how to deal with this kind of situation?

@julianpeeters
Copy link
Owner

Thank you very much for reporting this. I think a sensible solution would be to forego the cleanliness the imports, and use fully-qualified names the the type positions. While I don't expect the fix to be terribly involved, unfortunately my timeframe is uncertain, likely on a "months" scale.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants