Membership: #

Syntax

ds # comp

Input parameters

ds

the Data Set

cop

the Data Set Component

Semantics for scalar operations

This operator cannot be applied to scalar values.

Input parameters type

ds

dataset

comp

name<component>

Result type

result

dataset

Additional Constraints

comp must be a Data Set Component of the Data Set ds.

Behaviour

The membership operator returns a Data Set having the same Identifier Components of ds and a single Measure. If comp is a Measure in ds, then comp is maintained in the result while all other Measures are dropped. If comp is an Identifier or an Attribute Component in ds, then all the existing Measures of ds are dropped in the result and a new Measure is added. The Data Points’ values for the new Measure are the same as the values of comp in ds. A default conventional name is assigned to the new Measure depending on its type: for example num_var if the Measure is numeric, string_var if it is string and so on (the default name can be renamed through the rename operator if needed). The Attributes follow the Attribute propagation rule as usual (viral Attributes of ds are maintained in the result as viral, non-viral ones are dropped). If comp is an Attribute, it follows the Attribute propagation rule too. The same symbol denoting the membership operator (#) is also used inside other operations at Component level (for example in join, calc, aggr) in order to identify the Components to be operated: please note that in these cases the symbol # does not denote the membership operator (i.e., this operator, which does not operate at Component level), but a special keyword of the syntax of the other operator in which it is used.

Examples

Given the operand datasets DS_1 and DS_2, where the attribute component At_1 is viral for DS_2 and non-viral for DS_1:

Input DS_1 (see structure)

Id_1

Id_2

Me_1

Me_2

At_1

1

A

1

5

1

B

2

10

P

2

A

3

12

Input DS_2 (see structure)

Id_1

Id_2

Me_1

Me_2

At_1

1

A

1

5

1

B

2

10

P

2

A

3

12

Example 1

DS_r := DS_1#Me_1;

results in (see structure):

DS_r

Id_1

Id_2

Me_1

1

A

1

1

B

2

2

A

3

Example 2

DS_r := DS_1#Id_1;

results in (see structure):

DS_r

Id_1

Id_2

int_var

1

A

1

1

B

1

2

A

2

Example 3

DS_r := DS_1#At_1;

results in (see structure):

DS_r

Id_1

Id_2

string_var

1

A

1

B

P

2

A

Example 4

DS_r := DS_2#Me_1;

results in (see structure):

DS_r

Id_1

Id_2

Me_1

At_1

1

A

1

1

B

2

P

2

A

3

Example 5

DS_r := DS_2#Id_1;

results in (see structure):

DS_r

Id_1

Id_2

int_var

At_1

1

A

1

1

B

1

P

2

A

2

Example 6

DS_r := DS_2#At_1;

results in (see structure):

DS_r

Id_1

Id_2

string_var

At_1

1

A

1

B

P

P

2

A