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

Wrong nullable schemas with enum cannot evolve #617

Closed
gmcoringa opened this issue Nov 12, 2019 · 3 comments
Closed

Wrong nullable schemas with enum cannot evolve #617

gmcoringa opened this issue Nov 12, 2019 · 3 comments

Comments

@gmcoringa
Copy link

With version 0.5.6 was possible to create schemas with enum like this:

  {
   "name": "suit",
   "default": null,
   "type":{
      "type": "enum",
      "name": "Suit",
      "namespace": "com.mycompany",
      "symbols": ["SPADES", "HEARTS", "DIAMONDS", "CLUBS"]
    }
  },

Note that the null declaration is invalid.
With avro 1.9.1 this cannot be used anymore, and when you try to fix it in schema registry you cant, because the old schema is validate:

! org.apache.avro.AvroTypeException: Invalid default for field suit: null not a {"type":"enum","name":"Suit","namespace":"com.mycompany","symbols":["SPADES", "HEARTS", "DIAMONDS", "CLUBS"]}
! at org.apache.avro.Schema.validateDefault(Schema.java:1542)
! at org.apache.avro.Schema.access$500(Schema.java:87)
! at org.apache.avro.Schema$Field.<init>(Schema.java:523)
! at org.apache.avro.Schema.parse(Schema.java:1649)
! at org.apache.avro.Schema$Parser.parse(Schema.java:1396)
! at org.apache.avro.Schema$Parser.parse(Schema.java:1384)
! at com.hortonworks.registries.schemaregistry.avro.AvroSchemaProvider.checkCompatibility(AvroSchemaProvider.java:67)
! at com.hortonworks.registries.schemaregistry.SchemaVersionLifecycleManager.checkCompatibility(SchemaVersionLifecycleManager.java:477)
! at com.hortonworks.registries.schemaregistry.SchemaVersionLifecycleManager.checkCompatibility(SchemaVersionLifecycleManager.java:452)
! at com.hortonworks.registries.schemaregistry.DefaultSchemaRegistry.checkCompatibility(DefaultSchemaRegistry.java:833)
! at com.hortonworks.registries.schemaregistry.webservice.SchemaRegistryResource.checkCompatibilityWithSchema(SchemaRegistryResource.java:908)
! at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
! at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
! at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
! at java.lang.reflect.Method.invoke(Method.java:498)
! at org.glassfish.jersey.server.model.internal.ResourceMethodInvocationHandlerFactory$1.invoke(ResourceMethodInvocationHandlerFactory.java:81)

Is there any workaround to avoid this?

@raju-saravanan
Copy link
Collaborator

@gmcoringa Once you have added schema into schema registry you can't modify it through UI. I don't see any other way apart from updating the schema in the database directly. You can look for "schemaText" column for the table "schema_version_info" and make your changes there.

@gmcoringa
Copy link
Author

@raju-saravanan thanks for the hint, also I will have to update all versions, because the default validation level is ALL, so if any version of a schema is invalid there is no way to get using schema registry client or update the schema.

@gcsaba2
Copy link
Contributor

gcsaba2 commented Oct 5, 2022

Duplicate of #621

@gcsaba2 gcsaba2 marked this as a duplicate of #621 Oct 5, 2022
@gcsaba2 gcsaba2 closed this as completed Oct 5, 2022
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

3 participants