To check whether there are obstacles between light and spot, take World Position of Item light, subtract Spot World Position, normalize, and plug to Ray Cast Node Ray Direction. Take Spot World Position and use as Ray Origin. If result of Ray Cast is -1 there is no obstacles at all, if result is between 0.0 and Math > Vector > Distance between Spot World Position and Light Item Info node World Position, there are obstacles. Higher values that that calculated distance would mean that there is geometry behind light in that direction. The easiest would be making Gradient node with -1 key, and keys 0 and dynamic key (Show Output), taking Distance node output as key value.