Skip to content

Commit

Permalink
Minor rename union_is_exhaustive (#7007)
Browse files Browse the repository at this point in the history
  • Loading branch information
aljazerzen authored Mar 8, 2024
1 parent ecabd12 commit 093c00d
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 32 deletions.
4 changes: 2 additions & 2 deletions edb/ir/ast.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ class TypeRef(ImmutableBase):
union: typing.Optional[typing.FrozenSet[TypeRef]] = None
# Whether the union is specified by an exhaustive list of
# types, and type inheritance should not be considered.
union_is_concrete: bool = False
union_is_exhaustive: bool = False
# If this is an intersection type, this would be a set of
# intersection elements.
intersection: typing.Optional[typing.FrozenSet[TypeRef]] = None
Expand Down Expand Up @@ -239,7 +239,7 @@ class BasePointerRef(ImmutableBase):
children: typing.FrozenSet[BasePointerRef] = frozenset()
union_components: typing.Optional[typing.Set[BasePointerRef]] = None
intersection_components: typing.Optional[typing.Set[BasePointerRef]] = None
union_is_concrete: bool = False
union_is_exhaustive: bool = False
has_properties: bool = False
is_derived: bool = False
is_computable: bool = False
Expand Down
58 changes: 31 additions & 27 deletions edb/ir/typeutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,10 +313,10 @@ def _typeref(
schema)
for c in union_of.objects(schema)
}
non_overlapping, union_is_concrete = (
non_overlapping, union_is_exhaustive = (
s_utils.get_non_overlapping_union(schema, union_types)
)
if union_is_concrete:
if union_is_exhaustive:
non_overlapping = frozenset({
t for t in non_overlapping
if t.is_material_object_type(schema)
Expand All @@ -326,7 +326,7 @@ def _typeref(
_typeref(c) for c in non_overlapping
)
else:
union_is_concrete = False
union_is_exhaustive = False
union = None

intersection_of = t.get_intersection_of(schema)
Expand Down Expand Up @@ -399,7 +399,7 @@ def _typeref(
children=children,
ancestors=ancestors,
union=union,
union_is_concrete=union_is_concrete,
union_is_exhaustive=union_is_exhaustive,
intersection=intersection,
element_name=_name,
is_scalar=t.is_scalar(),
Expand Down Expand Up @@ -657,7 +657,7 @@ def ptrref_from_ptrcls(

union_components: Optional[Set[irast.BasePointerRef]] = None
union_of = ptrcls.get_union_of(schema)
union_is_concrete = False
union_is_exhaustive = False
if union_of:
union_ptrs = set()

Expand All @@ -666,9 +666,11 @@ def ptrref_from_ptrcls(
schema, material_comp = component.material_type(schema)
union_ptrs.add(material_comp)

non_overlapping, union_is_concrete = s_utils.get_non_overlapping_union(
schema,
union_ptrs,
non_overlapping, union_is_exhaustive = (
s_utils.get_non_overlapping_union(
schema,
union_ptrs,
)
)

union_components = {
Expand Down Expand Up @@ -740,25 +742,27 @@ def ptrref_from_ptrcls(
else:
children = frozenset()

kwargs.update(dict(
out_source=out_source,
out_target=out_target,
name=ptrcls.get_name(schema),
shortname=ptrcls.get_shortname(schema),
std_parent_name=std_parent_name,
source_ptr=source_ptr,
base_ptr=base_ptr,
material_ptr=material_ptr,
children=children,
is_derived=ptrcls.get_is_derived(schema),
is_computable=ptrcls.get_computable(schema),
union_components=union_components,
intersection_components=intersection_components,
union_is_concrete=union_is_concrete,
has_properties=ptrcls.has_user_defined_properties(schema),
in_cardinality=in_cardinality,
out_cardinality=out_cardinality,
))
kwargs.update(
dict(
out_source=out_source,
out_target=out_target,
name=ptrcls.get_name(schema),
shortname=ptrcls.get_shortname(schema),
std_parent_name=std_parent_name,
source_ptr=source_ptr,
base_ptr=base_ptr,
material_ptr=material_ptr,
children=children,
is_derived=ptrcls.get_is_derived(schema),
is_computable=ptrcls.get_computable(schema),
union_components=union_components,
intersection_components=intersection_components,
union_is_exhaustive=union_is_exhaustive,
has_properties=ptrcls.has_user_defined_properties(schema),
in_cardinality=in_cardinality,
out_cardinality=out_cardinality,
)
)

ptrref = ircls(**kwargs)

Expand Down
6 changes: 3 additions & 3 deletions edb/pgsql/compiler/relctx.py
Original file line number Diff line number Diff line change
Expand Up @@ -1677,14 +1677,14 @@ def range_for_typeref(
for child in typeref.union:
mat_child = child.material_type or child
if mat_child.id in seen:
assert typeref.union_is_concrete
assert typeref.union_is_exhaustive
continue
seen.add(mat_child.id)

c_rvar = range_for_typeref(
child,
path_id=path_id,
include_descendants=not typeref.union_is_concrete,
include_descendants=not typeref.union_is_exhaustive,
for_mutation=for_mutation,
dml_source=dml_source,
lateral=lateral,
Expand Down Expand Up @@ -1957,7 +1957,7 @@ def range_for_ptrref(
overlays = get_ptr_rel_overlays(
ptrref, dml_source=dml_source, ctx=ctx)

include_descendants = not ptrref.union_is_concrete
include_descendants = not ptrref.union_is_exhaustive

assert isinstance(ptrref.out_source.name_hint, sn.QualName)
# expand_inhviews helps support EXPLAIN. see
Expand Down

0 comments on commit 093c00d

Please sign in to comment.