Query processing framework