Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.eclipse.daanse.mdx.model.api.CreateMemberStatement;
import org.eclipse.daanse.mdx.model.api.CreateSetStatement;
import org.eclipse.daanse.mdx.model.api.CreateSubcubeStatement;
import org.eclipse.daanse.mdx.model.api.CallStatement;
import org.eclipse.daanse.mdx.model.api.DropSubcubeStatement;
import org.eclipse.daanse.mdx.model.api.CubeReference;
import org.eclipse.daanse.mdx.model.api.DrillthroughStatement;
Expand Down Expand Up @@ -100,6 +101,7 @@ static String dump(MdxStatement statement) {
case DropSetStatement s -> "(drop set " + list(s.names(), AstDump::name) + ")";
case CreateSubcubeStatement s -> "(create subcube " + dump(s.cubeName()) + " " + cube(s.subcube()) + ")";
case DropSubcubeStatement s -> "(drop subcube " + dump(s.cubeName()) + ")";
case CallStatement s -> "(call " + dump(s.procedure()) + " on=" + s.cube().map(c -> dump(c)).orElse("-") + ")";
};
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* Copyright (c) 2026 Contributors to the Eclipse Foundation.
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* SmartCity Jena - initial
* Stefan Bischof (bipolis.org) - initial
*/
package org.eclipse.daanse.mdx.model.api;

import java.util.Optional;

import org.eclipse.daanse.mdx.model.api.expression.MdxExpression;
import org.eclipse.daanse.mdx.model.api.expression.NameObjectIdentifier;

