table< T >¶
A tabular representation of the type T. The tabular result will contain columns of scalar types similar to a relational table.
Given an example such as:
entity Person key( Id : long ) {
Name : string
Age : int
Phone : list< string >
}
A example value of type table< Person > is represented as:
| Id :long | Name :string | Age :int | Phone_Id__ :int | Phone :string |
|---|---|---|---|---|
| 001 | Bob | 23 | 0 | 02930918290 |
| 001 | Bob | 23 | 1 | 02949084509 |
| 002 | Joe | 25 | 0 | 07940938092 |
The flatten rules are:
- A scalar becomes a column.
- Some flattening will result in auxiliary columns being added.
Auxiliary column is prefixed with string in form of ‘_usage__’ where
usageis replaced with an appropriate name given the context, such asindex. Naming conflicts are possible, for this reason, ALFA compiler reports a warning if fields are declared with 2 consecutive underscores, which may result in conflict with internally generated names. - A
map< K, V>becomes a minimum of 2 columns, more based on how K or V flatten. - The key and value fields of a map will name such that
KeyandValueare appended to the field name. - The default Map column names can be overridden by specifying them in the declaration -
map< KeyName : K, ValueName : V> - A
set< T >becomes a minimum of 2 columns, containing an _identity__ column and flattening for T - A
list< T >becomes a minimum of 2 columns, containing an _index__ column and flattening for T - When
Tis a trait, the set of columns are derived from the trait, however there can be more columns based on implementations of the trait. Therefore the columns is a union of all trait implementations. - An optional
T?value is represented by a minimum of 2 columns. An _isSet__ prefixed field and flattening for T.
Exhaustive list of all ALFA flattening for table
Optional Parameters
table< T >( ... )Optional named parameters can be specified to table to manipulate thetabletype. Currently the usage and types for the parameters are undefined.