| I think you are missing an important point in this: multiple subtypes can define properties with the same name, which can be of different types, be stored in different columns or even in different tables. In my opinion, TREAT(b AS SubType1).subValue1 can result in a value iif b is of type SubType1. Whether this should result in row-filtering, should be made clear in the spec. I tend to go for your option, but with quite different SQL:
CASE WHEN DTYPE = 'SubType1' THEN subValue1 ELSE NULL END
This will result in an actual value only for SubType1 and null for all other types. |