You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Julian Hyde (Jira)" <ji...@apache.org> on 2022/03/28 20:26:00 UTC

[jira] [Commented] (CALCITE-3526) SqlPrettyWriter should have options to fold/chop long lines, print leading commas

    [ https://issues.apache.org/jira/browse/CALCITE-3526?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17513631#comment-17513631 ] 

Julian Hyde commented on CALCITE-3526:
--------------------------------------

Logged CALCITE-4401 for the SqlJoin issue. Please continue discussion there.

> 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.20.1#820001)