The TRANSFORM operator. An invocation of TRANSFORM is equivalent to a longer expression involving
PROJECT
,
EXTEND
and
RENAME
as follows : Transform takes two arguments : the first being a relational expression, and the second a list of transform specs. So an invocation of TRANSFORM looks like TRANSFORM(<Relational Expression>,(<transform spec list>)). <transform spec list> is a list of attribute computation specifications, an
attribute computation specification mentioning the attribute name for the relation produced, and an expression defining how to compute the value for a particular tuple in the result.
So a transform spec looks like <AttributeName>(<Expression>). The expression can be omitted, in which case it defaults to <AttributeName>. The resulting relation has all and exactly those attributes in its heading that are mentioned in the transform spec list. The value for each of those attributes is the value obtained by evaluating the expression corresponding to the attribute name in the transform spec list. TRANSFORM thus "bundles" the semantics of
EXTEND, RENAME and PROJECT as follows :
- It "adds" the attributes that are specified as ATTRIBUTENAME(some operator invocation) just as
EXTEND
does
- It "removes" the attributes that are not specified just as
PROJECT
does
- It "alters" the names of the attributes that are specified as ATTRIBUTENAME(OTHERATTRIBUTENAME) just as
RENAME
does
Note that TRANSFORM is effectively implemented as the invocation of some projection of some extension of the input expression : TRANSFORM(R,...) === PROJECT(EXTEND(R,...),(...)), in which the first ellipsis stands for all <transform spec>s that include an expression, and the second for all attribute names mentioned in any <transform spec>. This implies that all the semantical rules of extend and project apply INDIVIDUALLY. In particular : this makes transform
specs such as A(PLUS(A,A)) invalid because that would make an attribute named 'A' appear twice in the result of the extend. Note also that while A(B) is valid as a transform
spec (achieving the same result as RENAME if attribute B is not mentioned), the combination A(B)B(A) is invalid, while this same combination in an invocation of RENAME is valid (thereby achieving the result of the two attributes "swapping" values).