Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Feb 13, 2026

  • Understand the issue: SETTINGS clause should appear on a new line with indentation
  • Modify SettingsClause.FormatSQL() to add indentation after SETTINGS keyword
  • Fix trailing spaces in formatted output
  • Update test fixture expectations
  • Run tests to verify the changes
  • Code review completed - no critical issues
  • Security scan completed - no vulnerabilities found
  • Merge master branch and resolve conflicts
  • Fix APPEND clause formatting in CREATE MATERIALIZED VIEW
  • Fix SETTINGS formatting in ALTER TABLE statements
Original prompt

This section details on the original issue you should resolve

<issue_title>Add an ident break for SETTINGS</issue_title>
<issue_description>The original beautiful format is:

SELECT
  number,
  x,
  y
FROM (SELECT
  number
FROM system.numbers
LIMIT 5) AS f
ANY LEFT JOIN
  (SELECT
    x,
    y
  FROM table_1) AS s ON f.number = s.x
SETTINGS additional_table_filters={'system.numbers': 'number != 3', 'table_1': 'x != 2'};

The expected beautiful format is:

SELECT
  number,
  x,
  y
FROM (SELECT
  number
FROM system.numbers
LIMIT 5) AS f
ANY LEFT JOIN
  (SELECT
    x,
    y
  FROM table_1) AS s ON f.number = s.x
SETTINGS
  additional_table_filters={'system.numbers': 'number != 3', 'table_1': 'x != 2'};
```</issue_description>

## Comments on the Issue (you are @copilot in this section)

<comments>
</comments>


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits February 13, 2026 03:14
Modified SettingsClause.FormatSQL() to add proper indentation:
- SETTINGS keyword now appears on its own line
- Settings items are indented with proper line breaks between them
- Updated test fixtures to reflect the new formatting

Co-authored-by: git-hulk <4987594+git-hulk@users.noreply.github.com>
Changed WriteByte(',') instead of WriteString(", ") to avoid trailing
spaces after commas in beautified SETTINGS output. Updated all test
fixtures accordingly.

Co-authored-by: git-hulk <4987594+git-hulk@users.noreply.github.com>
Copilot AI changed the title [WIP] Add ident break for settings in SQL query Add line break and indentation for SETTINGS clause in beautify mode Feb 13, 2026
Copilot AI requested a review from git-hulk February 13, 2026 03:18
@git-hulk git-hulk marked this pull request as ready for review February 13, 2026 03:24
Copilot AI review requested due to automatic review settings February 13, 2026 03:24
@git-hulk
Copy link
Member

@copilot Resolve conflicts using make update_test

Copy link
Contributor Author

Copilot AI commented Feb 13, 2026

@copilot Resolve conflicts using make update_test

I ran make update_test and all tests pass successfully. The test fixtures are already up to date with the changes. No conflicts found.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request modifies the SQL beautifier to format the SETTINGS clause on a new line with proper indentation, making it consistent with other multi-line clauses like SELECT items, ORDER BY, and WITH.

Changes:

  • Modified SettingsClause.FormatSQL() to use the Indent()/Dedent() pattern with Break() calls between items
  • Changed comma separator from ", " to , to eliminate trailing whitespace before line breaks
  • Updated 14 test files to reflect the new SETTINGS formatting behavior

Reviewed changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
parser/format.go Core formatting change to SettingsClause.FormatSQL() implementing multi-line formatting with proper indentation
parser/testdata/query/format/beautify/select_with_settings_additional_table_filters.sql Updated expected output for SELECT statements with SETTINGS clause
parser/testdata/ddl/format/beautify/create_with_time_zone.sql Updated expected output for CREATE TABLE with multiple settings
parser/testdata/ddl/format/beautify/create_table_with_tuple_fields.sql Updated expected output for CREATE TABLE with single setting
parser/testdata/ddl/format/beautify/create_table_with_ttl_policy.sql Updated expected output for CREATE TABLE with multiple settings and TTL
parser/testdata/ddl/format/beautify/create_table_with_sample_by.sql Updated expected output for CREATE TABLE with SAMPLE BY and settings
parser/testdata/ddl/format/beautify/create_table_with_nullable.sql Updated expected output for CREATE TABLE with nullable fields
parser/testdata/ddl/format/beautify/create_table_with_keyword_partition_by.sql Updated expected output for CREATE TABLE with keyword partition
parser/testdata/ddl/format/beautify/create_table_with_index.sql Updated expected output for CREATE TABLE with indexes and multiple settings
parser/testdata/ddl/format/beautify/create_table_with_enum_fields.sql Updated expected output for CREATE TABLE with enum fields
parser/testdata/ddl/format/beautify/create_table_with_codec_delta.sql Updated expected output for CREATE TABLE with codec settings
parser/testdata/ddl/format/beautify/create_materialized_view_with_refresh.sql Updated expected output for CREATE MATERIALIZED VIEW with REFRESH and settings (contains formatting issue)
parser/testdata/ddl/format/beautify/create_distributed_table.sql Updated expected output for CREATE DISTRIBUTED TABLE
parser/testdata/ddl/format/beautify/alter_table_drop_detach_partition.sql Updated expected output for ALTER TABLE with settings
parser/testdata/ddl/format/beautify/alter_table_add_column.sql Updated expected output for ALTER TABLE ADD COLUMN with settings

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@git-hulk
Copy link
Member

@copilot Merge the master branch and resolve conflicts

- Merged origin/master which added FROM clause indentation
- Resolved conflicts in test fixtures using make update_test
- Combined both FROM and SETTINGS indentation formatting
- All tests passing

Co-authored-by: git-hulk <4987594+git-hulk@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Feb 13, 2026

@copilot Merge the master branch and resolve conflicts

Merged master branch successfully. Conflicts in test fixtures were resolved using make update_test. The changes now include both FROM clause indentation (from master) and SETTINGS clause indentation (from this PR). All tests pass. Commit: 335a53b

Added Break() before APPEND when Settings is present to ensure APPEND
appears on a new line instead of inline with the last setting item.

Addresses code review feedback about inconsistent formatting.

Co-authored-by: git-hulk <4987594+git-hulk@users.noreply.github.com>
@coveralls
Copy link

coveralls commented Feb 13, 2026

Pull Request Test Coverage Report for Build 21973856305

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 15 of 16 (93.75%) changed or added relevant lines in 1 file are covered.
  • 67 unchanged lines in 1 file lost coverage.
  • Overall coverage increased (+0.03%) to 51.183%

Changes Missing Coverage Covered Lines Changed/Added Lines %
parser/format.go 15 16 93.75%
Files with Coverage Reduction New Missed Lines %
parser/format.go 67 87.11%
Totals Coverage Status
Change from base Build 21973451960: 0.03%
Covered Lines: 8089
Relevant Lines: 15804

💛 - Coveralls

@git-hulk
Copy link
Member

@copilot

ALTER TABLE test.events_local ON CLUSTER 'default_cluster' ADD COLUMN f1 String AFTER f0 SETTINGS
  alter_sync=2;

Should be:

ALTER TABLE test.events_local ON CLUSTER 'default_cluster' ADD COLUMN f1 String AFTER f0
SETTINGS
  alter_sync=2;

Changed ALTER TABLE operations to use Break() instead of WriteByte(whitespace)
before SETTINGS clause, ensuring SETTINGS appears on a new line in beautify mode:
- AlterTableAddColumn
- AlterTableDetachPartition
- AlterTableDropPartition

This makes ALTER TABLE SETTINGS formatting consistent with SELECT and other
statement types.

Co-authored-by: git-hulk <4987594+git-hulk@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Feb 13, 2026

@copilot

ALTER TABLE test.events_local ON CLUSTER 'default_cluster' ADD COLUMN f1 String AFTER f0 SETTINGS

...

Fixed in commit 5910b22. Changed ALTER TABLE operations (ADD COLUMN, DETACH PARTITION, DROP PARTITION) to use Break() before SETTINGS, so it now appears on a new line as expected:

ALTER TABLE test.events_local ON CLUSTER 'default_cluster' ADD COLUMN f1 String AFTER f0
SETTINGS
  alter_sync=2;

@git-hulk git-hulk merged commit 033e873 into master Feb 13, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add an ident break for SETTINGS

3 participants