use of org.apache.calcite.sql.pretty.SqlPrettyWriter in project calcite by apache.
the class SqlPrettyWriterTest method testSelectListExtraIndentFlag.
@Test
public void testSelectListExtraIndentFlag() throws Exception {
final SqlPrettyWriter prettyWriter = new SqlPrettyWriter(AnsiSqlDialect.DEFAULT);
prettyWriter.setSelectListItemsOnSeparateLines(true);
prettyWriter.setSelectListExtraIndentFlag(false);
checkSimple(prettyWriter, "${desc}", "${formatted}");
}
use of org.apache.calcite.sql.pretty.SqlPrettyWriter in project calcite by apache.
the class SqlPrettyWriterTest method testOnlyQuoteIdentifiersWhichNeedIt.
@Test
public void testOnlyQuoteIdentifiersWhichNeedIt() throws Exception {
final SqlPrettyWriter prettyWriter = new SqlPrettyWriter(AnsiSqlDialect.DEFAULT);
prettyWriter.setQuoteAllIdentifiers(false);
checkSimple(prettyWriter, "${desc}", "${formatted}");
}
use of org.apache.calcite.sql.pretty.SqlPrettyWriter in project calcite by apache.
the class SqlPrettyWriterTest method checkPrettySeparateLines.
private void checkPrettySeparateLines(String sql) {
final SqlPrettyWriter prettyWriter = new SqlPrettyWriter(AnsiSqlDialect.DEFAULT);
prettyWriter.setSelectListItemsOnSeparateLines(true);
prettyWriter.setSelectListExtraIndentFlag(false);
final SqlNode node = parseQuery(sql);
// Describe settings
final StringWriter sw = new StringWriter();
final PrintWriter pw = new PrintWriter(sw);
prettyWriter.describe(pw, true);
pw.flush();
String desc = sw.toString();
getDiffRepos().assertEquals("desc", "${desc}", desc);
prettyWriter.setWhereListItemsOnSeparateLines(true);
// Format
String actual = prettyWriter.format(node);
getDiffRepos().assertEquals("formatted", "${formatted}", actual);
}
use of 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.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}");
}
Aggregations