I tried reproducing the scenario from my end, please find the below screenshots:
This is by design, as the Kusto engine optimizes joins using hash-based equality logic. To work around this, the recommended approach is to perform the equality join first and then apply any inequality filters in a subsequent where
clause.
To further validate this behavior, I ran a working repro using the built-in StormEvents
sample data. Here’s a complete working example that performs a self-join on an equality column (EventType
), and then applies an inequality condition (State != State
):
StormEvents
| where State != "FLORIDA" // Filter out FLORIDA
| extend leftState = State // Rename for clarity
| join kind=inner (
StormEvents
| where State != "FLORIDA"
| extend rightState = State
| project rightState, EventType, DamageProperty
) on $left.EventType == $right.EventType // Equality join
| where leftState != rightState // Apply inequality condition
| summarize event_count = count() by leftState
| where event_count > 1
| project State = leftState, event_count
Alternate approach:
Could you please try the below approach:
myTable
| where myColumnSubset == "mySubGroup"
| join kind=inner (
myTable
| where myColumnSubset == "mySubGroup"
| project myColumnOne, myColumnTwo, myColumnThree
) on $left.myColumnOne == $right.myColumnOne
| where myColumnTwo != myColumnTwo
I hope this information helps!