Skip to content

PartiQL Shape union doesn't unify #486

@jpschorr

Description

@jpschorr

After #485 PartiqlShapeBuilder.any_of:

    pub fn any_of<I>(&self, types: I) -> PartiqlShape
    where
        I: IntoIterator<Item = PartiqlShape>,
    {
        let any_of = AnyOf::from_iter(types);
        match any_of.types.len() {
            0 => type_dynamic!(),
            1 => {
                let AnyOf { types } = any_of;
                types.into_iter().next().unwrap()
            }
            // TODO figure out what does it mean for a Union to be nullable or not
            _ => PartiqlShape::AnyOf(any_of),
        }
    }

The AnyOf::from_iter(types) uses an IndexSet internally to deduplicate types, thus the match on any_of.types.len() could "flatten" AnyOfs that had duplicates. With the addition of IDs, this deduplication no longer happens...

Originally posted by @jpschorr in #485 (review)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions