Package org.apache.calcite.sql
Interface SqlWriterConfig
@Immutable
public interface SqlWriterConfig
Configuration for
SqlWriter and SqlPrettyWriter.-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic enumPolicy for how to do deal with long lines. -
Method Summary
Modifier and TypeMethodDescriptiondefault booleanReturns whether expressions should always be included in parentheses.default booleanReturns whether the WHEN, THEN and ELSE clauses of a CASE expression appear at the start of a new line.default booleanReturns whether a clause (FROM, WHERE, GROUP BY, HAVING, WINDOW, ORDER BY) is followed by a new line.default booleanReturns whether a clause (FROM, WHERE, GROUP BY, HAVING, WINDOW, ORDER BY) starts a new line.@Nullable SqlDialectdialect()Returns the dialect.default intReturns the line length at which items are chopped or folded (for clauses that have chosenSqlWriterConfig.LineFolding.CHOPorSqlWriterConfig.LineFolding.FOLD).default SqlWriterConfig.LineFoldingReturns the line-folding policy for the FROM clause (and JOIN).@Nullable SqlWriterConfig.LineFoldingReturns the line-folding policy for the GROUP BY clause.@Nullable SqlWriterConfig.LineFoldingReturns the line-folding policy for the HAVING clause.default intReturns the number of spaces indentation.default booleanReturns whether to print keywords (SELECT, AS, etc.) in lower-case.default booleanReturns whether commas in SELECT, GROUP BY and ORDER clauses should appear at the start of the line.@Nullable SqlWriterConfig.LineFoldingReturns the line-folding policy for lists in the SELECT, GROUP BY and ORDER clauses, for items in the SET clause of UPDATE, and for items in VALUES.default intReturns the maximum line length.@Nullable SqlWriterConfig.LineFoldingReturns the line-folding policy for the MATCH_RECOGNIZE clause.static SqlWriterConfigof()Create a default SqlWriterConfig object.@Nullable SqlWriterConfig.LineFoldingReturns the line-folding policy for the ORDER BY clause.@Nullable SqlWriterConfig.LineFoldingReturns the line-folding policy for the OVER clause or a window declaration.default booleanReturns whether to quote all identifiers, even those which would be correct according to the rules of theSqlDialectif quotation marks were omitted.@Nullable SqlWriterConfig.LineFoldingReturns the line-folding policy for the SELECT clause.default booleanReturns whether to use a fix for SELECT list indentations.default booleanReturns whether each item in a SELECT list, GROUP BY list, or ORDER BY list is on its own line.default SqlWriter.SubQueryStyleReturns the sub-query style.@Nullable SqlWriterConfig.LineFoldingReturns the line-folding policy for the SET clause of an UPDATE statement.default booleanReturns whether each assignment in the SET clause of an UPDATE or MERGE statement should be on its own line.@Nullable SqlWriterConfig.LineFoldingReturns the line-folding policy for the VALUES expression.default booleanReturns whether each row in a VALUES clause should be on its own line.@Nullable SqlWriterConfig.LineFoldingReturns the line-folding policy for the WHERE clause.default booleanReturns whether to print a newline before each AND or OR (whichever is higher level) in WHERE clauses.default booleanReturns whether each declaration in a WINDOW clause should be on its own line.@Nullable SqlWriterConfig.LineFoldingReturns the line-folding policy for the WINDOW clause.default booleanReturns whether a WINDOW clause should start its own line.withAlwaysUseParentheses(boolean alwaysUseParentheses) SetsalwaysUseParentheses().withCaseClausesOnNewLines(boolean caseClausesOnNewLines) SetscaseClausesOnNewLines().withClauseEndsLine(boolean clauseEndsLine) SetsclauseEndsLine().withClauseStartsLine(boolean clauseStartsLine) SetsclauseStartsLine().withDialect(@Nullable SqlDialect dialect) Setsdialect().withFoldLength(int lineLength) SetsfoldLength().withFromFolding(SqlWriterConfig.LineFolding lineFolding) SetsfromFolding().withGroupByFolding(@Nullable SqlWriterConfig.LineFolding lineFolding) SetsgroupByFolding().withHavingFolding(@Nullable SqlWriterConfig.LineFolding lineFolding) SetshavingFolding().withIndentation(int indentation) Setsindentation().withKeywordsLowerCase(boolean keywordsLowerCase) SetskeywordsLowerCase().withLeadingComma(boolean leadingComma) SetsleadingComma().withLineFolding(@Nullable SqlWriterConfig.LineFolding lineFolding) SetslineFolding().withLineLength(int lineLength) SetslineLength().withMatchFolding(@Nullable SqlWriterConfig.LineFolding lineFolding) SetsmatchFolding().withOrderByFolding(@Nullable SqlWriterConfig.LineFolding lineFolding) SetsorderByFolding().withOverFolding(@Nullable SqlWriterConfig.LineFolding lineFolding) SetsoverFolding().withQuoteAllIdentifiers(boolean quoteAllIdentifiers) SetsquoteAllIdentifiers().withSelectFolding(@Nullable SqlWriterConfig.LineFolding lineFolding) SetsselectFolding().withSelectListExtraIndentFlag(boolean selectListExtraIndentFlag) withSelectListItemsOnSeparateLines(boolean selectListItemsOnSeparateLines) withSubQueryStyle(SqlWriter.SubQueryStyle subQueryStyle) SetssubQueryStyle().withUpdateSetFolding(@Nullable SqlWriterConfig.LineFolding lineFolding) SetsupdateSetFolding().withUpdateSetListNewline(boolean updateSetListNewline) SetsupdateSetListNewline().withValuesFolding(@Nullable SqlWriterConfig.LineFolding lineFolding) SetsvaluesFolding().withValuesListNewline(boolean valuesListNewline) SetsvaluesListNewline().withWhereFolding(@Nullable SqlWriterConfig.LineFolding lineFolding) SetswhereFolding().withWhereListItemsOnSeparateLines(boolean whereListItemsOnSeparateLines) withWindowDeclListNewline(boolean windowDeclListNewline) SetswindowDeclListNewline().withWindowFolding(@Nullable SqlWriterConfig.LineFolding lineFolding) SetswindowFolding().withWindowNewline(boolean windowNewline) SetswindowNewline().
-
Method Details
-
dialect
@Nullable SqlDialect dialect()Returns the dialect. -
withDialect
Setsdialect(). -
keywordsLowerCase
@Default default boolean keywordsLowerCase()Returns whether to print keywords (SELECT, AS, etc.) in lower-case. Default is false: keywords are printed in upper-case. -
withKeywordsLowerCase
SetskeywordsLowerCase(). -
quoteAllIdentifiers
@Default default boolean quoteAllIdentifiers()Returns whether to quote all identifiers, even those which would be correct according to the rules of theSqlDialectif quotation marks were omitted. Default is true. -
withQuoteAllIdentifiers
SetsquoteAllIdentifiers(). -
indentation
@Default default int indentation()Returns the number of spaces indentation. Default is 4. -
withIndentation
Setsindentation(). -
clauseStartsLine
@Default default boolean clauseStartsLine()Returns whether a clause (FROM, WHERE, GROUP BY, HAVING, WINDOW, ORDER BY) starts a new line. Default is true. SELECT is always at the start of a line. -
withClauseStartsLine
SetsclauseStartsLine(). -
clauseEndsLine
@Default default boolean clauseEndsLine()Returns whether a clause (FROM, WHERE, GROUP BY, HAVING, WINDOW, ORDER BY) is followed by a new line. Default is false. -
withClauseEndsLine
SetsclauseEndsLine(). -
selectListItemsOnSeparateLines
@Default default boolean selectListItemsOnSeparateLines()Returns whether each item in a SELECT list, GROUP BY list, or ORDER BY list is on its own line.Default is false; this property is superseded by
selectFolding(),groupByFolding(),orderByFolding(). -
withSelectListItemsOnSeparateLines
-
lineFolding
@Nullable SqlWriterConfig.LineFolding lineFolding()Returns the line-folding policy for lists in the SELECT, GROUP BY and ORDER clauses, for items in the SET clause of UPDATE, and for items in VALUES. -
withLineFolding
SetslineFolding(). -
selectFolding
@Nullable SqlWriterConfig.LineFolding selectFolding()Returns the line-folding policy for the SELECT clause. If not set, the value oflineFolding()is used. -
withSelectFolding
SetsselectFolding(). -
fromFolding
Returns the line-folding policy for the FROM clause (and JOIN). If not set, the value oflineFolding()is used. -
withFromFolding
SetsfromFolding(). -
whereFolding
@Nullable SqlWriterConfig.LineFolding whereFolding()Returns the line-folding policy for the WHERE clause. If not set, the value oflineFolding()is used. -
withWhereFolding
SetswhereFolding(). -
groupByFolding
@Nullable SqlWriterConfig.LineFolding groupByFolding()Returns the line-folding policy for the GROUP BY clause. If not set, the value oflineFolding()is used. -
withGroupByFolding
SetsgroupByFolding(). -
havingFolding
@Nullable SqlWriterConfig.LineFolding havingFolding()Returns the line-folding policy for the HAVING clause. If not set, the value oflineFolding()is used. -
withHavingFolding
SetshavingFolding(). -
windowFolding
@Nullable SqlWriterConfig.LineFolding windowFolding()Returns the line-folding policy for the WINDOW clause. If not set, the value oflineFolding()is used. -
withWindowFolding
SetswindowFolding(). -
matchFolding
@Nullable SqlWriterConfig.LineFolding matchFolding()Returns the line-folding policy for the MATCH_RECOGNIZE clause. If not set, the value oflineFolding()is used. -
withMatchFolding
SetsmatchFolding(). -
orderByFolding
@Nullable SqlWriterConfig.LineFolding orderByFolding()Returns the line-folding policy for the ORDER BY clause. If not set, the value oflineFolding()is used. -
withOrderByFolding
SetsorderByFolding(). -
overFolding
@Nullable SqlWriterConfig.LineFolding overFolding()Returns the line-folding policy for the OVER clause or a window declaration. If not set, the value oflineFolding()is used. -
withOverFolding
SetsoverFolding(). -
valuesFolding
@Nullable SqlWriterConfig.LineFolding valuesFolding()Returns the line-folding policy for the VALUES expression. If not set, the value oflineFolding()is used. -
withValuesFolding
SetsvaluesFolding(). -
updateSetFolding
@Nullable SqlWriterConfig.LineFolding updateSetFolding()Returns the line-folding policy for the SET clause of an UPDATE statement. If not set, the value oflineFolding()is used. -
withUpdateSetFolding
SetsupdateSetFolding(). -
selectListExtraIndentFlag
@Default default boolean selectListExtraIndentFlag()Returns whether to use a fix for SELECT list indentations.- If set to "false":
SELECT A as A, B as B, C as C, D - If set to "true" (the default):
SELECT A as A, B as B, C as C, D
- If set to "false":
-
withSelectListExtraIndentFlag
-
windowDeclListNewline
@Default default boolean windowDeclListNewline()Returns whether each declaration in a WINDOW clause should be on its own line.Default is true; this property is superseded by
windowFolding(). -
withWindowDeclListNewline
SetswindowDeclListNewline(). -
valuesListNewline
@Default default boolean valuesListNewline()Returns whether each row in a VALUES clause should be on its own line.Default is true; this property is superseded by
valuesFolding(). -
withValuesListNewline
SetsvaluesListNewline(). -
updateSetListNewline
@Default default boolean updateSetListNewline()Returns whether each assignment in the SET clause of an UPDATE or MERGE statement should be on its own line.Default is true; this property is superseded by
updateSetFolding(). -
withUpdateSetListNewline
SetsupdateSetListNewline(). -
windowNewline
@Default default boolean windowNewline()Returns whether a WINDOW clause should start its own line. -
withWindowNewline
SetswindowNewline(). -
leadingComma
@Default default boolean leadingComma()Returns whether commas in SELECT, GROUP BY and ORDER clauses should appear at the start of the line. Default is false. -
withLeadingComma
SetsleadingComma(). -
subQueryStyle
Returns the sub-query style. Default isSqlWriter.SubQueryStyle.HYDE. -
withSubQueryStyle
SetssubQueryStyle(). -
whereListItemsOnSeparateLines
@Default default boolean whereListItemsOnSeparateLines()Returns whether to print a newline before each AND or OR (whichever is higher level) in WHERE clauses.NOTE: Ignored when alwaysUseParentheses is set to true.
-
withWhereListItemsOnSeparateLines
-
alwaysUseParentheses
@Default default boolean alwaysUseParentheses()Returns whether expressions should always be included in parentheses. Default is false. -
withAlwaysUseParentheses
SetsalwaysUseParentheses(). -
lineLength
@Default default int lineLength()Returns the maximum line length. Default is zero, which means there is no maximum. -
withLineLength
SetslineLength(). -
foldLength
@Default default int foldLength()Returns the line length at which items are chopped or folded (for clauses that have chosenSqlWriterConfig.LineFolding.CHOPorSqlWriterConfig.LineFolding.FOLD). Default is 80. -
withFoldLength
SetsfoldLength(). -
caseClausesOnNewLines
@Default default boolean caseClausesOnNewLines()Returns whether the WHEN, THEN and ELSE clauses of a CASE expression appear at the start of a new line. The default is false. -
withCaseClausesOnNewLines
SetscaseClausesOnNewLines(). -
of
Create a default SqlWriterConfig object.- Returns:
- The config.
-