kokosing / trino-query-formatter Goto Github PK
View Code? Open in Web Editor NEWPresto SQL query formatter
License: Apache License 2.0
Presto SQL query formatter
License: Apache License 2.0
Is there any plan to support other version of SQL, e.g., Teradata? Is this formatter based on ANTLR4?
Not sure whether this is certain place to ask but I was looking for Presto (AWS athena query) formatter and came up here.
Would it be possible to support Athena query or do they use dialect so it wouldn't be supported here?
I already faced three error on parsing... I'll put error messages below.
CREATE EXTERNAL
when I tried to create external table$ cat sample.sql | presto-query-formatter-0.2-executable.jar > formatted.sql
Exception in thread "main" com.facebook.presto.sql.parser.ParsingException: line 1:8: no viable alternative at input 'CREATE EXTERNAL'
at com.facebook.presto.sql.parser.SqlParser$1.syntaxError(SqlParser.java:45)
at org.antlr.v4.runtime.ProxyErrorListener.syntaxError(ProxyErrorListener.java:41)
at org.antlr.v4.runtime.Parser.notifyErrorListeners(Parser.java:540)
at org.antlr.v4.runtime.DefaultErrorStrategy.reportNoViableAlternative(DefaultErrorStrategy.java:284)
at org.antlr.v4.runtime.DefaultErrorStrategy.reportError(DefaultErrorStrategy.java:121)
at com.facebook.presto.sql.parser.SqlBaseParser.statement(SqlBaseParser.java:2638)
at com.facebook.presto.sql.parser.SqlBaseParser.singleStatement(SqlBaseParser.java:236)
at com.facebook.presto.sql.parser.SqlParser.invokeParser(SqlParser.java:92)
at com.facebook.presto.sql.parser.SqlParser.createStatement(SqlParser.java:65)
at rocks.prestodb.query.formatter.Main.format(Main.java:61)
at rocks.prestodb.query.formatter.Main.main(Main.java:42)
Caused by: org.antlr.v4.runtime.NoViableAltException
at org.antlr.v4.runtime.atn.ParserATNSimulator.noViableAlt(ParserATNSimulator.java:2025)
at org.antlr.v4.runtime.atn.ParserATNSimulator.execATN(ParserATNSimulator.java:467)
at org.antlr.v4.runtime.atn.ParserATNSimulator.adaptivePredict(ParserATNSimulator.java:393)
at com.facebook.presto.sql.parser.SqlBaseParser.statement(SqlBaseParser.java:1376)
`
backtick$ cat sample.sql | presto-query-formatter-0.2-executable.jar > formatted.sql
Exception in thread "main" com.facebook.presto.sql.parser.ParsingException: line 2:9: backquoted identifiers are not supported; use double quotes to quote identifiers
at com.facebook.presto.sql.parser.SqlParser$PostProcessor.exitBackQuotedIdentifier(SqlParser.java:133)
at com.facebook.presto.sql.parser.SqlBaseParser$BackQuotedIdentifierContext.exitRule(SqlBaseParser.java:10605)
at org.antlr.v4.runtime.Parser.triggerExitRuleEvent(Parser.java:404)
at org.antlr.v4.runtime.Parser.exitRule(Parser.java:620)
at com.facebook.presto.sql.parser.SqlBaseParser.singleStatement(SqlBaseParser.java:247)
at com.facebook.presto.sql.parser.SqlParser.invokeParser(SqlParser.java:92)
at com.facebook.presto.sql.parser.SqlParser.createStatement(SqlParser.java:65)
at rocks.prestodb.query.formatter.Main.format(Main.java:61)
at rocks.prestodb.query.formatter.Main.main(Main.java:42)
struct
after <
$ cat sample.sql | presto-query-formatter-0.2-executable.jar > formatted.sql
Exception in thread "main" com.facebook.presto.sql.parser.ParsingException: line 4:29: mismatched input '<' expecting {'(', 'ARRAY', '>'}
at com.facebook.presto.sql.parser.SqlParser$1.syntaxError(SqlParser.java:45)
at org.antlr.v4.runtime.ProxyErrorListener.syntaxError(ProxyErrorListener.java:41)
at org.antlr.v4.runtime.Parser.notifyErrorListeners(Parser.java:540)
at org.antlr.v4.runtime.DefaultErrorStrategy.reportInputMismatch(DefaultErrorStrategy.java:301)
at org.antlr.v4.runtime.DefaultErrorStrategy.reportError(DefaultErrorStrategy.java:124)
at com.facebook.presto.sql.parser.SqlBaseParser.type(SqlBaseParser.java:9038)
at com.facebook.presto.sql.parser.SqlBaseParser.type(SqlBaseParser.java:8921)
at com.facebook.presto.sql.parser.SqlBaseParser.columnDefinition(SqlBaseParser.java:2987)
at com.facebook.presto.sql.parser.SqlBaseParser.tableElement(SqlBaseParser.java:2922)
at com.facebook.presto.sql.parser.SqlBaseParser.statement(SqlBaseParser.java:1638)
at com.facebook.presto.sql.parser.SqlBaseParser.singleStatement(SqlBaseParser.java:236)
at com.facebook.presto.sql.parser.SqlParser.invokeParser(SqlParser.java:92)
at com.facebook.presto.sql.parser.SqlParser.createStatement(SqlParser.java:65)
at rocks.prestodb.query.formatter.Main.format(Main.java:61)
at rocks.prestodb.query.formatter.Main.main(Main.java:42)
Caused by: org.antlr.v4.runtime.InputMismatchException
at org.antlr.v4.runtime.DefaultErrorStrategy.sync(DefaultErrorStrategy.java:244)
at com.facebook.presto.sql.parser.SqlBaseParser.type(SqlBaseParser.java:8979)
... 9 more
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.