Support queries in patterns