Type | Read/write | Author | Availability |
---|---|---|---|
Read | Finbourne | Provided with LUSID |
The Lusid.Property.Definition
provider enables you to write a Luminesce SQL query that retrieves property types stored in LUSID.
These include all the property types and derived property types you create yourself, and a selection of property types underlying system properties and valuation metrics provided with LUSID.
See also: Lusid.Property.Definition.Writer
Basic usage
select * from Lusid.Property.Definition where <filter-expression>;
Query parameters
Lusid.Property.Definition
has parameters that enable you to filter or refine a query.
To list available parameters, their data types, default values, and an explanation for each, run the following query using a suitable tool:
select FieldName, DataType, ParamDefaultValue, Description from Sys.Field where TableName = 'Lusid.Property.Definition' and FieldType = 'Parameter';
Data fields
By default, Lusid.Property.Definition
returns a table of data populated with particular fields (columns). You can return just a subset of these fields if you wish.
To list fields available to return, their data types, whether fields are considered 'main', and an explanation for each, run the following query using a suitable tool:
select FieldName, DataType, IsMain, IsPrimaryKey, SampleValues, Description from Sys.Field where TableName = 'Lusid.Property.Definition' and FieldType = 'Column';
Note: Fields marked 'main' are returned by queries that use a caret character, for example
select ^ from Lusid.Property.Definition
.
Examples
Note: For more example Luminesce SQL queries, visit our Github repo.
Example 1: Retrieve all property types, custom and system
select * from Lusid.Property.Definition;
Example 2: Retrieve all user-defined property types
You can exclude property types for system properties, valuation metrics and potentially other settings provided with LUSID by filtering out the protected system
and default
scopes.
select * from Lusid.Property.Definition where PropertyScope not in ('system', 'default');
Example 3: Retrieve all derived property types
You can retrieve just derived property types by filtering out the protected system
and default
scopes and setting isDerived
to True
.
select * from Lusid.Property.Definition where PropertyScope not in ('system', 'default') and isDerived = True;
Example 4: Retrieve all dependent property types in the derivation formulae of derived property types
A derived property type has a derivation formula that may reference other property types. The following query retrieves dependent property types for all derived property types in a particular domain, in this case Instrument
:
select DISTINCT
substr(sRow.Value, 1, instr(sRow.Value, ']') - 1) as propertyKey
,def.PropertyKey as DerivedPropertyKey
from
Lusid.Property.Definition def
left outer join
Tools.Split sRow on def.DerivationFormula = sRow.Original and sRow.DelimiterString = 'Properties['
left outer join
Lusid.Property.Definition prop on prop.propertyKey = substr(sRow.Value, 1, instr(sRow.Value, ']') - 1)
where
def.domain = 'Instrument' and
def.IsDerived = true and
def.PropertyScope not in ('LUSID-Onboarding','default','system') and
def.[ConstraintStyle] not in ('Identifier') and
instr(sRow.Value, ']') > 0
The query generates one row per dependency per derived property type. So for example if an Instrument/Derived/Domicile
derived property type has the following derivation formula:
map(coalesce(Properties[Instrument/SourceA/country_issue], Properties[Instrument/SourceB/origin], 'Unknown'): 'United Kingdom'='UK', 'united kingdom'='UK', 'United States'='USA', 'US'='USA', default='Unknown')
…then the query produces the following two rows for Instrument/Derived/Domicile
:
Example 5: Retrieve property types for multiple property scopes
You can retrieve property types for a particular set of property scopes, such as those used by your data vendors.
select * from Lusid.Property.Definition where PropertyScope in ('VendorA', 'VendorB', 'VendorC');
Example 6: Retrieve property types for all transactions within a portfolio scope
You can join Lusid.Property.Definition
to a property provider such as Lusid.Portfolio.Txn.Property to decorate transaction properties with associated property type details, such as Lifetime
:
select
tp.TxnId,
tp.PortfolioScope,
tp.Value,
pd.PropertyScope,
pd.PropertyCode,
pd.DisplayName,
pd.Description,
pd.DataType,
pd.PropertyKey,
pd.Lifetime
from Lusid.Property.Definition pd
inner join Lusid.Portfolio.Txn.Property tp
on tp.PropertyScope = pd.PropertyScope and tp.PropertyCode = pd.PropertyCode
where tp.PortfolioScope = 'Finbourne-Examples' and pd.PropertyScope not in ('system', 'default');