test - writes compiled query