finos / legend-pure

Legend Pure module
https://legend.finos.org
Apache License 2.0
66 stars 136 forks source link

Remove validation restriction of data parameter to getAll being only a constant or variable (to enable FunctionExpression) #686

Open aormerod-gs opened 1 year ago

aormerod-gs commented 1 year ago

https://github.com/finos/legend-pure/blob/cbf7fcef2ecd76a8e1e82afd85431c3d613dc9a7/legend-pure-m3-core/src/main/java/org/finos/legend/pure/m3/compiler/validation/functionExpression/GetAllValidator.java#L73

Currently the method checks that the business date is a constant or a VariableExpression, expecting use cases of

MyClass.all(%2015-01-01)

or

let businessDate = today(); 
MyClass.all($businessDate );

However it gives compiler usage like

let businessDate = today(); 
MyClass.all($businessDate )
     ->concatenate(MyClass.all($businessDate->adjust(-1, DurationUnit.DAYS));

due to the parameter being a FunctionExpression.

Although people can still create an equivalent query via:

let businessDate = today(); 
MyClass.all($businessDate )
     ->concatenate({d:Date[1]|MyClass.all($d)}->eval($businessDate->adjust(-1, DurationUnit.DAYS));

and the compiler won't complain (but it's more complicated to write / less clear)