Builtin

attrs

attrs(a)

A macro which returns an attr list from relation a, which must contain {attr:str} and optionally {seq:int}. The attr list is built at call-time, i.e. just before the expression in which it is embedded is evaluated. It can be used as a projection, or anywhere an attribute list is needed.

If {seq:int} is provided, it will be used as a left-right ordering for places where that matters e.g. ordering lists.

Examples

heading($P)
attrtype
PNOstr
PNAMEstr
COLORstr
WEIGHTint
CITYstr
attrs creates a table (not a relation)
attrs(heading($P))
🮕🮕🮕🮕🮕🮕🮕🮕🮕🮕
  attr    
  PNO     
  PNAME   
  COLOR   
  WEIGHT  
  CITY    
🮕🮕🮕🮕🮕🮕🮕🮕🮕🮕

Use as a projection - projecting only int attributes
$P{attrs(heading($P)[type="int"])}
WEIGHT
12
14
17
19