Add query_entities to functions module import
Fix query_entities with labeled subqueries