EntityFunction

EntityFunction[x,body]

is a function with a single formal parameter x, to be used in EntityValue and related functions.

EntityFunction[{x1,x2,},body]

is an EntityFunction with a list of formal parameters.

Details

  • EntityFunction[x, body] behaves exactly like an EntityProperty and can be used directly in EntityValue.
  • In EntityFunction[x,body], x is usually bound to a single Entity at a time. The second argument of AggregatedEntityClass is an exception to this rule, since the formal parameter will bind to each group of entities.
  • In the context of the second argument of AggregatedEntityClass for relational-database-backed entities, the following aggregation functions are supported:
  • Minminimum of values
    Maxmaximum of values
    Lengthnumber of values
    Totalsum of values
    Meanthe mean value
    StandardDeviationsample standard deviation
    Variancesample variance
  • EntityFunction[{left,right},body] can appear as the condition for CombinedEntityClass. Here, left will bind to each Entity in the first argument of CombinedEntityClass and right to each Entity in the second argument.
  • When dealing with entities registered in a relational-database-backed EntityStore, only the following forms can be compiled to SQL:
  • a+badditions between numbers, dates and time quantities
    a-bdifferences between numbers or dates
    a*bmultiplications between numbers
    a/bratios between numbers
    a^bpowers between numbers
    Quotient[a,b]integer division
    Mod[a,b]remainder of division between integers
    Sqrt[a]square root
    Exp[a]exponential of numbers
    Log,Log10,Log2logarithms in different bases
    Abs[a]absolute value
    OddQ[a],EvenQ[a]parity checks on integers
    ab,a>b,ab,comparisons between numbers, dates, strings
    a&&b,a||b,!a,Boolean algebra
    If[a,b,c]if statements
    Which[]which statements
    MissingQ[a]check whether an element is missing
    Length[list]0check whether a list is empty
    OrderedQ[a,b]check the alphabetical order of strings
    MemberQ[list,a]check whether an element is in a list or an entity in a class
    StringJoin[a,b,]string concatenation
    StringMatchQ[],StringStartsQ[],basic string matching operations
    Now,Todaygetting the current date
    AllTrue,AnyTrueBoolean operations on lists
    SelectFirst[list,Not@*MissingQ]select the first non-missing value in a list
    BitNot,BitAnd,BitOr,BitShiftLeft,bitwise operations
    Sin,Cos,Tan,trigonometric functions
    ArcSin,ArcCos,ArcTan,inverse trigonometric functions
    Sinh,Cosh,Tanh,hyperbolic functions
    ArcSinh,ArcCosh,ArcTanhinverse hyperbolic functions
    Round,Floor,Ceilingrounding functions
    Min,Maxminimum and maximum (outside aggregations)
    StringTake,StringDropextract a subpart of a string (including UpTo support)
    ToString[a]convert a number or date to string
    N[a]convert an integer to real
    IntegerPart[a]extract the integer part of a real number
    FromDigits[a]convert a string to integer
    Boole[a]convert a Boolean to 0 or 1
    Interpreter["StructuredDate"][a],Interpreter["StructuredTime"][a],Interpreter["StructuredDateTime"][a]convert a string to date or time object
    UnixTime[a]convert a date object with time to a number
    FromUnixTime[a]convert a number to a date object with time
    JulianDate[a]convert a date object to a number
    FromJulianDate[a]convert a number to a date object
    DateValue[a,"SecondsFromMidnight"]convert a time object to a number
    DateValue[UnixTime[a],"TimeObject"]convert a number to a time object
  • In the context of relational-database-backed entities, the functions above might have limited functionality with respect to their Wolfram Language counterpart. For example, SQL lacks support for complex numbers; because of this, the domains of numerical functions are limited to regions where they are real valued. Symbolic evaluation is generally not available. Precision-tracking semantics may also vary.

Examples

open all close all

Basic Examples  (3)

Compute the ratio between atomic mass and atomic number for all noble gases:

In[1]:=
Click for copyable input
Out[1]=

EntityFunction can be applied directly to a single entity, like EntityProperty:

In[1]:=
Click for copyable input
Out[1]=

Use EntityFunction as a condition for FilteredEntityClass:

In[1]:=
Click for copyable input
Out[1]=

Properties & Relations  (6)

Possible Issues  (1)

Introduced in 2019
(12.0)