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 support for optional objects in lists + Add support for optional lists of (optional) objects #43

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

chidifrank
Copy link

Adds support for optional objects in lists & Add support for optional lists of (optional) objects

  1. Generating the spark schema for array columns that contain optional objects used to result in errors.

The script would try to get the items for array types but if you have an array with optional object elements it would result in a NotImplementedError since the type and ref would be None. The ref would reside in anyOf which would contain $ref

class OptionalObjectsInArray(SparkBase):
    c1: List[Optional[Nested2Model]]

OptionalObjectsInArray.spark_schema()
> `NotImplementedError`
  1. Generating the spark schema for optional array columns that contain (optional) objects used to result in an Attribute error, since the array field would not have the attribute items it would have the attribute anyOf which would contain items
class OptionalArrayOfArraysWithOptionalObjectsInArray(SparkBase):
    c1: Optional[List[OptionalObjectsInArray]]

OptionalArrayOfArraysWithOptionalObjectsInArray.spark_schema()
> `AttributeError: 'NoneType' object has no attribute 'get'`

@arcaputo3
Copy link

This is a fantastic change; currently installing from this branch! Please merge :)

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