Hi all,
I know this is very specific, but I hope maybe someone can still help me out.
I am basically trying to join two tables. The rows of both tables are associated with same measurements, but have slightly different timestamps (similar but not perfectly aligned).
For this I miss some kind of for-each loop or random functions that could apply to each element of one table and could be called from another table.
The syntax would be somehow similar to:
I tried to implement getElement as a custom function, but this one already returns
an error I do no understand (“Canont mix implicit and explicit preperties”)
getElement = (tables=<-, StartTime, StopTime, val) =>
tables
|> range(start: MyStartTime, stop: MyEndTime)
|> filter(fn: ® => r.a == val )
|> tableFind(fn: (key) => key._measurement == “m1”)
|> getRecord(idx: 0)
Then I would like to call this function for each element of a new stream, something like:
myTableStream1 = from(bucket: “test/autogen”)
|> range(start: MyStartTime, stop: MyEndTime)
|> filter(fn: ® => r._measurement == “m1” )
myTableStream2 = from(bucket: “test/autogen”)
|> range(start: MyStartTime, stop: MyEndTime)
|> filter(fn: ® => r._measurement == “m2” )
/// This is the part where I should join the m2 stream and m1 stream - I supposed it would be something like:
|> filter(fn: getElement(myTableStream1, r._time -1s, r._time+1s, r.b)
Unfortunatelly I do not know how to save the result of the operation in a temporary variable and pass it to the next filter in order for the next function that either adds the columns of the measurement from m1, or drop the whole row.
Also, I have not found a possibility to simply join two rows (in case they do not have the same timestamp). Assuming I have two rows r1 and r2 and want to join them into one row. As far as I could see the map() function only works if you know the names of the columns. Any other possibilities to do this?
Any hints would be greatly appreciated.
All the best