Azure ADX, not add timestamp after using argmax in creation of materialized view

44 Views Asked by At

When trying to create a materialized view in ADX using KQL you have some limitations one of which is to use summarize as the last statement in the creation query.I am using argmax()-function over multiple parameters and bin them into the last available (non-null) value. This I do this way:

table_name 
| summarize   
arg_max( parametername1 = iif(isnotempty(parametername1), ts, unixtime_nanoseconds_todatetime(0)), parametername1 = parametername1 ), 
arg_max( parametername2 = iif(isnotempty(parametername2 ), ts, unixtime_nanoseconds_todatetime(0)), parametername2 =parametername2 ),
 ... 
by origin, bin(ts,1m)
 

The problem is now, that argmax always return the timestamp for the parameter and the parametervalue, so two distinct columns. But because I already have the timestamp from my bin, I don't need a seperate timestamp for every parameter. Using project or project-away isn't an option, because you can't use it as a last statement as menitoned above.

So is there not an option?

I tried to just select the specific field with .parametername1 at the end of every aggregation statement which didn't work. I tried to use project, which isn't allowed after summarize.

1

There are 1 best solutions below

0
yifats On

This can't be done as part of the materialized view statement. You can create a stored function over the view that will project-away the unnecessary timestamp columns, and have all users query the stored function instead of the view directly.