Closed ChenZhouUC closed 10 months ago
already solved when updated to latest version
Hello, thanks for the extension. I can still repro the error with the same example using version v1.6.0
of the extension, which is the latest version in the VSCode marketplace (extension ID inferrinizzard.prettier-sql-vscode
).
Unable to format SQL: Error: Parse error: Ambiguous grammar [ [ { "type": "statement", "children": [ { "type": "clause", "nameKw": { "type": "keyword", "tokenType": "RESERVED_SELECT", "text": "SELECT", "raw": "SELECT" }, "children": [ { "type": "all_columns_asterisk" } ] }, { "type": "clause", "nameKw": { "type": "keyword", "tokenType": "RESERVED_CLAUSE", "text": "FROM", "raw": "FROM" }, "children": [ { "type": "keyword", "tokenType": "RESERVED_KEYWORD", "text": "MEMBER", "raw": "member" } ] }, { "type": "clause", "nameKw": { "type": "keyword", "tokenType": "RESERVED_CLAUSE", "text": "WHERE", "raw": "WHERE" }, "children": [ { "type": "identifier", "text": "ds" }, { "type": "between_predicate", "betweenKw": { "type": "keyword", "tokenType": "BETWEEN", "text": "BETWEEN", "raw": "BETWEEN" }, "expr1": [ { "type": "literal", "text": "20230912" } ], "andKw": { "type": "keyword", "tokenType": "AND", "text": "AND", "raw": "AND" }, "expr2": [ { "type": "literal", "text": "20230918" } ] }, { "type": "keyword", "tokenType": "AND", "text": "AND", "raw": "AND" }, { "type": "identifier", "text": "member_id" }, { "type": "operator", "text": "=" }, { "type": "identifier", "text": "\"abcs\"" } ] } ], "hasSemicolon": true } ], [ { "type": "statement", "children": [ { "type": "clause", "nameKw": { "type": "keyword", "tokenType": "RESERVED_SELECT", "text": "SELECT", "raw": "SELECT" }, "children": [ { "type": "all_columns_asterisk" } ] }, { "type": "clause", "nameKw": { "type": "keyword", "tokenType": "RESERVED_CLAUSE", "text": "FROM", "raw": "FROM" }, "children": [ { "type": "keyword", "tokenType": "RESERVED_KEYWORD", "text": "MEMBER", "raw": "member" } ] }, { "type": "clause", "nameKw": { "type": "keyword", "tokenType": "RESERVED_CLAUSE", "text": "WHERE", "raw": "WHERE" }, "children": [ { "type": "identifier", "text": "ds" }, { "type": "between_predicate", "betweenKw": { "type": "keyword", "tokenType": "BETWEEN", "text": "BETWEEN", "raw": "BETWEEN" }, "expr1": [ { "type": "literal", "text": "20230912" }, { "type": "keyword", "tokenType": "AND", "text": "AND", "raw": "AND" }, { "type": "literal", "text": "20230918" } ], "andKw": { "type": "keyword", "tokenType": "AND", "text": "AND", "raw": "AND" }, "expr2": [ { "type": "identifier", "text": "member_id" } ] }, { "type": "operator", "text": "=" }, { "type": "identifier", "text": "\"abcs\"" } ] } ], "hasSemicolon": true } ] ]
Apologies I should be using renesaarsoo.sql-formatter-vsc
instead.
Describe the Feature when use this formatter to format sql like this:
SELECT * FROM member WHERE ds BETWEEN 20230912 AND 20230918 AND member_id = "abcs";
It would report error like this:
Why do you want this feature? BETWEEN AND clause is useful in many SQL Derivatives like Hive SQL.