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

fix: Allow Singer schemas to include the required and enum fields #917

Merged

Conversation

Jack-Burnett
Copy link
Contributor

@Jack-Burnett Jack-Burnett commented Aug 19, 2022

Closes #901

The use of the Schema class from a dependency was limiting schemas to only include certain declared json schema fields, since it would remove properties if they were not whitelisted.
 Since this is from a dependency, we can't simply expand the whitelist so instead we override the class and expand the list there.
An alternative implementation would be to simply replace the class outright (no inheritance) - this could break existing taps that pass a Schema to Stream.init though.

It helps with but does not close #332, since 332 is asking for helpers, which this does not add - it makes it possible to add them though.

I think there are lots more improvements that could be made to SchemaPlus in follow-up PRs (adding many more legitimate properties to the whitelist and having better support for some non-simple properties.

Also, I removed the 'selected' and 'inclusion' fields from the new class - because they are part of the singer spec and not actually valid fields to see on a json schema.

@codecov
Copy link

codecov bot commented Aug 19, 2022

Codecov Report

Merging #917 (6689f4e) into main (52db6ec) will increase coverage by 0.26%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main     #917      +/-   ##
==========================================
+ Coverage   80.40%   80.66%   +0.26%     
==========================================
  Files          34       35       +1     
  Lines        3429     3476      +47     
  Branches      681      692      +11     
==========================================
+ Hits         2757     2804      +47     
  Misses        499      499              
  Partials      173      173              
Impacted Files Coverage Δ
singer_sdk/helpers/_schema.py 100.00% <100.00%> (ø)
singer_sdk/helpers/_singer.py 96.40% <100.00%> (ø)
singer_sdk/streams/core.py 81.21% <100.00%> (ø)
singer_sdk/streams/sql.py 78.70% <100.00%> (ø)

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@edgarrmondragon
Copy link
Collaborator

Hi @Jack-Burnett! Thanks for the PR. I'll take a look in the next few days 😺

@edgarrmondragon edgarrmondragon changed the title fix: Allow schemas to include the 'required' and 'enum' fields. fix: Allow schemas to include the 'required' and 'enum' fields Aug 24, 2022
singer_sdk/helpers/_schema.py Outdated Show resolved Hide resolved
singer_sdk/helpers/_schema.py Outdated Show resolved Hide resolved
Copy link
Collaborator

@edgarrmondragon edgarrmondragon left a comment

Choose a reason for hiding this comment

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

@Jack-Burnett this is looking great!

I initially missed those pylint comments which we don't need. Once that's addressed this is g2g 🙂

singer_sdk/helpers/_schema.py Outdated Show resolved Hide resolved
singer_sdk/helpers/_schema.py Outdated Show resolved Hide resolved
singer_sdk/helpers/_schema.py Outdated Show resolved Hide resolved
singer_sdk/helpers/_schema.py Outdated Show resolved Hide resolved
Jack-Burnett and others added 5 commits August 24, 2022 17:47
Co-authored-by: Edgar R. M. <edgarrm358@gmail.com>
Co-authored-by: Edgar R. M. <edgarrm358@gmail.com>
Co-authored-by: Edgar R. M. <edgarrm358@gmail.com>
Co-authored-by: Edgar R. M. <edgarrm358@gmail.com>
@edgarrmondragon edgarrmondragon changed the title fix: Allow schemas to include the 'required' and 'enum' fields fix: Allow Singer schemas to include the 'required' and 'enum' fields Aug 24, 2022
@edgarrmondragon edgarrmondragon changed the title fix: Allow Singer schemas to include the 'required' and 'enum' fields fix: Allow Singer schemas to include the required and enum fields Aug 24, 2022
@Jack-Burnett
Copy link
Contributor Author

@Jack-Burnett this is looking great!

I initially missed those pylint comments which we don't need. Once that's addressed this is g2g 🙂

Ohh yeah just lazy copy-pasting on my part 😅 All gone now

@edgarrmondragon
Copy link
Collaborator

Thank you @Jack-Burnett!

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