public class DaxSqlParser extends AbstractSqlParser
This parser handles DAX-specific SQL syntax including:
Design Notes:
AbstractSqlParser using the template method patternTLexerDax for tokenizationTParserDax for parsingUsage Example:
// Get DAX parser from factory
SqlParser parser = SqlParserFactory.get(EDbVendor.dbvdax);
// Build context
ParserContext context = new ParserContext.Builder(EDbVendor.dbvdax)
.sqlText("= CALCULATE(SUM(Sales[Amount]), ALL(Sales))")
.build();
// Parse
SqlParseResult result = parser.parse(context);
// Access statements
TStatementList statements = result.getSqlStatements();
SqlParser,
AbstractSqlParser,
TLexerDax,
TParserDaxAbstractSqlParser.PreparedSqlReader| Modifier and Type | Field and Description |
|---|---|
TLexerDax |
flexer
The DAX lexer used for tokenization
|
defaultDelimiterStr, delimiterChar, frameStack, globalContext, globalFrame, lexer, parserContext, sourcetokenlist, sqlcmds, sqlEnv, sqlstatements, syntaxErrors, vendor| Constructor and Description |
|---|
DaxSqlParser()
Construct DAX SQL parser.
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
extractVendorRawStatements(SqlParseResult.Builder builder)
Call DAX-specific raw statement extraction logic.
|
protected TCustomLexer |
getLexer(ParserContext context)
Return the DAX lexer instance.
|
protected TCustomParser |
getParser(ParserContext context,
TSourceTokenList tokens)
Return the DAX SQL parser instance with updated token list.
|
protected TCustomParser |
getSecondaryParser(ParserContext context,
TSourceTokenList tokens)
DAX does not use a secondary parser.
|
protected TStatementList |
performParsing(ParserContext context,
TCustomParser parser,
TCustomParser secondaryParser,
TSourceTokenList tokens,
TStatementList rawStatements)
Parse all raw DAX statements.
|
protected void |
setupVendorParsersForExtraction()
Setup DAX parser for raw statement extraction.
|
protected void |
tokenizeVendorSql()
Call DAX-specific tokenization logic.
|
afterStatementParsed, attemptErrorRecovery, copyErrorsFromStatement, doAfterTokenize, doExtractRawStatements, extractRawStatements, getanewsourcetoken, getDefaultDelimiterStr, getDelimiterChar, getErrorCount, getrawsqlstatements, getSyntaxErrors, getVendor, handleStatementParsingException, initializeGlobalContext, isDollarFunctionDelimiter, onRawStatementComplete, onRawStatementCompleteVendorSpecific, parse, performInterpreter, performSemanticAnalysis, performTokenization, prepareSqlReader, processTokensBeforeParse, processTokensInTokenTable, setTokenHandle, tokenize, toString, towinlinebreakpublic DaxSqlParser()
Configures the parser for DAX 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.
protected TCustomLexer getLexer(ParserContext context)
getLexer in class AbstractSqlParsercontext - the parser contextprotected TCustomParser getParser(ParserContext context, TSourceTokenList tokens)
getParser in class AbstractSqlParsercontext - the parser contexttokens - the source token listprotected TCustomParser getSecondaryParser(ParserContext context, TSourceTokenList tokens)
getSecondaryParser in class AbstractSqlParsercontext - the parser contexttokens - the source token listprotected void tokenizeVendorSql()
Delegates to dodaxsqltexttotokenlist which handles DAX's simple token iteration.
tokenizeVendorSql in class AbstractSqlParserprotected void setupVendorParsersForExtraction()
Injects shared state (sqlcmds, sourcetokenlist) into the DAX parser so it can access tokens and SQL command definitions during parsing.
setupVendorParsersForExtraction in class AbstractSqlParserprotected void extractVendorRawStatements(SqlParseResult.Builder builder)
Delegates to dodaxgetrawsqlstatements which handles DAX's statement boundary detection (based on nested parentheses and special DAX keywords).
extractVendorRawStatements in class AbstractSqlParserbuilder - the result builder to populate with raw statementsprotected TStatementList performParsing(ParserContext context, TCustomParser parser, TCustomParser secondaryParser, TSourceTokenList tokens, TStatementList rawStatements)
Iterates through all raw statements extracted by dodaxgetrawsqlstatements() and parses each one using the DAX parser.
Follows the pattern from MssqlSqlParser.performParsing()
performParsing in class AbstractSqlParsercontext - the parser contextparser - the main parser instancesecondaryParser - secondary parser (may be null)tokens - the source token listrawStatements - raw statements already extracted (never null)