query layer impl in python