/**
* CallStatement Statement
* Syntax CALL SP_Name [ ( SP_Argument [, SP_Argument ...] ) ] [ ON Cube_Expression ]
* <p>
* Runs a stored procedure outside a query. {@link #procedure()} is the tree the same text gives as an expression: a
* method call on the qualifier, e.g. {@code MyAssembly.MyClass.Proc(a, b)} is the method {@code Proc} with the
* arguments {@code MyAssembly.MyClass}, {@code a}, {@code b}; an unqualified {@code Proc(a)} is a function call; a
* name without parentheses is a compound id. The older form {@code MyAssembly!MyClass!Proc(a)} gives the same tree.
* The parser does not resolve the name.
*
* @see <a href="https://learn.microsoft.com/en-us/sql/mdx/mdx-data-manipulation-call">CALL</a>
*/
public non-sealed interface CallStatement extends MdxStatement {

MdxExpression procedure();

/** The cube after ON; empty without ON, the procedure then runs on the current cube. */
Optional<NameObjectIdentifier> cube();
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@
public sealed interface MdxStatement permits SelectStatement, DrillthroughStatement, ExplainStatement,
RefreshStatement, UpdateStatement, TransactionStatement,
CreateMemberStatement, CreateSetStatement, DropMemberStatement, DropSetStatement,
CreateSubcubeStatement, DropSubcubeStatement {
CreateSubcubeStatement, DropSubcubeStatement, CallStatement {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* Copyright (c) 2026 Contributors to the Eclipse Foundation.
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* SmartCity Jena - initial
* Stefan Bischof (bipolis.org) - initial
*/
package org.eclipse.daanse.mdx.model.record;

import java.util.Objects;
import java.util.Optional;

import org.eclipse.daanse.mdx.model.api.CallStatement;
import org.eclipse.daanse.mdx.model.api.expression.MdxExpression;
import org.eclipse.daanse.mdx.model.api.expression.NameObjectIdentifier;

public record CallStatementR(MdxExpression procedure, Optional<NameObjectIdentifier> cube) implements CallStatement {

public CallStatementR {
Objects.requireNonNull(procedure, "procedure must not be null");
Objects.requireNonNull(cube, "cube must not be null");
}
}
40 changes: 34 additions & 6 deletions parser.ccc/src/main/ccc/Grammer.ccc
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ import java.util.concurrent.CancellationException;
import org.eclipse.daanse.mdx.model.api.CreateMemberStatement;
import org.eclipse.daanse.mdx.model.api.CreateSetStatement;
import org.eclipse.daanse.mdx.model.api.CreateSubcubeStatement;
import org.eclipse.daanse.mdx.model.api.CallStatement;
import org.eclipse.daanse.mdx.model.api.DropSubcubeStatement;
import org.eclipse.daanse.mdx.model.api.CubeReference;
import org.eclipse.daanse.mdx.model.api.DrillthroughStatement;
Expand Down Expand Up @@ -94,6 +95,7 @@ import org.eclipse.daanse.mdx.model.api.select.SelectWithClause;
import org.eclipse.daanse.mdx.model.record.CreateMemberStatementR;
import org.eclipse.daanse.mdx.model.record.CreateSetStatementR;
import org.eclipse.daanse.mdx.model.record.CreateSubcubeStatementR;
import org.eclipse.daanse.mdx.model.record.CallStatementR;
import org.eclipse.daanse.mdx.model.record.DropSubcubeStatementR;
import org.eclipse.daanse.mdx.model.record.DrillthroughStatementR;
import org.eclipse.daanse.mdx.model.record.DropMemberStatementR;
Expand Down Expand Up @@ -574,6 +576,9 @@ MdxStatement parseMdxStatement :
SCAN 0 {isWord(1, "DROP") && isWord(2, "SUBCUBE")} =>
mdxStatement = parseDropSubcubeStatement
|
SCAN 0 {isWord(1, "CALL")} =>
mdxStatement = parseCallStatement
|
SCAN 0 {isWord(1, "DROP") && getToken(2).getType() == SET} =>
mdxStatement = parseDropSetStatement
|
Expand Down Expand Up @@ -1574,6 +1579,7 @@ MdxExpression parseAtom :
MdxExpression expression;
NameObjectIdentifier nameObjectIdentifier;
List < MdxExpression > expressions;
List < ObjectIdentifier > qualifiers = null;
}
< SINGLE_QUOTED_STRING >
{
Expand Down Expand Up @@ -1631,15 +1637,17 @@ MdxExpression parseAtom :
|
// Function call "foo(a, b)" or "whiz!bang!foo(a, b)".
// Properties "x.PROP" and methods "exp.meth(a)" are in primary().
// The qualifiers of whiz!bang!foo(a, b) are kept: it is the method foo on whiz.bang, as whiz.bang.foo(a, b) is.
nameObjectIdentifier = parseNameObjectIdentifier
(
< BANG > nameObjectIdentifier = parseNameObjectIdentifier
< BANG >
{
// We support the syntax for qualifying function names with package
// names separated by bang ('!'), e.g. 'whiz!bang!foo(a, b)'
// but currently we ignore the qualifiers. The previous example is
// equivalent to 'foo(a, b)'.
if (qualifiers == null) {
qualifiers = new ArrayList<>();
}
qualifiers.add(nameObjectIdentifier);
}
nameObjectIdentifier = parseNameObjectIdentifier
)*
(
< LPAREN >
Expand All @@ -1658,7 +1666,8 @@ MdxExpression parseAtom :
}
)
{
return MdxParserUtil.createCall(null, nameObjectIdentifier, expressions, this.propertyWords);
return MdxParserUtil.createCall(qualifiers == null ? null : new CompoundIdR(qualifiers), nameObjectIdentifier,
expressions, this.propertyWords);
}
;

Expand Down Expand Up @@ -1954,6 +1963,25 @@ DropSubcubeStatement parseDropSubcubeStatement :
}
;

// <callStatement> ::= CALL <procedure> [ ( <argument> [ , <argument> ]... ) ] [ ON <cubeName> ]
// CALL is a word, not a token. The procedure is read as a primary expression: a.b.Proc(x) is the method Proc on a.b,
// Proc(x) a function, a.b.Proc without parentheses a compound id. The older a!b!Proc(x) gives the same tree.
// https://learn.microsoft.com/en-us/sql/mdx/mdx-data-manipulation-call
CallStatement parseCallStatement :
{
MdxExpression procedure;
NameObjectIdentifier cube = null;
}
SCAN {isWord(1, "CALL")} => < ID >
procedure = parsePrimary
(
< ON > cube = parseNameObjectIdentifier
)?
{
return new CallStatementR(procedure, Optional.ofNullable(cube));
}
;

TransactionStatement parseTransactionStatement :
{
TransactionKind kind;
Expand Down
17 changes: 13 additions & 4 deletions parser.cccx/src/main/ccc/Expressions.inc.ccc
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,16 @@ PrimaryPrefix#void :
CaseExpression
|
QualifiedIdentifier
{
// whiz!bang!foo: the qualifiers are kept, as in whiz.bang.foo
CompoundId qualified = new CompoundId();
peekNode().children().forEach(qualified::add);
if (getToken(1).getType() == LPAREN) {
pokeNode(org.eclipse.daanse.mdx.parser.cccx.MdxParserUtil.createMethodTarget(qualified, this.propertyWords));
} else {
pokeNode(org.eclipse.daanse.mdx.parser.cccx.MdxParserUtil.createCall(qualified, this.propertyWords));
}
}
|
CompoundId
{
Expand Down Expand Up @@ -575,10 +585,9 @@ INJECT QualifiedIdentifier :
QualifiedIdentifier :
NameObjectIdentifier
=>|+1
// We support the syntax for qualifying function names with package
// names separated by bang ('!'), e.g. 'whiz!bang!foo(a, b)'
// but currently we ignore the qualifiers. The previous example is
// equivalent to 'foo(a, b)'.
// Function names qualified with package names separated by bang ('!'),
// e.g. 'whiz!bang!foo(a, b)'. PrimaryPrefix turns it into the tree of
// 'whiz.bang.foo(a, b)': the method foo on whiz.bang.
(<BANG> NameObjectIdentifier)+
;

Expand Down
30 changes: 30 additions & 0 deletions parser.cccx/src/main/ccc/Statements.inc.ccc
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,9 @@ MdxStatement MdxStatement#interface :
SCAN 0 {isWord(1, "DROP") && isWord(2, "SUBCUBE")} =>
DropSubcubeStatement
|
SCAN 0 {isWord(1, "CALL")} =>
CallStatement
|
SCAN 0 {isWord(1, "DROP") && getToken(2).getType() == SET} =>
DropSetStatement
|
Expand Down Expand Up @@ -409,6 +412,33 @@ DropSubcubeStatement :
NameObjectIdentifier
;

// <callStatement> ::= CALL <procedure> [ ( <argument> [ , <argument> ]... ) ] [ ON <cubeName> ]
// CALL is a word, not a token. The procedure is read as a primary expression: a.b.Proc(x) is the method Proc on a.b,
// Proc(x) a function, a.b.Proc without parentheses a compound id. The older a!b!Proc(x) gives the same tree.

INJECT CallStatement :
import java.util.Optional;
implements MdxStatement, org.eclipse.daanse.mdx.model.api.CallStatement;
{
public org.eclipse.daanse.mdx.model.api.expression.MdxExpression procedure() {
return (org.eclipse.daanse.mdx.model.api.expression.MdxExpression) get(1);
}

public Optional<org.eclipse.daanse.mdx.model.api.expression.NameObjectIdentifier> cube() {
return firstChildOfType(ON) == null ? Optional.empty()
: Optional.of((org.eclipse.daanse.mdx.model.api.expression.NameObjectIdentifier) getLastChild());
}
}

// https://learn.microsoft.com/en-us/sql/mdx/mdx-data-manipulation-call
CallStatement :
SCAN {isWord(1, "CALL")} => < ID >
PrimaryExpression
(
< ON > NameObjectIdentifier
)?
;

INJECT DropMemberStatement :
import java.util.List;
implements MdxStatement, org.eclipse.daanse.mdx.model.api.DropMemberStatement;
Expand Down
Loading
Loading