Affects Version/s: None
Fix Version/s: 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
you now write
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.
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.