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

Concatenate several schemas into a single one #36

Open
deponovo opened this issue Aug 5, 2020 · 1 comment
Open

Concatenate several schemas into a single one #36

deponovo opened this issue Aug 5, 2020 · 1 comment

Comments

@deponovo
Copy link

deponovo commented Aug 5, 2020

Hi,
it would be nice to have a __or__ method in the Schema class to concatenate schemas. I cannot create a branch for this in the mean time, but if somebody could, here is an implementation proposal.

class Schema:
    def __or__(self, other):
        if not isinstance(other, Schema):
            raise TypeError(f'{self.__class__.__name__} can only be concatenated with another `Schema`, found {type(other)}.'

        concat_columns = self.columns.extend(other.columns)
        concat_schemas = Schema(columns=concat_columns)
        return concat_schemas 
@multimeric
Copy link
Owner

I'll consider an implementation of this in the next major version.

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

No branches or pull requests

2 participants