Package gudusoft.gsqlparser.parser
Class NetezzaSqlParser
Object
gudusoft.gsqlparser.parser.AbstractSqlParser
gudusoft.gsqlparser.parser.NetezzaSqlParser
- All Implemented Interfaces:
SqlParser
Netezza database SQL parser implementation.
This parser handles Netezza-specific SQL syntax including:
- Netezza PL/SQL blocks (procedures, functions)
- SQL*Plus-like commands
- Netezza-specific DML/DDL
- Type casting expressions
- Special token handling (INNER, NOT DEFERRABLE, etc.)
Design Notes:
- Extends
AbstractSqlParserusing the template method pattern - Uses
TLexerNetezzafor tokenization - Uses
TParserNetezzafor parsing - Delimiter character: ';' for SQL statements
Usage Example:
// Get Netezza parser from factory
SqlParser parser = SqlParserFactory.get(EDbVendor.dbvnetezza);
// Build context
ParserContext context = new ParserContext.Builder(EDbVendor.dbvnetezza)
.sqlText("SELECT * FROM Employees WHERE DepartmentID = 10")
.build();
// Parse
SqlParseResult result = parser.parse(context);
// Access statements
TStatementList statements = result.getSqlStatements();
-
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 Netezza-specific raw statement extraction logic.protected TCustomLexergetLexer(ParserContext context) Return the Netezza lexer instance.protected TCustomParsergetParser(ParserContext context, TSourceTokenList tokens) Return the Netezza SQL parser instance with updated token list.protected TCustomParsergetSecondaryParser(ParserContext context, TSourceTokenList tokens) Return null for secondary parser (Netezza only uses one 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 Netezza-specific semantic analysis using TSQLResolver.protected voidSetup Netezza parser for raw statement extraction.protected voidCall Netezza-specific tokenization logic.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, toString, towinlinebreak
-
Field Details
-
flexer
The Netezza lexer used for tokenization
-
-
Constructor Details
-
NetezzaSqlParser
public NetezzaSqlParser()Construct Netezza SQL parser.Configures the parser for Netezza 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 Netezza lexer instance.- Specified by:
getLexerin classAbstractSqlParser- Parameters:
context- the parser context- Returns:
- configured lexer instance (never null)
-
getParser
Return the Netezza 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
Return null for secondary parser (Netezza only uses one parser).- Overrides:
getSecondaryParserin classAbstractSqlParser- Parameters:
context- the parser contexttokens- the source token list- Returns:
- secondary parser instance, or null if not needed
-
tokenizeVendorSql
Call Netezza-specific tokenization logic.Delegates to donetezzatexttotokenlist which handles Netezza's specific keyword recognition and token generation.
- Specified by:
tokenizeVendorSqlin classAbstractSqlParser
-
setupVendorParsersForExtraction
Setup Netezza parser for raw statement extraction.Netezza uses a single parser, so we inject sqlcmds and update the token list for the main parser only.
- Specified by:
setupVendorParsersForExtractionin classAbstractSqlParser
-
extractVendorRawStatements
Call Netezza-specific raw statement extraction logic.Delegates to donetezzagetrawsqlstatements which handles Netezza's statement delimiters.
- 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 Netezza-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)
-