The return of DETACHED #5279
Replies: 4 comments
-
|
Beta Was this translation helpful? Give feedback.
-
I also happen to like the explicitness of |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
It is important that the |
Beta Was this translation helpful? Give feedback.
-
Recent changes to the semantic model and the interpretation of view declarations necessitate the return of the
DETACHED
keyword.To recap, view declarations in the
WITH
clause are no longer interpreted as a computation of a set in a nested scope. Instead, we define the turnstile operator (:=
) as the "lexical equivalence" operator. TheIdent := Expr
means "treat every occurrence ofIdent
asExpr
literally, but interpretExpr
using the context captured at the site of the declaration".Essentially, views become a pure refactoring tool, and so the following query
is perfectly equivalent to
This new interpretation is vital to the usefulness of views, as we now have the "nested scope must not affect outer scopes" rule, so the old "nested scope" views would be unusable in many cases.
However, the original "nested scope" interpretation was necessary to support the "detached set" case:
Now,
WITH I := Issue SELECT (I, Issue)
is perfectly equivalent toSELECT (Issue, Issue)
, which, obviously, would not result in a Cartesian product. This is because both the view declaration and theSELECT
body are in the same scope.So, basically, we need the
DETACHED
keyword back:The general form is
DETACHED Expr
, which means "interpretExpr
in a completely detached scope". This is equivalent to how schema-level link computables and schema-level views are interpreted.Beta Was this translation helpful? Give feedback.
All reactions