Columnar sql rewriter