Builtin

attr_types

attr_types(a)

A macro which returns an attr:type list from relation a, which must contain {attr:str, type:str} and optionally {seq:int}. The attr:type 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 relation constructor, as a relational operator output type declaration, or anywhere an attribute:type list is needed.

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

Examples

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

Use as a relation constructor - using only str attributes
{attr_types(heading($P)[type="str"])}{}
CITYCOLORPNAMEPNO