Skip to content

Implement SQL formatter into the docs pipeline #13031

Open
@qiancai

Description

@qiancai

Change Request

  1. Describe what you find is inappropriate or missing in the existing docs.

    It would be better to have SQL code be more readable by default and be stacked as opposed to all one line.

    For example, the line:

    SELECT l_orderkey, MAX(L_COMMENT), MAX(L_SHIPMODE), MAX(L_SHIPINSTRUCT), MAX(L_SHIPDATE), MAX(L_EXTENDEDPRICE) FROM lineitem GROUP BY l_orderkey HAVING SUM(l_quantity) > 314;
    

    Would be more readable as:

    SELECT 
          l_orderkey, 
          MAX(L_COMMENT), 
          MAX(L_SHIPMODE), 
          MAX(L_SHIPINSTRUCT), 
          MAX(L_SHIPDATE), 
          MAX(L_EXTENDEDPRICE) 
    FROM lineitem 
    GROUP BY l_orderkey 
    HAVING SUM(l_quantity) > 314;
    
  2. Describe your suggestion or addition.

    Try and put something like https://sqlfum.pt/ into the docs pipeline to automatically:

    • Fix the case for SQL keywords (e.g. "insert" → "INSERT")
    • Convert to multi-line
  3. Provide some reference materials (such as documents and websites) if you could.

    https://github.com/mjibson/sqlfmt (which is https://wasm.sqlfum.pt/ )
    https://sqlfmt.com/
    https://www.salvis.com/blog/2020/08/28/formatting-sql-code-blocks-in-markdown-files/

Metadata

Metadata

Assignees

No one assigned

    Labels

    2024-tidb-docs-dashThis issue or PR is included in the 2024 TiDB Docs Dash event.type/enhancementThe issue or PR belongs to an enhancement.

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions