Get query from preprocess function