Skip to content

[FORMATTING] Window functions and expressionWidth #841

@Brandon-Schur

Description

@Brandon-Schur

Setting an arbitrarily large expression width doesn't lead to window functions staying on a single line

Goal is similar to #168 which I believe is now "expressionWidth"

Input data

Which SQL and options did you provide as input?

-- Simplified example
SELECT
  PERCENTILE_CONT(1) within GROUP (ORDER BY blocks_read) AS blocks_read_p100,
  PERCENTILE_CONT(0.99) within GROUP (ORDER BY blocks_read) AS blocks_read_p99,
  PERCENTILE_CONT(0.95) within GROUP (ORDER BY blocks_read) AS blocks_read_p95,
FROM
  query_metrics

Expected Output

SELECT
  PERCENTILE_CONT(1) within GROUP (ORDER BY blocks_read) AS blocks_read_p100,
  PERCENTILE_CONT(0.99) within GROUP (ORDER BY blocks_read) AS blocks_read_p99,
  PERCENTILE_CONT(0.95) within GROUP (ORDER BY blocks_read) AS blocks_read_p95,
FROM
  query_metrics

Actual Output

SELECT
  PERCENTILE_CONT(1) within GROUP (
    ORDER BY
      blocks_read
  ) AS blocks_read_p100,
  PERCENTILE_CONT(0.99) within GROUP (
    ORDER BY
      blocks_read
  ) AS blocks_read_p99,
  PERCENTILE_CONT(0.95) within GROUP (
    ORDER BY
      blocks_read
  ) AS blocks_read_p95,
FROM
  query_metrics

My settings from vscode

    "SQL-Formatter-VSCode.dialect": "redshift",
    "SQL-Formatter-VSCode.tabSizeOverride": 1,
    "SQL-Formatter-VSCode.keywordCase": "upper",
    "SQL-Formatter-VSCode.expressionWidth": 400,
    "SQL-Formatter-VSCode.dataTypeCase": "upper",
    "SQL-Formatter-VSCode.denseOperators": true,
    "SQL-Formatter-VSCode.functionCase": "upper",
    "SQL-Formatter-VSCode.paramTypes": {

    }

Usage

  • How are you calling / using the library? Vscode
  • What SQL language(s) does this apply to? Redshift/PostgreSQL
  • Which SQL Formatter version are you using? 4.1.7

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions