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
@@ -0,0 +1,27 @@
package fr.inria.corese.core.next.query.api.exception;

/**
* Thrown when a syntactically valid query uses a feature not implemented by the current next pipeline.
*/
@SuppressWarnings("java:S110")
public class UnsupportedQueryFeatureException extends QueryException {

/**
* Constructs an UnsupportedQueryFeatureException with a detail message.
*
* @param message the detail message explaining which query feature is not supported
*/
public UnsupportedQueryFeatureException(String message) {
super(message);
}

/**
* Constructs an UnsupportedQueryFeatureException with a detail message and cause.
*
* @param message the detail message explaining which query feature is not supported
* @param cause the underlying cause that exposed the unsupported feature
*/
public UnsupportedQueryFeatureException(String message, Throwable cause) {
super(message, cause);
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package fr.inria.corese.core.next.query.impl.sparql.bridge;

import fr.inria.corese.core.next.query.api.exception.UnsupportedQueryFeatureException;
import fr.inria.corese.core.next.query.impl.sparql.ast.*;
import fr.inria.corese.core.next.query.impl.sparql.ast.path.PathAst;
import fr.inria.corese.core.next.query.impl.sparql.ast.path.PredicatePathAst;
Expand Down Expand Up @@ -191,20 +192,20 @@ static TermAst simplePredicate(PathAst path) {
if (path instanceof PredicatePathAst(TermAst predicate)) {
return predicate;
}
throw new UnsupportedOperationException(
"Property path bridge compilation is not supported yet for: "
throw new UnsupportedQueryFeatureException(
"Property path bridge compilation is not supported yet by the next pipeline for: "
+ path.getClass().getSimpleName());
}

private static void rejectUnsupportedAskClauses(AskQueryAst askQueryAst) {
if (!askQueryAst.valuesClause().mappings().isEmpty()) {
throw new UnsupportedOperationException(
"Inline VALUES is not supported yet for ASK (values handling is a follow-up)");
throw new UnsupportedQueryFeatureException(
"Inline VALUES is not supported yet by the next pipeline for ASK");
}
SolutionModifierAst mod = askQueryAst.solutionModifier();
if (mod.hasGroupBy() || mod.hasHaving() || mod.distinct() || mod.reduced()) {
throw new UnsupportedOperationException(
"Solution modifiers (GROUP BY, HAVING, DISTINCT, REDUCED) are not supported for ASK");
throw new UnsupportedQueryFeatureException(
"GROUP BY, HAVING, DISTINCT and REDUCED are not supported yet by the next pipeline for ASK");
}
// TODO(#388): inline VALUES needs a dedicated runtime mapping.
// TODO(#388): GROUP BY / HAVING would require aggregate-aware ASK semantics, not just field copying.
Expand All @@ -213,22 +214,23 @@ private static void rejectUnsupportedAskClauses(AskQueryAst askQueryAst) {

private static void rejectUnsupportedSelectClauses(SelectQueryAst selectQueryAst) {
if (!selectQueryAst.valuesClause().mappings().isEmpty()) {
throw new UnsupportedOperationException("VALUES is not supported yet when building a next Query");
throw new UnsupportedQueryFeatureException(
"Inline VALUES is not supported yet by the next pipeline for SELECT");
}
ProjectionAst projection = selectQueryAst.projection();
if (!projection.expressionTerms().isEmpty() || !projection.expressionBoundVariables().isEmpty()) {
throw new UnsupportedOperationException(
"SELECT expressions are not supported yet when building a next Query");
throw new UnsupportedQueryFeatureException(
"SELECT expressions and aliases are not supported yet by the next pipeline");
}
SolutionModifierAst solutionModifier = selectQueryAst.solutionModifier();
if (solutionModifier.reduced()) {
throw new UnsupportedOperationException("REDUCED is not supported yet when building a next Query");
throw new UnsupportedQueryFeatureException("REDUCED is not supported yet by the next pipeline for SELECT");
}
if (solutionModifier.hasGroupBy()) {
throw new UnsupportedOperationException("GROUP BY is not supported yet when building a next Query");
throw new UnsupportedQueryFeatureException("GROUP BY is not supported yet by the next pipeline for SELECT");
}
if (solutionModifier.hasHaving()) {
throw new UnsupportedOperationException("HAVING is not supported yet when building a next Query");
throw new UnsupportedQueryFeatureException("HAVING is not supported yet by the next pipeline for SELECT");
}
// TODO(#387): inline VALUES needs a dedicated runtime mapping.
// TODO(#387): SELECT expressions need a clear runtime story for aliases and reuse in later clauses.
Expand All @@ -238,13 +240,13 @@ private static void rejectUnsupportedSelectClauses(SelectQueryAst selectQueryAst

private static void rejectUnsupportedDescribeClauses(DescribeQueryAst describeQueryAst) {
if (!describeQueryAst.valuesClause().mappings().isEmpty()) {
throw new UnsupportedOperationException(
"Inline VALUES is not supported yet for DESCRIBE (values handling is a follow-up)");
throw new UnsupportedQueryFeatureException(
"Inline VALUES is not supported yet by the next pipeline for DESCRIBE");
}
SolutionModifierAst mod = describeQueryAst.solutionModifier();
if (mod.hasGroupBy() || mod.hasHaving() || mod.distinct() || mod.reduced()) {
throw new UnsupportedOperationException(
"Solution modifiers (GROUP BY, HAVING, DISTINCT, REDUCED) are not supported for DESCRIBE");
throw new UnsupportedQueryFeatureException(
"GROUP BY, HAVING, DISTINCT and REDUCED are not supported yet by the next pipeline for DESCRIBE");
}
// TODO(#390): inline VALUES needs a dedicated runtime mapping.
// TODO(#390): GROUP BY / HAVING would require aggregate-aware DESCRIBE semantics, not just field copying.
Expand Down Expand Up @@ -465,13 +467,13 @@ private void applyLimitOffset(Query query, SolutionModifierAst solutionModifier)

private static void rejectUnsupportedConstructClauses(ConstructQueryAst constructQueryAst) {
if (!constructQueryAst.valuesClause().mappings().isEmpty()) {
throw new UnsupportedOperationException(
"Inline VALUES is not supported yet for CONSTRUCT (values handling is a follow-up)");
throw new UnsupportedQueryFeatureException(
"Inline VALUES is not supported yet by the next pipeline for CONSTRUCT");
}
SolutionModifierAst mod = constructQueryAst.solutionModifier();
if (mod.hasGroupBy() || mod.hasHaving() || mod.distinct() || mod.reduced()) {
throw new UnsupportedOperationException(
"Solution modifiers (GROUP BY, HAVING, DISTINCT, REDUCED) are not supported for CONSTRUCT");
throw new UnsupportedQueryFeatureException(
"GROUP BY, HAVING, DISTINCT and REDUCED are not supported yet by the next pipeline for CONSTRUCT");
}
// TODO(#389): inline VALUES needs a dedicated runtime mapping.
// TODO(#389): GROUP BY / HAVING would require aggregate-aware CONSTRUCT semantics, not just field copying.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package fr.inria.corese.core.next.query.impl.sparql.bridge;

import fr.inria.corese.core.next.data.impl.io.common.IOConstants;
import fr.inria.corese.core.next.query.impl.sparql.ast.*;
package fr.inria.corese.core.next.query.impl.sparql.bridge;

import fr.inria.corese.core.next.data.impl.io.common.IOConstants;
import fr.inria.corese.core.next.query.api.exception.UnsupportedQueryFeatureException;
import fr.inria.corese.core.next.query.impl.sparql.ast.*;
import fr.inria.corese.core.next.query.impl.sparql.ast.constraint.*;
import fr.inria.corese.core.next.query.kgram.api.core.Filter;
import fr.inria.corese.core.next.util.StringUtils;
Expand Down Expand Up @@ -211,14 +212,15 @@ private static Expression constraintToExpression(ConstraintAst constraint) {
case Sha512Ast sha512Ast ->
functionTerm("sha512", convert(sha512Ast.argument()));
case ExistsAst existsAst ->
throw new UnsupportedOperationException(
"EXISTS { ... } conversion requires GroupGraphPatternAst → Exp (see CoreseAstQueryBuilder)");
case NotExistsAst notExistsAst ->
throw new UnsupportedOperationException(
"NOT EXISTS { ... } conversion requires GroupGraphPatternAst → Exp (see CoreseAstQueryBuilder)");
default ->
throw new UnsupportedOperationException(
"Unsupported constraint AST: " + constraint.getClass().getName());
throw new UnsupportedQueryFeatureException(
"EXISTS filters are not supported yet by the next pipeline");
case NotExistsAst notExistsAst ->
throw new UnsupportedQueryFeatureException(
"NOT EXISTS filters are not supported yet by the next pipeline");
default ->
throw new UnsupportedQueryFeatureException(
"Filter expression is not supported yet by the next pipeline: "
+ constraint.getClass().getSimpleName());
};
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package fr.inria.corese.core.next.query.impl.sparql.bridge;

import fr.inria.corese.core.next.query.api.exception.UnsupportedQueryFeatureException;
import fr.inria.corese.core.next.query.impl.sparql.ast.BgpAst;
import fr.inria.corese.core.next.query.impl.sparql.ast.BindAst;
import fr.inria.corese.core.next.query.impl.sparql.ast.FilterAst;
Expand Down Expand Up @@ -57,8 +58,9 @@ Exp compile(PatternAst pattern) {
case BindAst bind -> compileBind(bind);
case ServiceAst service -> compileService(service);
case GroupGraphPatternAst group -> compileGroup(group);
default -> throw new UnsupportedOperationException(
"WHERE compilation not yet supported for: " + pattern.getClass().getSimpleName());
default -> throw new UnsupportedQueryFeatureException(
"WHERE pattern is not supported yet by the next pipeline: "
+ pattern.getClass().getSimpleName());
};
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package fr.inria.corese.core.next.query.impl.sparql.bridge;

import fr.inria.corese.core.next.query.api.exception.UnsupportedQueryFeatureException;
import fr.inria.corese.core.next.query.impl.parser.AbstractSparqlParserFeatureTest;
import fr.inria.corese.core.next.query.impl.parser.SparqlParser;
import fr.inria.corese.core.next.query.impl.sparql.ast.AskQueryAst;
Expand Down Expand Up @@ -112,14 +113,14 @@ void appliesFromNamedClause() {
}

@Test
@DisplayName("Inline VALUES is not supported yet → UnsupportedOperationException")
@DisplayName("Inline VALUES is not supported yet -> UnsupportedQueryFeatureException")
void rejectsValuesClause() {
ValuesAst values = new ValuesAst(List.of(
new ValueMappingAst(Map.of(new VarAst("s"), new IriAst("http://example.org/x")))));
AskQueryAst ask = new AskQueryAst(
DatasetClauseAst.none(), whereOneTriple(), null, null, values);

assertThrows(UnsupportedOperationException.class, () -> builder.toNextQuery(ask));
assertThrows(UnsupportedQueryFeatureException.class, () -> builder.toNextQuery(ask));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package fr.inria.corese.core.next.query.impl.sparql.bridge;

import fr.inria.corese.core.next.query.api.exception.UnsupportedQueryFeatureException;
import fr.inria.corese.core.next.query.impl.parser.AbstractSparqlParserFeatureTest;
import fr.inria.corese.core.next.query.impl.parser.SparqlParser;
import fr.inria.corese.core.next.query.impl.sparql.ast.*;
Expand Down Expand Up @@ -156,12 +157,12 @@ void appliesOrderBy() {
}

@Test
@DisplayName("Inline VALUES is not supported yet -> UnsupportedOperationException")
@DisplayName("Inline VALUES is not supported yet -> UnsupportedQueryFeatureException")
void rejectsValuesClause() {
ValuesAst values = new ValuesAst(List.of(new ValueMappingAst(Map.of(new VarAst("x"), new IriAst("http://example.org/v")))));
ConstructQueryAst construct = new ConstructQueryAst(template(new TriplePatternAst(new VarAst("x"), new VarAst("p"), new VarAst("o"))), DatasetClauseAst.none(), whereSPO(), null, null, values);

assertThrows(UnsupportedOperationException.class, () -> builder.toNextQuery(construct));
assertThrows(UnsupportedQueryFeatureException.class, () -> builder.toNextQuery(construct));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package fr.inria.corese.core.next.query.impl.sparql.bridge;

import fr.inria.corese.core.next.query.api.exception.UnsupportedQueryFeatureException;
import fr.inria.corese.core.next.query.impl.parser.SparqlParser;
import fr.inria.corese.core.next.query.impl.sparql.ast.*;
import fr.inria.corese.core.next.query.kgram.api.core.Node;
Expand Down Expand Up @@ -160,25 +161,25 @@ void appliesOrderBy() {
}

@Test
@DisplayName("Inline VALUES is not supported yet → UnsupportedOperationException")
@DisplayName("Inline VALUES is not supported yet -> UnsupportedQueryFeatureException")
void rejectsValuesClause() {
ValuesAst values = new ValuesAst(List.of(
new ValueMappingAst(Map.of(new VarAst("x"), new IriAst("http://example.org/v")))));
DescribeQueryAst describe = new DescribeQueryAst(
DatasetClauseAst.none(), List.of(new VarAst("x")), whereBindingX(), null, null, values);

assertThrows(UnsupportedOperationException.class, () -> builder.toNextQuery(describe));
assertThrows(UnsupportedQueryFeatureException.class, () -> builder.toNextQuery(describe));
}

@Test
@DisplayName("Unsupported solution modifier (e.g. DISTINCT) → UnsupportedOperationException")
@DisplayName("Unsupported solution modifier (e.g. DISTINCT) -> UnsupportedQueryFeatureException")
void rejectsUnsupportedModifier() {
SolutionModifierAst mod = SolutionModifierAst.withoutGroupBy(
true, false, List.of(), null, null);
DescribeQueryAst describe = new DescribeQueryAst(
DatasetClauseAst.none(), List.of(new VarAst("x")), whereBindingX(), mod);

assertThrows(UnsupportedOperationException.class, () -> builder.toNextQuery(describe));
assertThrows(UnsupportedQueryFeatureException.class, () -> builder.toNextQuery(describe));
}

@Test
Expand Down
Loading
Loading