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.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Recent changes to the semantic model and the interpretation of view declarations necessitate the return of the
DETACHEDkeyword.To recap, view declarations in the
WITHclause 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 := Exprmeans "treat every occurrence ofIdentasExprliterally, but interpretExprusing 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 theSELECTbody are in the same scope.So, basically, we need the
DETACHEDkeyword back:The general form is
DETACHED Expr, which means "interpretExprin 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