Package gudusoft.gsqlparser.parser
Class SparksqlSqlParser
Object
gudusoft.gsqlparser.parser.AbstractSqlParser
gudusoft.gsqlparser.parser.SparksqlSqlParser
- All Implemented Interfaces:
SqlParser
Apache Spark SQL parser implementation.
This parser handles SparkSQL-specific SQL syntax including:
- SparkSQL SELECT statements
- SparkSQL-specific functions (DATE, TIME, TIMESTAMP, INTERVAL)
- SparkSQL stored procedures and triggers
- SparkSQL delimiter handling
Design Notes:
- Extends
AbstractSqlParserusing the template method pattern - Uses
TLexerSparksqlfor tokenization - Uses
TParserSparksqlfor parsing - Tokenization is simple, similar to MySQL
- Delimiter character: ';' for SparkSQL 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 SparkSQL-specific raw statement extraction logic.protected TCustomLexergetLexer(ParserContext context) Return the SparkSQL lexer instance.protected TCustomParsergetParser(ParserContext context, TSourceTokenList tokens) Return the SparkSQL parser instance with updated token list.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 semantic analysis on parsed statements.protected voidSetup SparkSQL parser for raw statement extraction.protected voidCall SparkSQL-specific tokenization logic.Methods inherited from class gudusoft.gsqlparser.parser.AbstractSqlParser
afterStatementParsed, attemptErrorRecovery, copyErrorsFromStatement, doAfterTokenize, doExtractRawStatements, extractRawStatements, getanewsourcetoken, getDefaultDelimiterStr, getDelimiterChar, getErrorCount, getrawsqlstatements, getSecondaryParser, getSyntaxErrors, getVendor, handleStatementParsingException, initializeGlobalContext, isDollarFunctionDelimiter, onRawStatementComplete, onRawStatementCompleteVendorSpecific, parse, performTokenization, prepareSqlReader, processTokensBeforeParse, processTokensInTokenTable, setTokenHandle, tokenize, toString, towinlinebreak
-
Field Details
-
flexer
The SparkSQL lexer used for tokenization
-
-
Constructor Details
-
SparksqlSqlParser
public SparksqlSqlParser()Construct SparkSQL parser.Configures the parser for Apache Spark SQL with default delimiter (;).
-
-
Method Details
-
getLexer
Return the SparkSQL lexer instance.- Specified by:
getLexerin classAbstractSqlParser- Parameters:
context- the parser context- Returns:
- configured lexer instance (never null)
-
getParser
Return the SparkSQL 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)
-
tokenizeVendorSql
Call SparkSQL-specific tokenization logic.- Specified by:
tokenizeVendorSqlin classAbstractSqlParser
-
setupVendorParsersForExtraction
Setup SparkSQL parser for raw statement extraction.- Specified by:
setupVendorParsersForExtractionin classAbstractSqlParser
-
extractVendorRawStatements
Call SparkSQL-specific raw statement extraction logic.- 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.- 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
Description copied from class:AbstractSqlParserPerform semantic analysis on parsed statements.Hook Method: Default implementation does nothing. Override to provide vendor-specific semantic analysis.
Typical Implementation:
- Column-to-table resolution (TSQLResolver)
- Dataflow analysis
- Reference resolution
- Scope resolution
- Overrides:
performSemanticAnalysisin classAbstractSqlParser- Parameters:
context- the parser contextstatements- the parsed statements (mutable)
-
performInterpreter
Description copied from class:AbstractSqlParserPerform interpretation/evaluation on parsed statements.Hook Method: Default implementation does nothing. Override to provide AST interpretation/evaluation.
Typical Implementation:
- Execute simple SQL statements
- Evaluate expressions
- Constant folding
- Static analysis
- Overrides:
performInterpreterin classAbstractSqlParser- Parameters:
context- the parser contextstatements- the parsed statements (mutable)
-