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

JSON referenced schema support #1514

Merged
merged 14 commits into from
Apr 4, 2023
Merged

JSON referenced schema support #1514

merged 14 commits into from
Apr 4, 2023

Conversation

anchitj
Copy link
Member

@anchitj anchitj commented Feb 2, 2023

Changes to support referenced schemas in JSON schema.

Referenced schemas are always assumed to be registered in the SR prior.

@anchitj anchitj force-pushed the referencedJsonTest branch 2 times, most recently from ea82e94 to f50d5f6 Compare March 2, 2023 11:49
@anchitj anchitj changed the title [WIP] JSON referenced schema support JSON referenced schema support Mar 2, 2023
@anchitj anchitj marked this pull request as ready for review March 2, 2023 12:03
@anchitj anchitj requested a review from a team as a code owner March 2, 2023 12:03
@anchitj anchitj force-pushed the referencedJsonTest branch from f50d5f6 to e19e9d7 Compare March 3, 2023 06:57
@anchitj anchitj requested review from emasab and pranavrth March 3, 2023 06:57
@anchitj anchitj force-pushed the referencedJsonTest branch 2 times, most recently from fd856a8 to 2f01818 Compare March 3, 2023 07:01
@anchitj anchitj force-pushed the referencedJsonTest branch from 2f01818 to 6f189ff Compare March 3, 2023 07:52
Copy link
Member

@pranavrth pranavrth left a comment

Choose a reason for hiding this comment

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

Add changelog.

src/confluent_kafka/schema_registry/json_schema.py Outdated Show resolved Hide resolved
if named_schemas is None:
named_schemas = {}
for ref in schema.references:
referenced_schema = schema_registry_client.get_version(ref.subject, ref.version)
Copy link
Member

Choose a reason for hiding this comment

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

Can we use a batch call for fetching the references?

Copy link
Member Author

Choose a reason for hiding this comment

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

I checked on this, it doesn't looks like it's available directly through schema registry. https://docs.confluent.io/platform/current/schema-registry/develop/api.html#post--subjects-(string-%20subject)-versions

Copy link
Member

Choose a reason for hiding this comment

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

In that case, can we parallelize the calls? Maybe in future.

src/confluent_kafka/schema_registry/json_schema.py Outdated Show resolved Hide resolved
src/confluent_kafka/schema_registry/json_schema.py Outdated Show resolved Hide resolved
src/confluent_kafka/cimpl.py Outdated Show resolved Hide resolved
if named_schemas is None:
named_schemas = {}
for ref in schema.references:
referenced_schema = schema_registry_client.get_version(ref.subject, ref.version)
Copy link
Member

Choose a reason for hiding this comment

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

In that case, can we parallelize the calls? Maybe in future.

src/confluent_kafka/schema_registry/json_schema.py Outdated Show resolved Hide resolved
src/confluent_kafka/schema_registry/json_schema.py Outdated Show resolved Hide resolved
src/confluent_kafka/schema_registry/json_schema.py Outdated Show resolved Hide resolved
src/confluent_kafka/schema_registry/json_schema.py Outdated Show resolved Hide resolved
src/confluent_kafka/schema_registry/json_schema.py Outdated Show resolved Hide resolved
@pranavrth
Copy link
Member

Fix build issues as well

@anchitj anchitj requested a review from pranavrth April 3, 2023 09:13
Copy link
Member

@pranavrth pranavrth left a comment

Choose a reason for hiding this comment

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

Write some more tests. Unit test. Negative integration test.

CHANGELOG.md Outdated Show resolved Hide resolved
src/confluent_kafka/schema_registry/json_schema.py Outdated Show resolved Hide resolved
src/confluent_kafka/schema_registry/json_schema.py Outdated Show resolved Hide resolved
src/confluent_kafka/schema_registry/json_schema.py Outdated Show resolved Hide resolved
src/confluent_kafka/schema_registry/json_schema.py Outdated Show resolved Hide resolved
src/confluent_kafka/schema_registry/json_schema.py Outdated Show resolved Hide resolved
src/confluent_kafka/schema_registry/json_schema.py Outdated Show resolved Hide resolved
src/confluent_kafka/schema_registry/json_schema.py Outdated Show resolved Hide resolved
@anchitj
Copy link
Member Author

anchitj commented Apr 3, 2023

Write some more tests. Unit test. Negative integration test.

Added a unit test. I believe the existing tests should cover the added code. Please let me know if you want me to add some more specific tests.

@anchitj anchitj requested a review from pranavrth April 4, 2023 06:35
Copy link
Member

@pranavrth pranavrth left a comment

Choose a reason for hiding this comment

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

I would like a thorough test cases for this. Might be out of the scope of this PR but can we add that as well to the jira that we are creating to fix issues in this code?

src/confluent_kafka/schema_registry/json_schema.py Outdated Show resolved Hide resolved
src/confluent_kafka/schema_registry/json_schema.py Outdated Show resolved Hide resolved
@anchitj anchitj requested a review from pranavrth April 4, 2023 07:48
Copy link
Member

@pranavrth pranavrth left a comment

Choose a reason for hiding this comment

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

LGTM!

Just check the docs.

raise ValueError(
"""schema_registry_client must be provided if "schema_str" is a Schema instance with references""")
else:
raise ValueError('You must pass either str or Schema')
Copy link
Contributor

Choose a reason for hiding this comment

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

ditto

Copy link
Member Author

Choose a reason for hiding this comment

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

Thx, I've updated this.

@anchitj anchitj requested review from pranavrth and emasab April 4, 2023 12:49
Copy link
Member

@pranavrth pranavrth left a comment

Choose a reason for hiding this comment

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

LGTM!

Remove this function and merge it.

@@ -43,6 +43,34 @@ def __exit__(self, *args):
return False


def _id_of(schema):
Copy link
Member

Choose a reason for hiding this comment

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

This function is not needed anymore!

Copy link
Member Author

Choose a reason for hiding this comment

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

Missed removing it. Updated now.

@anchitj anchitj merged commit c771e17 into master Apr 4, 2023
@anchitj anchitj deleted the referencedJsonTest branch April 4, 2023 14:02
emasab pushed a commit that referenced this pull request Jun 19, 2023
* JSON referenced schema support

* Changes

* PR Feedback

* PR Feedback

* PR Feedback

* PR Feedback

* Fix wrong documentation

* PR Feedback

* Update unit tests

* PR Feedback

* Use ref.name as the id

* Remove _id_of function
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

Successfully merging this pull request may close these issues.

3 participants