cuboid()

Read(1947) Label: cuboid,

Here’s how to use cuboid() function.

T.cuboid(f,F i ,…;y,…)

Description:

Generate preaggregation file for a composite table/multizone composite table.

Syntax:

T.cuboid(f,Fi,…;y,…)

Note:

The function generates preaggregation file f for composite table/multizone composite table T. The preaggregation file will not update itself accordingly when the composite table is updated.

Parameter:

T

A composite table/multizone composite table

f

Preaggregation file object

Fi

Grouping field

y

Aggregate expression; aggregate functions supported are sum/count/avg/max/min/top

Return value:

Preaggregation file name

Example:

 

A

 

1

=file("empcub.ctx")

 

2

=A1.create@y(#EID,NAME,GENDER,DEPT,SALARY,BIRTHDAY)

Create a composite table file.

3

=demo.cursor("select  EID,NAME,GENDER,DEPT,SALARY,BIRTHDAY from employee ")

Return a table sequence:

4

=A2.append(A3)

Append table sequence A3’s data to the composite table.

5

=file("cub1")

Preaggregation file object.

6

=A2.cuboid(A5,DEPT,GENDER;avg(age(BIRTHDAY)),count(EID))

Generate preaggregation file cub1 for the composite table file, where DEPT and GENDER are grouping fields, and compute average age and find the number of employees in each group.

7

=A2.cgroups(DEPT,GENDER;avg(age(BIRTHDAY)):AvgAge,count(EID):IdNum;;A5)

Use the preaggregation file to perform grouping & aggregation on the composite table and return following result: