Skip to content

[FORMATTING] Querying a semi-structured data with an element name that is a reserved clause is incorrect #706

@chaupow

Description

@chaupow

Hi! 👋

Input data

Which SQL and options did you provide as input?
with "language": "snowflake"

SELECT
  details:type
FROM
  transactions

Expected Output

SELECT
  details:type
FROM
  transactions

Actual Output

SELECT
  details:
type
FROM
  transactions

Usage

We're using snowflake and unfortunately some of our JSON fields have the key type which is identified as a reserved clause and incorrectly put in the next line.

We can prevent this by using details:"type" but it would be great if it would work without quotes as well.

This is especially an issue because we would love to use "keywordCase": "upper" but this breaks the query because key names are case sensitive and details:TYPE fails to query the intended lookup.

  • How are you calling / using the library?
sqlFormatter.format(sqlContent, {"language": "snowflake"});
  • What SQL language(s) does this apply to?
    snowflake

  • Which SQL Formatter version are you using?
    15.1.2

Thank youuuuuuuuu 🙏

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