Olap4j contains an implementation of an MDX parser. The default
implementation is org.olap4j.mdx.parser.impl.DefaultMdxParserImpl, but you
shouldn't use that class directly. Get it via the connection's parser
factory:
OlapConnection connection;
MdxParser parser =
connection.getParserFactory().createMdxParser(connection);
SelectNode select = parser.parseSelect("SELECT FROM [Sales]");
If different servers have different variants of MDX, the driver will need to
create a specific parser by overriding the parser factory. I don't expect
that that will need to happen very often, because providers usually extend
MDX by adding new functions, not by adding new syntactic constructs.
But for a client application it is simple: just use the parser that your
olap4j connection gives you.
> This
> solution is better and could even be used on Olap4J (more challenger,
> too).
What's good about it? I'd like to learn/reuse if possible.
Julian
The olap4 functional spec has some sample code:
OlapConnection connection;
MdxParserFactory parserFactory =
connection.getParserFactory();
MdxParser parser =
parserFactory.createMdxParser(connection);
SelectNode select =
parser.parseSelect("SELECT FROM [Sales]");
MdxValidator validator =
parserFactory.createMdxValidator(connection);
select = validator.validate(select);
http://www.olap4j.org/olap4j_fs.html#MDX_parser
Does this code work? It should.
Julian
> I've tryied play with Query, QueryAxis and QueryDimension classes, but
> no success at all.
>
> And by the way, the documentation I've mentioned that is outdated is
> here: ...
If you want examples, look at the olap4j test suite. There are lots of them,
and they are all guaranteed to work. :)
> Bill Seyler wrote:
> I think when it come to Halogen what we need is the ability to parse
> MDX into a Olap4J query model. Can Olap4J do that now? If it can
> then things get really easy from the Halogen perspective.
I don't think it can. Query models are very incomplete right now. Not ready
for development unless you are willing to roll up your sleeves. I'd like to
have a discussion about the design of query models on the olap4j forums.
See also this thread discussing the difference between the MDX parse tree
model and the Query model in olap4j:
https://sourceforge.net/forum/message.php?msg_id=5011964
Julian