Class ImpalaSqlParser
- All Implemented Interfaces:
SqlParser
This parser handles Impala-specific SQL syntax including:
- Hive-compatible SQL dialect
- Backtick-quoted identifiers (`schema.table`)
- Semicolon statement delimiters
- Impala-specific functions and syntax
Design Notes:
- Extends
AbstractSqlParserusing the template method pattern - Uses
TLexerImpalafor tokenization - Uses
TParserImpalafor parsing - Shares tokenization logic with Hive (dohivetexttotokenlist)
- Delimiter character: ';' for SQL statements
Usage Example:
// Get Impala parser from factory
SqlParser parser = SqlParserFactory.get(EDbVendor.dbvimpala);
// Build context
ParserContext context = new ParserContext.Builder(EDbVendor.dbvimpala)
.sqlText("SELECT * FROM employees WHERE dept_id = 10")
.build();
// Parse
SqlParseResult result = parser.parse(context);
// Access statements
TStatementList statements = result.getSqlStatements();
- 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 Impala-specific raw statement extraction logic.protected TCustomLexergetLexer(ParserContext context) Return the Impala lexer instance.protected TCustomParsergetParser(ParserContext context, TSourceTokenList tokens) Return the Impala SQL 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 Impala-specific semantic analysis using TSQLResolver.protected voidSetup Impala parser for raw statement extraction.protected voidCall Impala-specific tokenization logic.toString()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, towinlinebreak
-
Field Details
-
flexer
The Impala lexer used for tokenization
-
-
Constructor Details
-
ImpalaSqlParser
public ImpalaSqlParser()Construct Apache Impala SQL parser.Configures the parser for Impala 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 Impala lexer instance.- Specified by:
getLexerin classAbstractSqlParser- Parameters:
context- the parser context- Returns:
- configured lexer instance (never null)
-
getParser
Return the Impala 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)
-
tokenizeVendorSql
Call Impala-specific tokenization logic.Delegates to doimpalatexttotokenlist which internally calls dohivetexttotokenlist. Impala shares the same tokenization logic as Hive.
- Specified by:
tokenizeVendorSqlin classAbstractSqlParser
-
setupVendorParsersForExtraction
Setup Impala parser for raw statement extraction.Impala uses a single parser, so we inject sqlcmds and update the token list for the main parser only.
- Specified by:
setupVendorParsersForExtractionin classAbstractSqlParser
-
extractVendorRawStatements
Call Impala-specific raw statement extraction logic.Delegates to doimpalagetrawsqlstatements which internally calls dohivegetrawsqlstatements. Impala shares the same statement extraction logic as Hive.
- 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 Impala-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
-