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

[improve][docs] Add schema compatibility between Go and Java client #656

Closed
wants to merge 2 commits into from

Conversation

liangyepianzhou
Copy link
Contributor

@liangyepianzhou liangyepianzhou commented Jul 27, 2023

original PR: apache/pulsar-client-go#1056

  • doc
  • doc-required
  • doc-not-needed
  • doc-complete

@github-actions github-actions bot added the doc Improvements or additions to documentation label Jul 27, 2023
@Anonymitaet
Copy link
Member

@BewareMyPower @shibd
Could you please help review this PR? Thank you!

],
"name":"MyAvro","namespace":"schemaNotFoundTestCase","type":"record"}`, nil)
// Not compatible with defining a schema in Java
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this refer to the following Java example?

If the Go Client is used like this, the Java client should also support it, right?

In java client, there are two ways:

  1. Use SchemaDefinition to set schema JsonDef
          String jsonDef = "{"fields":[{"name":"id","type":"int"},{"default":null,"name":"name","type":["null","string"]}],"name":"MyAvro","namespace":"schemaNotFoundTestCase","type":"record"}"
           Schema schema = Schema.AVRO(SchemaDefinition.builder().withJsonDef("").build());
  1. Or, to set not allow field is null.
      SchemaDefinition<Example> schemaDefinition =
                     SchemaDefinition.builder().withPojo(Example.class).withAlwaysAllowNull(false).build();
      Schema schema = Schema.AVRO(schemaDefinition);
      
    Producer<Example> producer = pulsarClient.newProducer(schema)
                .topic(topic).create();

we should show the solution.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, you are right.


consumerJSCompatible := NewJSONSchema(exampleSchemaDefCompatible, nil)
// Not compatible with defining a schema in Java
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which define code of Java is this incompatible with?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Like Avro, is a problem with null fields.

@tisonkun tisonkun changed the title [optimize][schema] Add schema compatibility between Go and Java client [improve][docs] Add schema compatibility between Go and Java client Aug 8, 2023
@tisonkun tisonkun deleted the go_schema branch August 27, 2023 11:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
doc Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants