LucidDB / luciddb

DEFUNCT: See README
https://github.com/LucidDB/luciddb
Apache License 2.0
52 stars 24 forks source link

[FRG-190] Improve SQL pretty-printer #682

Closed dynamobi-build closed 12 years ago

dynamobi-build commented 12 years ago

[reporter="jvs", created="Thu, 24 Aug 2006 18:14:08 -0500 (GMT-05:00)"] Oscar, if you have any time to study and tweak this to smooth out some of the wrinkles, I can enable any improvements you make into the way it's used in LucidEra red-zone code.

Farrago class is org.eigenbase.sql.pretty.SqlPrettyWriter (it interacts with the SqlNode class hierarchy to unparse specific constructs). Unit test is org.eigenbase.sql.test.SqlPrettyWriterTest; stepping through there should give you some idea how it works. It relies on SqlPrettyWriterTest.ref.xml (in the same directory as the .java file) for input queries and expected output formatting to diff against.

It looks like there's already a flag for setCaseClausesOnNewLines; I'm not sure if it does what you want, but if it does, I can enable it. There doesn't appear to be any support for wrapping each AND clause onto a separate line yet, so that would be a possible enhancement for ON join conditions and WHERE clauses. There's also that annoying thing where it gets the indent wrong for select lists.

Rules of engagement here are that we should not change the default existing behavior, because many diff-based tests may depend on it. So any changes or enhancements need to be added via new flags whose default values yield the current behavior. And all changes need corresponding unit tests.

dynamobi-build commented 12 years ago

[author="ogothberg", created="Wed, 18 Oct 2006 15:25:06 -0500 (GMT-05:00)"] Wow, had totally forgot about this. Should log into this jira server more often. Is now on my mental to-look-into list.

dynamobi-build commented 12 years ago

[author="ogothberg", created="Mon, 6 Nov 2006 10:15:01 -0500 (GMT-05:00)"] Looked at some code, built some sub-tasks. All still on a when-I-have-the-time priority.

dynamobi-build commented 12 years ago

[author="ogothberg", created="Thu, 8 Mar 2007 12:42:06 -0500 (GMT-05:00)"] all subtasks checked in, changenums 8773, 8847