Is it possible to use aliases when evaluating projections?

#1

On 7.6.1, I’m trying the following evaluate with the as

FacilityCharacteristicSet.evaluate({
  projection: 'id, abs(compareTo(timestamp, dateTime("2018-09-01"))) as distance',
  order: 'distance',
  filter: 'parent.facilityType=="ZONE"'
})

But it’s throwing:

Invalid expression "[id, abs(compareTo(timestamp, dateTime("2018-09-01"))) as distance]": missing ] after element list (<expr>#1)

When I remove the as and the order field the evaluate works, however if I try to order using my expression

FacilityCharacteristicSet.evaluate({
  projection: 'id, abs(compareTo(timestamp, dateTime("2018-09-01")))',
  order: 'abs(compareTo(timestamp, dateTime("2018-09-01")))',
  filter: 'parent.facilityType=="ZONE"'
})

I hit the following error:

Can't order using an expression that isn't included in the projections. Order: 'distance', Projections: '[id, abs(compareTo(timestamp, dateTime("2018-09-01")))]'
0 Likes

#2

There’s no as in your original query. Typo?

1 Like

#3

Thanks @yaroslav it was a typo, I corrected the expression by adding as distance

0 Likes

#4

@bachr No we do not support aliasing in projections or anywhere for that matter

0 Likes