I am in a situation stuck with a challenge to solve in Druid. I will attach an excel file with this mail, 1st sheet contains input data and 2nd sheet has excepted result.
The data has 3 columns ID, DOCNO, AMT and I want a result data with columns ID, DOCNO, AMT, and FLAG where FLAG should be a boolean value (True or False).
if an individual ID has 3 AMT entries 100,100,-100 then the corresponding FLAG should be True, False, False.
Note: Here we take 100 and -100 as matching and should be flagged as False remaining 100 should be flagged as True.
An ID AB1001 has 6 AMT entries -199,-199,199,199,199,88, and the corresponding FLAG should be False, False, False, False, True, True respectively
which means only matching pairs of -ve and +ve with the same number should be flagged as false otherwise should be flagged as True.
Anyone, please provide a suitable query to solve this challenge in Druid.
(Attachment CHALLENGE (1).xlsx is missing)
I can’t think of a way to do this. It sounds like you want to mark pairs of -v/v false, repeat, until they’re all paired and marked. Not sure how to do that.
Maybe there’s another way to approach this? Eg, if you want the end result, just take a sum. Or, if you need pictures in time, take a sum up to the row’s timestamp.
Otherwise the logic gets pretty complicated: not just, false if there’s a -v for the v, but if there’s a -v that isn’t already paired with another copy of v.
I think the answer, if you need this flag, would be to find a way to do it upstream. If there’s a different end-result that’s the real aim, maybe something at
query time, and maybe along the lines of the suggestions above.
If someone else sees a way to do it at ingestion time (which I think is what you’re asking), I’ll be very interested to hear it.
Hi, I don’t quite understand the logic you are looking for. Your first example as an odd number of items in it, your second example an even number of items. If you are starting from one end of the set and moving through it to pick up pairs, then are you walking through it backwards?