Empty label expressions and views

Поиск
Список
Период
Сортировка
Искать

Empty label expressions and views

От:
Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>
Дата:
Вложения:
Hi All,

This was earlier discussed in [1], but starting a new thread to discuss only this issue.

We create dependencies between a view and the labels specified in the label expressions in the view definition. An empty label expression resolves to a disjunction between all the labels. But since there is no explicit label mentioned we do not create dependency between any label and the view. Further adding and dropping labels in the property graph changes the element tables that are scanned by the query. That feels awkward - a user who created the view may not be expecting this change. Well, one can have the same effect if an existing label is associated with a new element table - but at least the user is aware of the effect when they add or remove a label to or from the element table. The awkwardness is arguable.

When we support all property references things need to change. An all property reference [1] is resolved to all the properties associated with all the labels specified in the element pattern. Since the shape of the view result depends upon the properties references in the COLUMNs clause, an all property reference can not be stored in the view definition as an all property reference. Instead the expanded form of all property reference needs to be stored in the catalog. This is in line with how we store a * in the target list in the view definition. This requires resolving an all property reference during transformation phase itself. This means that we have to resolve an empty label expression during the transformation phase itself. This, in turn, means an empty label expression in the view definition will be stored as disjunction of all labels in the catalogs. As explained earlier, this is different from what we do today and may result in a backward in-compatibility. So I think we should discuss whether we need to fix the empty label expression resolution now and avoid backward compatibility or tackle the problem when we will support all properties reference. Just backporting the changes to query transformation are not enough to fix the backward incompatibility since already created views won't be fixed that way - they will need to be recreated.

PFA the patch which fixes the transformation of empty label expression. The patch might need some work. The patch may be considered invasive at this late stage in the PG 19. For that reason I am fine to defer this to PG 20 or whenever we support all properties reference.


--
Best Wishes,
Ashutosh Bapat

Re: Empty label expressions and views

От:
Peter Eisentraut <peter@eisentraut.org>
Дата:
On 07.08.26 11:23, Ashutosh Bapat wrote:
> We create dependencies between a view and the labels specified in the 
> label expressions in the view definition. An empty label expression 
> resolves to a disjunction between all the labels. But since there is no 
> explicit label mentioned we do not create dependency between any label 
> and the view. Further adding and dropping labels in the property graph 
> changes the element tables that are scanned by the query. That feels 
> awkward - a user who created the view may not be expecting this change. 
> Well, one can have the same effect if an existing label is associated 
> with a new element table - but at least the user is aware of the 
> effect when they add or remove a label to or from the element table. The 
> awkwardness is arguable.

But this is how it is meant to work.  You are arguing that the set of 
labels should be frozen when the view is parsed, which could be equally 
confusing, considering that we don't prevent new labels from being added.

> When we support all property references things need to change. An all 
> property reference [1] is resolved to all the properties associated with 
> all the labels specified in the element pattern. Since the shape of the 
> view result depends upon the properties references in the COLUMNs 
> clause, an all property reference can not be stored in the view 
> definition as an all property reference. Instead the expanded form of 
> all property reference needs to be stored in the catalog. This is in 
> line with how we store a * in the target list in the view definition. 
> This requires resolving an all property reference during transformation 
> phase itself. This means that we have to resolve an empty label 
> expression during the transformation phase itself. This, in turn, means 
> an empty label expression in the view definition will be stored as 
> disjunction of all labels in the catalogs.

Maybe we need to do some more analysis on this chain of reasoning and 
where the problem lies.  I'm tempted to think that the way empty label 
expressions behave now is correct, and then the fix should lie in some 
other steps.



FAQ