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

Add option in SchemaBuilder to ignore user defined json properties during codegen. #542

Closed
wants to merge 3 commits into from

Conversation

li-ukumar
Copy link
Member

What

Adding option to ignore json properties in SchemaBuilder

Why

During avro codegen, the if the generator detects conflicting defintions of a schema, where the filesystem definition is different from the one in classpath, it throws.
Relaxing this check by allowing the user to specify json properties to be ignored during this check.

It is useful if the duplicate schema is "almost" same but has certain properties which may store metadata for another flow.

Test

Added Sanity Unit test
build

@li-ukumar li-ukumar changed the title Add option in SchemaBuilder to ignore certail json properties during codegen. Add option in SchemaBuilder to ignore user defined json properties during codegen. Jan 19, 2024
@li-ukumar li-ukumar marked this pull request as draft January 19, 2024 19:37
@codecov-commenter
Copy link

codecov-commenter commented Jan 19, 2024

Codecov Report

Attention: 12 lines in your changes are missing coverage. Please review.

Comparison is base (f46f720) 46.15% compared to head (6656ce6) 46.17%.
Report is 1 commits behind head on master.

Files Patch % Lines
...1/compatibility/SchemaComparisonConfiguration.java 52.00% 12 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master     #542      +/-   ##
============================================
+ Coverage     46.15%   46.17%   +0.02%     
- Complexity     4534     4545      +11     
============================================
  Files           407      407              
  Lines         28393    28447      +54     
  Branches       4633     4634       +1     
============================================
+ Hits          13104    13135      +31     
- Misses        13721    13748      +27     
+ Partials       1568     1564       -4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Comment on lines 247 to 251
List<String> jsonPropsToIgnoreInCompare = new ArrayList<>();
if(options.has(jsonPropsToIgnoreInCompareOpt)) {
jsonPropsToIgnoreInCompare = options.valuesOf(jsonPropsToIgnoreInCompareOpt);
}

Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: change to:

List jsonPropsToIgnoreInCompare = options.has(jsonPropsToIgnoreInCompareOpt) ? options.valuesOf(jsonPropsToIgnoreInCompareOpt) : Collections.emptyList();

@@ -238,6 +244,11 @@ public static void main(String[] args) throws Exception {
skipCodegenIfSchemaOnClasspath = Boolean.TRUE.equals(Boolean.parseBoolean(value));
}

List<String> jsonPropsToIgnoreInCompare = new ArrayList<>();
Copy link
Collaborator

Choose a reason for hiding this comment

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

I saw eventually you have this as a HashSet. why not have it as a Set at the beginning?

@karthikrg
Copy link
Contributor

I don't advise doing this. If folks rely on reading these properties from runtime schema they may get nasty surprises.

@li-ukumar li-ukumar closed this Feb 12, 2024
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.

4 participants