Skip to content

Commit 31b402a

Browse files
committed
run sql query for any exception
Signed-off-by: dbulahov <bulahovdenis@gmail.com>
1 parent cfcc571 commit 31b402a

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

common/src/main/java/org/eclipse/daanse/olap/connection/ConnectionBase.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,15 +114,16 @@ public QueryComponent parseStatement(
114114
parser = getContext().getMdxParserProvider().newParser(queryToParse, funTable.getPropertyWords());
115115
MdxStatement mdxStatement = parser.parseMdxStatement();
116116
return getQueryProvider().createQuery(statement, mdxStatement, strictValidation);
117-
} catch (MdxParserException mdxPE) {
117+
} catch (Exception mdxPE) {
118118

119119
Optional<SqlGuardFactory> oSqlGuardFactory = getContext().getSqlGuardFactory();
120120
if (oSqlGuardFactory.isEmpty()) {
121121
throw new FailedToParseQueryException(queryToParse, mdxPE);
122122
} else {
123123
List<DatabaseSchema> ds = (List<DatabaseSchema>) this.getCatalogReader().getDatabaseSchemas();
124124
org.eclipse.daanse.sql.guard.api.elements.DatabaseCatalog dc = new DatabaseCatalogImpl("", ds);
125-
SqlGuard guard = oSqlGuardFactory.get().create("", "", dc, List.of(), this.getContext().getDialect());
125+
//TODO need resolve function list from other place
126+
SqlGuard guard = oSqlGuardFactory.get().create("", "", dc, List.of("sum", "avg", "min", "max", "count", "concat"), this.getContext().getDialect());
126127
// TODO add white list functions
127128
try {
128129
String sanetizedSql = guard.guard(queryToParse);

common/src/test/java/org/eclipse/daanse/olap/function/def/crossjoin/CrossJoinTest.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import java.util.Collections;
3333
import java.util.Comparator;
3434
import java.util.List;
35+
import java.util.Optional;
3536

3637
import org.eclipse.daanse.mdx.model.api.expression.operation.FunctionOperationAtom;
3738
import org.eclipse.daanse.mdx.model.api.expression.operation.OperationAtom;
@@ -64,6 +65,7 @@
6465
import org.eclipse.daanse.olap.function.core.FunctionParameterR;
6566
import org.eclipse.daanse.olap.query.component.ResolvedFunCallImpl;
6667
import org.eclipse.daanse.olap.api.execution.ExecutionContext;
68+
import org.eclipse.daanse.olap.api.execution.ExecutionMetadata;
6769
import org.eclipse.daanse.olap.execution.ExecutionImpl;
6870
import org.junit.jupiter.api.AfterEach;
6971
import org.junit.jupiter.api.BeforeEach;
@@ -137,7 +139,8 @@ void testListTupleListTupleIterCalc() {
137139
when(rolapConnection.getContext()).thenReturn(context);
138140
when(statement.getDaanseConnection()).thenReturn(rolapConnection);
139141
when(excMock.getDaanseStatement()).thenReturn(statement);
140-
ExecutionContext executionContext = mock(ExecutionContext.class);
142+
ExecutionMetadata executionMetadata = mock(ExecutionMetadata.class);
143+
ExecutionContext executionContext = ExecutionContext.root(Optional.empty(), executionMetadata);
141144
when(excMock.asContext()).thenReturn(executionContext);
142145
CrossJoinIterCalc calc =
143146
new CrossJoinIterCalc( getResolvedFunCall(), null, crossJoinFunDef.getCtag() );

0 commit comments

Comments
 (0)