attributes

metThe attributes operator produces a 1-dimensional result array where each cell describes one attribute of a named array.

Synopsis

attributes( named_array )

Summary

The attributes operator produces a result array where each cell describes an attribute of the named array. Each output cell includes the following information: 

  • No: the sequence number of the attribute as it appears in the input array.
  • name: the attribute name.
  • type_id: the attribute data type.
  • nullable: a boolean flag representing whether or not the attribute can be null.

The attributes operator is one of SciDB's metadata operators. Other metadata operators include dimensions, show and list.

Examples

Create an Array, and Show its Attributes

To create an array with one attribute, then show the array's attribute, do the following:

  1. To create the array, enter the following:

    AFL% CREATE ARRAY A <a:int32>[x=0:9];
  2. To show the array's attributes, enter: 

    AFL% attributes(A);


    The output is:

    {No} name,type_id,nullable
    {0} 'a','int32',true

Create another Array with more than one Attribute and show the Array's Attributes

To create an array with more than one attribute then show the array's attributes, do the following:

  1. To create an array named winnersFlat with five attributes of mixed types, enter the following. Note that two attributes in the winnersFlat array – year and country – can contain null markers. 

    AFL% 
    CREATE ARRAY winnersFlat <event:string NOT NULL,person:string NOT NULL,year:int32,country:string,time:double NOT NULL>[I=0:11];

     

  2. Data in the winnersFlat array might look like this. Note the null entries (which correspond to a missing code of 0) and the country attribute with a missing code of 1. 

    {I} event,person,year,country,time
    {0} 'dash','Bailey',1996,'Canada',9.84
    {1} 'dash','Greene',2000,'USA',9.87
    {2} 'dash','Gatlin',2004,'USA',9.85
    {3} 'dash','Bolt',2008,'Jamaica',9.69
    {4} 'steeplechase','Keter',1996,'Kenya',487.12
    {5} 'steeplechase','Kosgei',null,?1,503.17
    {6} 'steeplechase','Kemboi',2004,'Kenya',485.81
    {7} 'steeplechase','Kipruto',2008,'Kenya',490.34
    {8} 'marathon','Thugwane',1996,'USA',7956
    {9} 'marathon','Abera',2000,null,7811
    {10} 'marathon','Baldini',2004,'Italy',7855
    {11} 'marathon','Wanjiru',2008,'Kenya',7596
  3. To show the winnersFlat array's attributes, enter: 

    AFL% attributes( winnersFlat );


    The output is:

    {No} name,type_id,nullable
    {0} 'event','string',false
    {1} 'person','string',false
    {2} 'year','int32',true
    {3} 'country','string',true
    {4} 'time','double',false

Filter the Array's Attributes to show Only the Nullable Attributes 

From the perspective of the query language, the results of the attributes operator can be treated like an array.  So you can use a combination of filter and attributes to show only the nullable attributes of an array.

  1. To show the winnersFlat array's nullable attributes, enter: 

    AFL% filter ( attributes ( winnersFlat ), nullable = true );


    The output is:

    {No} name,type_id,nullable
    {2} 'year','int32',true
    {3} 'country','string',true