Azure ADF expression that returns either an existing array, or an empty array, based on a bool
Asked Answered
P

3

6

I have a boolean expression: equals(myStringValue, targetStringValue)

I have an array expression which might or might not be valid, depending on the boolean condition myArrayExpression.

I want to write:

if(
  equals(myStringValue, targetStringValue),
  myArrayExpression,
  ?????
)

where ????? is an expression that returns an empty array.


Naturally, this is an XY-problem. I definitely want to know how to do this directly, because understanding how this language works well is important to me. But if you want to know about the XY problem, it's over here: Azure ADF GetMetadata childItems if folder might not exist

Philharmonic answered 10/8, 2020 at 9:5 Comment(0)
P
5

You can always use the function json() to create arbitrary arrays or objects. In this scenario you can use json('[]') to get an empty array.

Paillette answered 3/10, 2023 at 5:18 Comment(0)
P
0

Defining an array variable, with no default value, and then referencing that does work.

But seems very sad - now we've got an extra variable floating around for no reason :(

Philharmonic answered 10/8, 2020 at 9:40 Comment(0)
O
0

You can use if (x, Y, skip(createArray(''), 1))

Oared answered 24/8, 2022 at 14:13 Comment(2)
Formatting code improves readabilityCommode
This produces an array with one item.Scalar

© 2022 - 2024 — McMap. All rights reserved.