project
The project operator produces a result array with the same dimensions as (but a subset of the attributes of)Â a source array.
Synopsis
project(source_array, attribute [,attribute]... [, inverse:true]);
Summary
The project operator produces a result array that includes some attributes of a source array but excludes others. You indicate which attributes to include by supplying their names with the attribute parameters. In the result array, the attributes appear in the order you name them as parameters.
You can use the project operator in the FROM clause of an AQL SELECT statement, as a stand-alone operator in an AFL statement, or as an operand within other SciDB operators.
When you specify the inverse: true keyword parameter, project excludes the named attributes instead of including them. The discard macro expands to project(..., inverse: true).
Examples
Using the Operator
To demonstrate project operator, do the following:
Create an array with three attributes:
AFL% store(apply(build(<x:int64>[i=0:5], i), y, 2*x, z, x+10), A); Query was executed successfully AFL% scan(A); {i} x,y,z {0} 0,0,10 {1} 1,2,11 {2} 2,4,12 {3} 3,6,13 {4} 4,8,14 {5} 5,10,15
Project to an array with a subset of the attribute:
AFL% project(A, y); {i} y {0} 0 {1} 2 {2} 4 {3} 6 {4} 8 {5} 10
Reorder the attributes, excluding one of them.
AFL% project(A, y, x); {i} y,x {0} 0,0 {1} 2,1 {2} 4,2 {3} 6,3 {4} 8,4 {5} 10,5
Use the inverse: keyword to discard the named attributes:
AFL% project(A, y, inverse:1); {i} x,z {0} 0,10 {1} 1,11 {2} 2,12 {3} 3,13 {4} 4,14 {5} 5,15
Use the discard macro to do the same thing:
AFL% discard(A, y); {i} x,z {0} 0,10 {1} 1,11 {2} 2,12 {3} 3,13 {4} 4,14 {5} 5,15
Remove the array:
AFL% remove(A);