Duplicate objects in results #5278
Replies: 7 comments
-
To clarify, the current implementation will return a single User object for both of the above queries. The question is about the correct understanding of the updated model that we're supposed to be implementing. |
Beta Was this translation helpful? Give feedback.
-
After extended discussion the solution to the problem is to detect ambiguous usage of the same symbolic name. According to our design, we always want it to be true that the same symbolic name means the same thing everywhere in the expression. The problematic examples above, in fact, break that rule. A symbolic name is unambiguous if:
These rules guarantee that the elements of the set denoted by the symbol are well-defined and can be iterated over in the context of the expression. The original problems arose from the attempt to resolve these kind of ambiguous definitions in an element-wise context ( The two kinds of examples that illustrate the problem involve
We cannot unambiguosly determine whether this means "produce duplicate User results with a different single Issue.id as a computable foo" (element-wise on |
Beta Was this translation helpful? Give feedback.
-
It occurs to me that we're on the right track here, but we may need to more closely look at the element-wise functions. Specifically whether or not their arguments are defined in the same scope level or nested scopes. At the same scope level (e.g. tuples) we are happy enough to produce cross-products and let one element-wise argument affect the interpretation of the other arguments. When the arguments are defined in different scope levels (shapes, We have a different expectation for what these two element-wise functions should do:
|
Beta Was this translation helpful? Give feedback.
-
I think the new rule is a sufficient guarantee that a nested scope does not affect the interpretation of the outer scope. In the last example, only the first expression would compile. |
Beta Was this translation helpful? Give feedback.
-
OK, so the general rule that we have is that the interpretation of a symbol in a scope cannot be altered by any nested scope. If a use of a symbol in a nested scope is not compatible with the use in the current scope that is an error. How do we detect that a symbol is compatible:
In the future we may relax these requirements slightly by noting that required 1-1 links generate a new symbol that is equivalent to its prefix as far as element-wise usage is concerned. This would allow something like this:
It is important to note that Another note is that the link operator is special because it's the only operator that takes both the graph and its contents into account. It can behave as either an element-wise (for "11" and "1*") or a |
Beta Was this translation helpful? Give feedback.
-
There's an update to when the above rule is used: it's only necessary for clauses. Mathematically we're perfectly happy to refactor any arbitrary longest common prefix from any arbitrary combination of functions. However, clauses are meant to behave like data pipelines, where the preceding data is not altered by what is written in the next clause (so a |
Beta Was this translation helpful? Give feedback.
-
Shapes also have this type of behavior (the innards of the shape should not affect the shape's root interpretation), so the rule applies to them as well. |
Beta Was this translation helpful? Give feedback.
-
One of the recent updates makes it so that
UNION
allows duplicate objects. We also useUNION
as the implicit operator that joins the results of element-wise functions.Consider the following setup:
Now consider the following 2 queries:
The second of the queries should produce a multi-set of 3 identical User objects (all of them being Elvis). The reason is that the query itself is a function that is element-wise w.r.t.
SELECT
clause andSET OF
w.r.t.FILTER
clause. So since the clauses both refer to related sets (have symbolically same prefixes) we need to apply our rules for refactoring the longest common prefix. It happens to beIssue
. So in the end we end up evaluatingSELECT
clause for eachIssue
, getting the same User object, and then including it in the result (using an implicitUNION
) since theFILTER
evaluates to true for eachIssue
as well.One of the odd features of this is that counter-intuitively we increased the result set cardinality by applying a
FILTER
vs. not having anyFILTER
at all.Beta Was this translation helpful? Give feedback.
All reactions