Derived properties reference

This page catalogs the aggregations and expressions available to derived properties, noting where each can be used and how they compare in performance.

Aggregations

An aggregation combines values from many linked objects into one value. An aggregation is required whenever a link traversal can reach more than one object. Both ontology-defined and runtime-defined derived properties support aggregations.

Linked selections and aggregations cannot embed another derived property definition, but their property selectors can reference a property that is already in scope. Expressions can use native properties or the results of linked selections and aggregations, as described below.

The following table lists each aggregation by its name in Ontology Manager and method name in the Ontology SDK, the property types it accepts as input, and the property type of the value it produces.

Name in Ontology ManagerMethod name in Ontology SDKSource property typesResult property type
Count$countNot applicableLong
AverageavgNumericDouble
SumsumNumericNumeric, widened (see below)
MinimumminNumeric, string, Boolean, date, timestampSame as source
MaximummaxNumeric, string, Boolean, date, timestampSame as source
Approximate cardinalityapproximateDistinctNumeric, string, Boolean, date, timestampLong
Exact cardinalityexactDistinctNumeric, string, Boolean, date, timestampLong
Collect listcollectListAnything except vectorArray of the source type
Collect setcollectSetAnything except vectorArray of the source type
Not availableapproximatePercentileNumericSame as source

In this table, numeric includes byte, short, integer, long, float, double, and decimal.

Each valid source property type can be scalar or an array of that type. Aggregations flatten array inputs before computing the result. For example, a percentile over an array<integer> property returns an integer.

Result type widening

The Sum aggregation widens the numeric type results to avoid overflow:

Source typeResult type
short, integerlong
longlong
floatdouble
doubledouble
decimaldecimal, with increased precision and reduced scale (if necessary)

Collection behavior

The Collect list and Collect set aggregations share the following behavior:

  • Collected values do not have a guaranteed order unless property reducers are defined. When property reducers are defined, Foundry uses them to sort the returned values whether or not the reducer is applied.
  • Objects with no value for the property are skipped, so the resulting array never contains nulls.
  • Collect set removes duplicate values. Collect list preserves them.
  • For Collect set, duplicates are removed before the limit is applied. The limit controls the number of distinct values returned rather than the total number of values considered.
  • The limit defaults to 10 and can be raised to a maximum of 100.
  • The limit determines the values returned to you, not the values the platform evaluates. Learn more about collection limits before filtering on a collected property.

A property reducer can select one representative value from a collected array for display and interface implementation. The reducer does not change the full array used by queries.

Type limitations for aggregations

Vector properties cannot be aggregated or selected by a derived property. A derived property cannot produce a vector value.

Expressions

Expressions combine values arithmetically or extract parts of a date. They are only available to runtime-defined derived properties.

Static literals are not currently supported in expressions. Expression-based derived properties can only reference derived properties defined earlier in the declaration order; specifically, those defined in an inner object set expression. For example, when chaining multiple withProperties operations, a derived property can be referenced in a subsequent expression-based operation, but not within the same operation or any earlier one in the declaration order. Linked property- and aggregation-based derived properties cannot reference other derived properties at all.

Numeric expressions

Ontology SDKDescription
addAdds two values.
subtractSubtracts the second value from the first.
multiplyMultiplies two values.
divideDivides the first value by the second.
maxReturns the greater of two values.
minReturns the lesser of two values.
absReturns the absolute value.
negateReverses the sign of the value.

Date and timestamp expressions

Ontology SDKDescription
minReturns the earlier of two values.
maxReturns the later of two values.
extractPartExtracts a component of a date. Accepts DAYS, MONTHS, QUARTERS, or YEARS.

Expressions require version 2.4.0 or later of the @osdk/client package.

Choose to select or aggregate

Your ability to directly select a property depends on how many objects each link traversal can reach. If more than one object can be reached, an aggregation is required:

Link chainAvailable operation
Every traversal reaches at most one objectSelect a property directly or aggregate
Any traversal can reach more than one objectAn aggregation is required
The chain includes a many-to-many linkAn aggregation is required; selecting is never permitted
A one-to-many link whose foreign key is an arrayAn aggregation is required; treated as potentially reaching many objects in either direction

Compare derived properties to native properties

Once defined, a derived property behaves much like a native property within the same request, with some differences:

OperationSupportedNotes
Return in resultsYesDerived properties must be selected explicitly, regardless of property type.
FilterYesIncludes exact match, range, prefix, phrase, full-text, geographic, and relative date filters.
SortYesIn Workshop, sorting an object set that uses derived properties limits the set to 200 rows.
AggregateYes
Group byYes
Reference from another derived propertyLimitedLinked property- and aggregation-based derived properties cannot reference other derived properties. Expression-based support depends on the declaration order, as described above.
Edit with an action or functionNoDerived properties are read-only.
Use as a primary keyNo
Use as a link type foreign keyNo

Scale and performance by aggregation

Derived property values are evaluated at query time and are not indexed. Performance depends primarily on data scale: the number of objects evaluated and the number of linked objects each one reaches. Relative cost reflects the latency and compute usage of a request.

  • Loading a derived property, which means returning its value in results, is relatively inexpensive for every aggregation. The cost is roughly equivalent to an aggregation request.
  • Searching on a derived property, which means filtering or sorting by its value, is more expensive for most aggregations. Collect list and Collect set are the exception: the platform can often push searches on these aggregations down to existing indexes on the source property.
AggregationLoad costSearch costNotes
CountLowHigh
Sum, Average, Minimum, MaximumLowHigh
Approximate cardinalityLowHighPrefer this over Exact cardinality unless an exact count is required.
Exact cardinalityModerateHigh
Approximate percentileLowHighRuntime-defined only.
Collect list, Collect setLowLowCost scales with the number of linked objects, not with the display limit.

Additional guidance:

  • Prefer approximate cardinality: Exact cardinality is substantially less performant. Use it only when an exact count is required and the additional latency is acceptable.
  • Consider traversal count and link cardinality: Each traversal can increase the intermediate result size. Overall performance depends on both the data scale and the number of linked objects.
  • Filter before aggregating: Applying a filter to the linked object set reduces the number of objects the aggregation must process.
  • Consider a precomputed value at high scale: If a derived property introduces unacceptable latency, review Ontology structural guidance for information on when denormalization is an appropriate tradeoff.

For platform-wide execution thresholds and fallback behavior, review Ontology query limitations. For compute cost, review query compute usage.