legend-pure icon indicating copy to clipboard operation
legend-pure copied to clipboard

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

Open aormerod-gs opened this issue 1 year ago • 0 comments

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)

aormerod-gs avatar Apr 14 '23 11:04 aormerod-gs