fix to do query re-writing for tests on query serialization
fix to rewrite query w/ recursive rewriter for both of Simple stream and Pattern