Package gudusoft.gsqlparser.parser
Class PrestoSqlParser
Object
gudusoft.gsqlparser.parser.AbstractSqlParser
gudusoft.gsqlparser.parser.PrestoSqlParser
- All Implemented Interfaces:
SqlParser
Presto SQL parser implementation.
This parser handles Presto-specific SQL syntax including:
- Presto SQL statements
- Presto PL/SQL blocks (stored procedures, functions)
- Semicolon statement separators
Design Notes:
- Extends
AbstractSqlParserusing the template method pattern - Uses
TLexerPrestofor tokenization - Uses
TParserPrestofor parsing - Delimiter character: ';' for SQL statements
- Since:
- 3.2.0.0
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class gudusoft.gsqlparser.parser.AbstractSqlParser
AbstractSqlParser.PreparedSqlReader -
Field Summary
FieldsFields inherited from class gudusoft.gsqlparser.parser.AbstractSqlParser
defaultDelimiterStr, delimiterChar, frameStack, globalContext, globalFrame, lexer, parserContext, sourcetokenlist, sqlcmds, sqlEnv, sqlstatements, syntaxErrors, vendor -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidCall Presto-specific raw statement extraction logic.protected TCustomLexergetLexer(ParserContext context) Return the Presto lexer instance.protected TCustomParsergetParser(ParserContext context, TSourceTokenList tokens) Return the Presto SQL parser instance with updated token list.protected TCustomParsergetSecondaryParser(ParserContext context, TSourceTokenList tokens) Presto does not have a secondary parser (only Oracle has PL/SQL parser).protected voidperformInterpreter(ParserContext context, TStatementList statements) Perform interpretation/evaluation on parsed statements.protected TStatementListperformParsing(ParserContext context, TCustomParser parser, TCustomParser secondaryParser, TSourceTokenList tokens, TStatementList rawStatements) Perform full parsing of statements with syntax checking.protected voidperformSemanticAnalysis(ParserContext context, TStatementList statements) Perform Presto-specific semantic analysis using TSQLResolver.protected voidSetup Presto parser for raw statement extraction.protected voidCall Presto-specific tokenization logic.toString()Methods inherited from class gudusoft.gsqlparser.parser.AbstractSqlParser
afterStatementParsed, attemptErrorRecovery, copyErrorsFromStatement, doAfterTokenize, doExtractRawStatements, extractRawStatements, getanewsourcetoken, getDefaultDelimiterStr, getDelimiterChar, getErrorCount, getrawsqlstatements, getSyntaxErrors, getVendor, handleStatementParsingException, initializeGlobalContext, isDollarFunctionDelimiter, onRawStatementComplete, onRawStatementCompleteVendorSpecific, parse, performTokenization, prepareSqlReader, processTokensBeforeParse, processTokensInTokenTable, setTokenHandle, tokenize, towinlinebreak
-
Field Details
-
flexer
The Presto lexer used for tokenization
-
-
Constructor Details
-
PrestoSqlParser
public PrestoSqlParser()Construct Presto SQL parser.Configures the parser for Presto database with default delimiter (;).
Following the original TGSqlParser pattern, the lexer and parser are created once in the constructor and reused for all parsing operations.
-
-
Method Details
-
getLexer
Return the Presto lexer instance.- Specified by:
getLexerin classAbstractSqlParser- Parameters:
context- the parser context- Returns:
- configured lexer instance (never null)
-
getParser
Return the Presto SQL parser instance with updated token list.- Specified by:
getParserin classAbstractSqlParser- Parameters:
context- the parser contexttokens- the source token list- Returns:
- configured parser instance (never null)
-
getSecondaryParser
Presto does not have a secondary parser (only Oracle has PL/SQL parser).- Overrides:
getSecondaryParserin classAbstractSqlParser- Parameters:
context- the parser contexttokens- the source token list- Returns:
- null (no secondary parser)
-
tokenizeVendorSql
Call Presto-specific tokenization logic.Delegates to doprestotexttotokenlist which handles Presto's specific keyword recognition and token generation.
- Specified by:
tokenizeVendorSqlin classAbstractSqlParser
-
setupVendorParsersForExtraction
Setup Presto parser for raw statement extraction.Presto uses a single parser, so we inject sqlcmds and update the token list for the main parser only.
- Specified by:
setupVendorParsersForExtractionin classAbstractSqlParser
-
extractVendorRawStatements
Call Presto-specific raw statement extraction logic.Delegates to doprestogetrawsqlstatements which handles Presto's statement delimiters (semicolon and slash for PL/SQL).
- Specified by:
extractVendorRawStatementsin classAbstractSqlParser- Parameters:
builder- the result builder to populate with raw statements
-
performParsing
protected TStatementList performParsing(ParserContext context, TCustomParser parser, TCustomParser secondaryParser, TSourceTokenList tokens, TStatementList rawStatements) Perform full parsing of statements with syntax checking.This method orchestrates the parsing of all statements.
- Specified by:
performParsingin classAbstractSqlParser- Parameters:
context- the parser contextparser- the main parser instancesecondaryParser- secondary parser (may be null)tokens- the source token listrawStatements- raw statements already extracted (never null)- Returns:
- statement list with parsed AST (never null)
-
performSemanticAnalysis
Perform Presto-specific semantic analysis using TSQLResolver.- Overrides:
performSemanticAnalysisin classAbstractSqlParser- Parameters:
context- the parser contextstatements- the parsed statements (mutable)
-
performInterpreter
Perform interpretation/evaluation on parsed statements.- Overrides:
performInterpreterin classAbstractSqlParser- Parameters:
context- the parser contextstatements- the parsed statements (mutable)
-
toString
- Overrides:
toStringin classAbstractSqlParser
-