@Override protected Tester getTester() { return new UnparsingTesterImpl(); }
@Override public void checkExp(String sql, String expected) { SqlNode sqlNode = parseExpressionAndHandleEx(sql); // Unparse with no dialect, always parenthesize. final String actual = sqlNode.toSqlString(null, true).getSql(); assertEquals(expected, linux(actual)); // Unparse again in Calcite dialect (which we can parse), and // minimal parentheses. final String sql1 = sqlNode.toSqlString(CalciteSqlDialect.DEFAULT, false).getSql(); // Parse and unparse again. SqlNode sqlNode2; final Quoting q = quoting; try { quoting = Quoting.DOUBLE_QUOTE; sqlNode2 = parseExpressionAndHandleEx(sql1); } finally { quoting = q; } final String sql2 = sqlNode2.toSqlString(CalciteSqlDialect.DEFAULT, false).getSql(); // Should be the same as we started with. assertEquals(sql1, sql2); // Now unparse again in the null dialect. // If the unparser is not including sufficient parens to override // precedence, the problem will show up here. final String actual2 = sqlNode2.toSqlString(null, true).getSql(); assertEquals(expected, linux(actual2)); }
@Override public void check(String sql, String expected) { SqlNode sqlNode = parseStmtAndHandleEx(sql); // Unparse with no dialect, always parenthesize. final String actual = sqlNode.toSqlString(null, true).getSql(); assertEquals(expected, linux(actual)); // Unparse again in Calcite dialect (which we can parse), and // minimal parentheses. final String sql1 = sqlNode.toSqlString(CalciteSqlDialect.DEFAULT, false).getSql(); // Parse and unparse again. SqlNode sqlNode2; final Quoting q = quoting; try { quoting = Quoting.DOUBLE_QUOTE; sqlNode2 = parseStmtAndHandleEx(sql1); } finally { quoting = q; } final String sql2 = sqlNode2.toSqlString(CalciteSqlDialect.DEFAULT, false).getSql(); // Should be the same as we started with. assertEquals(sql1, sql2); // Now unparse again in the null dialect. // If the unparser is not including sufficient parens to override // precedence, the problem will show up here. final String actual2 = sqlNode2.toSqlString(null, true).getSql(); assertEquals(expected, linux(actual2)); }
@Override public void check(String sql, String expected) { SqlNode sqlNode = parseStmtAndHandleEx(sql); // Unparse with no dialect, always parenthesize. final String actual = sqlNode.toSqlString(null, true).getSql(); assertEquals(expected, linux(actual)); // Unparse again in Calcite dialect (which we can parse), and // minimal parentheses. final String sql1 = sqlNode.toSqlString(CalciteSqlDialect.DEFAULT, false).getSql(); // Parse and unparse again. SqlNode sqlNode2; final Quoting q = quoting; try { quoting = Quoting.DOUBLE_QUOTE; sqlNode2 = parseStmtAndHandleEx(sql1); } finally { quoting = q; } final String sql2 = sqlNode2.toSqlString(CalciteSqlDialect.DEFAULT, false).getSql(); // Should be the same as we started with. assertEquals(sql1, sql2); // Now unparse again in the null dialect. // If the unparser is not including sufficient parens to override // precedence, the problem will show up here. final String actual2 = sqlNode2.toSqlString(null, true).getSql(); assertEquals(expected, linux(actual2)); }
@Override public void checkExp(String sql, String expected) { SqlNode sqlNode = parseExpressionAndHandleEx(sql); // Unparse with no dialect, always parenthesize. final String actual = sqlNode.toSqlString(null, true).getSql(); assertEquals(expected, linux(actual)); // Unparse again in Calcite dialect (which we can parse), and // minimal parentheses. final String sql1 = sqlNode.toSqlString(CalciteSqlDialect.DEFAULT, false).getSql(); // Parse and unparse again. SqlNode sqlNode2; final Quoting q = quoting; try { quoting = Quoting.DOUBLE_QUOTE; sqlNode2 = parseExpressionAndHandleEx(sql1); } finally { quoting = q; } final String sql2 = sqlNode2.toSqlString(CalciteSqlDialect.DEFAULT, false).getSql(); // Should be the same as we started with. assertEquals(sql1, sql2); // Now unparse again in the null dialect. // If the unparser is not including sufficient parens to override // precedence, the problem will show up here. final String actual2 = sqlNode2.toSqlString(null, true).getSql(); assertEquals(expected, linux(actual2)); }
@Override protected Tester getTester() { return new UnparsingTesterImpl(); } }