[
https://issues.apache.org/jira/browse/CALCITE-3526?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Julian Hyde resolved CALCITE-3526.
----------------------------------
Fix Version/s: 1.22.0
Resolution: Fixed
Fixed in
[c416c31f|https://github.com/apache/calcite/commit/c416c31fc376868bdd672afd84ec06dc75d56575].
> SqlPrettyWriter should have options to fold/chop long lines, print leading
> commas
> ---------------------------------------------------------------------------------
>
> Key: CALCITE-3526
> URL: https://issues.apache.org/jira/browse/CALCITE-3526
> Project: Calcite
> Issue Type: Bug
> Reporter: Julian Hyde
> Priority: Major
> Fix For: 1.22.0
>
>
> SqlPrettyWriter should have options to fold/chop long lines, print leading
> commas.
> In this change, we change how {{SqlPrettyWriter}} is configured: methods such
> as
> {{setIndentation}} are now deprecated, there is an immutable config object
> {{SqlWriterConfig}}, and the {{SqlDialect}} and {{boolean
> alwaysUseParentheses}} constructor arguments are also properties of the
> config. So, rather than
> {code}
> new SqlPrettyWriter(d, p).setIndentation(4)
> {code}
> you now write
> {code}
> new SqlPrettyWriter(
> SqlPrettyWriter.config()
> .withDialect(d)
> .withAlwaysUseParentheses(p)
> .withIndentation(4))
> {code}
> This change adds options to fold lists such as the SELECT clause: WIDE always
> puts items on the same line, TALL always puts items on separate lines, and
> FOLD and CHOP adapt. If the line is too long, FOLD fits as many items on a
> line as it can, whereas CHOP puts items onto separate lines. STEP is like
> WIDE but observes the {{clauseEndsLine}} property.
> You can set folding policy for each clause separately using
> {{withSelectFolding}}, {{withOrderByFolding}} etc., or set the default
> {{withFolding}}.
> A new property {{clauseEndsLine}} causes first SELECT item to be on a
> separate line than the SELECT keyword, and similarly other clauses.
> For all options, see
> [SqlWriterConfig|https://calcite.apache.org/apidocs/org/apache/calcite/sql/SqlWriterConfig.html].
> This changes also fixes CALCITE-1585; because config is held in an immutable
> object rather than the SqlPrettyWriter, {{reset()}} no longer resets settings
> such as {{alwaysUseParentheses}}.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)