Package org.apache.calcite.sql
Interface SqlWriterConfig
@Immutable
public interface SqlWriterConfig
Configuration for
SqlWriter
and SqlPrettyWriter
.-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic enum
Policy for how to do deal with long lines. -
Method Summary
Modifier and TypeMethodDescriptiondefault boolean
Returns whether expressions should always be included in parentheses.default boolean
Returns whether the WHEN, THEN and ELSE clauses of a CASE expression appear at the start of a new line.default boolean
Returns whether a clause (FROM, WHERE, GROUP BY, HAVING, WINDOW, ORDER BY) is followed by a new line.default boolean
Returns whether a clause (FROM, WHERE, GROUP BY, HAVING, WINDOW, ORDER BY) starts a new line.@Nullable SqlDialect
dialect()
Returns the dialect.default int
Returns the line length at which items are chopped or folded (for clauses that have chosenSqlWriterConfig.LineFolding.CHOP
orSqlWriterConfig.LineFolding.FOLD
).default SqlWriterConfig.LineFolding
Returns the line-folding policy for the FROM clause (and JOIN).@Nullable SqlWriterConfig.LineFolding
Returns the line-folding policy for the GROUP BY clause.@Nullable SqlWriterConfig.LineFolding
Returns the line-folding policy for the HAVING clause.default int
Returns the number of spaces indentation.default boolean
Returns whether to print keywords (SELECT, AS, etc.) in lower-case.default boolean
Returns whether commas in SELECT, GROUP BY and ORDER clauses should appear at the start of the line.@Nullable SqlWriterConfig.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.default int
Returns the maximum line length.@Nullable SqlWriterConfig.LineFolding
Returns the line-folding policy for the MATCH_RECOGNIZE clause.static SqlWriterConfig
of()
Create a default SqlWriterConfig object.@Nullable SqlWriterConfig.LineFolding
Returns the line-folding policy for the ORDER BY clause.@Nullable SqlWriterConfig.LineFolding
Returns the line-folding policy for the OVER clause or a window declaration.default boolean
Returns whether to quote all identifiers, even those which would be correct according to the rules of theSqlDialect
if quotation marks were omitted.@Nullable SqlWriterConfig.LineFolding
Returns the line-folding policy for the SELECT clause.default boolean
Returns whether to use a fix for SELECT list indentations.default boolean
Returns whether each item in a SELECT list, GROUP BY list, or ORDER BY list is on its own line.default SqlWriter.SubQueryStyle
Returns the sub-query style.@Nullable SqlWriterConfig.LineFolding
Returns the line-folding policy for the SET clause of an UPDATE statement.default boolean
Returns whether each assignment in the SET clause of an UPDATE or MERGE statement should be on its own line.@Nullable SqlWriterConfig.LineFolding
Returns the line-folding policy for the VALUES expression.default boolean
Returns whether each row in a VALUES clause should be on its own line.@Nullable SqlWriterConfig.LineFolding
Returns the line-folding policy for the WHERE clause.default boolean
Returns whether to print a newline before each AND or OR (whichever is higher level) in WHERE clauses.default boolean
Returns whether each declaration in a WINDOW clause should be on its own line.@Nullable SqlWriterConfig.LineFolding
Returns the line-folding policy for the WINDOW clause.default boolean
Returns 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 theSqlDialect
if 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.CHOP
orSqlWriterConfig.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.
-