It depends on what you mean with 'filtering of subtypes'. I think the spec is clear enough in that it states That is, [...] in the case of a restriction, the associated predicate is false.. For the restriction treat(e as SubType1).subvalue1 = 100, this means it should only be true when e is SubType1 and subvalue1 = 100. Negated, this means it should be true when e is not SubType1 or subvalue1 <> 100. Depending on how you use these restrictions in your WHERE clause, this will or will not result in filtering. IMHO the 'true' filtering only applies to the FROM clause and JOINs. I do not agree with you that the 3rd testcase is invalid. The spec never forbids using properties from a supertype. Neither the treat, nor the property dereference therefore is invalid. Given the definition of the treat operator, it should evaluate to true iff e is of type SubType1. In general, I feel treats should be resolved like this:
- In the FROM clause (and JOINs), rows must be filtered on the subtype
- In the WHERE clause (and JOIN ON), predicates must evaluate to false when the type does not match. This can be accomplished by automatically convert treat(e as X) to (type(e) IN (X+subtypes of X) and treat(e as X)).
- In the SELECT clause, treats should not be allowed or result in NULL values
|