use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.sql.pretty.SqlPrettyWriter in project calcite by apache.
the class SqlPrettyWriterTest method testKeywordsLowerCase.
@Test
public void testKeywordsLowerCase() throws Exception {
final SqlPrettyWriter prettyWriter = new SqlPrettyWriter(AnsiSqlDialect.DEFAULT);
prettyWriter.setKeywordsLowerCase(true);
checkSimple(prettyWriter, "${desc}", "${formatted}");
}
use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.sql.pretty.SqlPrettyWriter in project calcite by apache.
the class SqlPrettyWriterTest method testSelectListItemsOnSeparateLines.
@Test
public void testSelectListItemsOnSeparateLines() throws Exception {
final SqlPrettyWriter prettyWriter = new SqlPrettyWriter(AnsiSqlDialect.DEFAULT);
prettyWriter.setSelectListItemsOnSeparateLines(true);
checkSimple(prettyWriter, "${desc}", "${formatted}");
}
use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.sql.pretty.SqlPrettyWriter in project calcite by apache.
the class SqlPrettyWriterTest method assertExprPrintsTo.
protected void assertExprPrintsTo(boolean newlines, final String sql, String expected) {
final SqlCall valuesCall = (SqlCall) parseQuery("VALUES (" + sql + ")");
final SqlCall rowCall = valuesCall.operand(0);
final SqlNode node = rowCall.operand(0);
final SqlPrettyWriter prettyWriter = new SqlPrettyWriter(AnsiSqlDialect.DEFAULT);
prettyWriter.setAlwaysUseParentheses(false);
if (newlines) {
prettyWriter.setCaseClausesOnNewLines(true);
}
String actual = prettyWriter.format(node);
getDiffRepos().assertEquals("formatted", expected, actual);
// Now parse the result, and make sure it is structurally equivalent
// to the original.
final String actual2 = actual.replaceAll("`", "\"");
final SqlNode valuesCall2 = parseQuery("VALUES (" + actual2 + ")");
assertTrue(valuesCall.equalsDeep(valuesCall2, Litmus.THROW));
}
use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.sql.pretty.SqlPrettyWriter in project calcite by apache.
the class SqlPrettyWriterTest method assertPrintsTo.
protected void assertPrintsTo(boolean newlines, final String sql, String expected) {
final SqlNode node = parseQuery(sql);
final SqlPrettyWriter prettyWriter = new SqlPrettyWriter(AnsiSqlDialect.DEFAULT);
prettyWriter.setAlwaysUseParentheses(false);
if (newlines) {
prettyWriter.setCaseClausesOnNewLines(true);
}
String actual = prettyWriter.format(node);
getDiffRepos().assertEquals("formatted", expected, actual);
// Now parse the result, and make sure it is structurally equivalent
// to the original.
final String actual2 = actual.replaceAll("`", "\"");
final SqlNode node2 = parseQuery(actual2);
assertTrue(node.equalsDeep(node2, Litmus.THROW));
}
use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.sql.pretty.SqlPrettyWriter in project calcite by apache.
the class SqlPrettyWriterTest method testParenthesizeAllExprs.
@Test
public void testParenthesizeAllExprs() throws Exception {
final SqlPrettyWriter prettyWriter = new SqlPrettyWriter(AnsiSqlDialect.DEFAULT);
prettyWriter.setAlwaysUseParentheses(true);
checkSimple(prettyWriter, "${desc}", "${formatted}");
}
Aggregations