use of org.apache.ignite.lang.IgniteException in project ignite-3 by apache.
the class IgnitePlanner method expandView.
/**
* {@inheritDoc}
*/
@Override
public RelRoot expandView(RelDataType rowType, String qryStr, List<String> schemaPath, List<String> viewPath) {
SqlParser parser = SqlParser.create(qryStr, parserCfg);
SqlNode sqlNode;
try {
sqlNode = parser.parseQuery();
} catch (SqlParseException e) {
// throw new IgniteSQLException("parse failed", IgniteQueryErrorCode.PARSING, e);
throw new IgniteException("parse failed", e);
}
CalciteCatalogReader catalogReader = this.catalogReader.withSchemaPath(schemaPath);
SqlValidator validator = new IgniteSqlValidator(operatorTbl, catalogReader, typeFactory, validatorCfg, ctx.parameters());
SqlToRelConverter sqlToRelConverter = sqlToRelConverter(validator, catalogReader, sqlToRelConverterCfg);
RelRoot root = sqlToRelConverter.convertQuery(sqlNode, true, false);
root = root.withRel(sqlToRelConverter.decorrelate(sqlNode, root.rel));
return trimUnusedFields(root);
}
use of org.apache.ignite.lang.IgniteException in project ignite-3 by apache.
the class RelJson method relFactory.
private static RelFactory relFactory(String typeName) {
Class<?> clazz = null;
if (!typeName.contains(".")) {
for (String pckg : PACKAGES) {
if ((clazz = classForName(pckg + typeName, true)) != null) {
break;
}
}
}
if (clazz == null) {
clazz = classForName(typeName, false);
}
assert RelNode.class.isAssignableFrom(clazz);
Constructor<RelNode> constructor;
try {
constructor = (Constructor<RelNode>) clazz.getConstructor(RelInput.class);
} catch (NoSuchMethodException e) {
throw new IgniteException("class does not have required constructor, " + clazz + "(RelInput)");
}
BlockBuilder builder = new BlockBuilder();
ParameterExpression input = Expressions.parameter(RelInput.class);
builder.add(Expressions.new_(constructor, input));
MethodDeclaration declaration = Expressions.methodDecl(Modifier.PUBLIC, RelNode.class, "apply", asList(input), builder.toBlock());
return Commons.compile(RelFactory.class, Expressions.toString(asList(declaration), "\n", true));
}
use of org.apache.ignite.lang.IgniteException in project ignite-3 by apache.
the class RelJsonReader method read.
/**
* Read.
* TODO Documentation https://issues.apache.org/jira/browse/IGNITE-15859
*/
public RelNode read(String s) {
try {
lastRel = null;
Map<String, Object> o = mapper.readValue(s, TYPE_REF);
List<Map<String, Object>> rels = (List) o.get("rels");
readRels(rels);
return lastRel;
} catch (IOException e) {
throw new IgniteException(e);
}
}
use of org.apache.ignite.lang.IgniteException in project ignite-3 by apache.
the class RootNode method close.
/**
* {@inheritDoc}
*/
@Override
public void close() {
if (closed) {
return;
}
lock.lock();
try {
if (waiting != -1 || !outBuff.isEmpty()) {
ex.compareAndSet(null, new IgniteException("Query was cancelled"));
}
// an exception has to be set first to get right check order
closed = true;
cond.signalAll();
} finally {
lock.unlock();
}
onClose.run();
}
use of org.apache.ignite.lang.IgniteException in project ignite-3 by apache.
the class RelJsonWriter method asString.
/**
* AsString.
* TODO Documentation https://issues.apache.org/jira/browse/IGNITE-15859
*/
public String asString() {
try {
StringWriter writer = new StringWriter();
ObjectMapper mapper = new ObjectMapper();
ObjectWriter writer0 = pretty ? mapper.writer(new DefaultPrettyPrinter()) : mapper.writer();
writer0.withRootName("rels").writeValue(writer, relList);
return writer.toString();
} catch (IOException e) {
throw new IgniteException(e);
}
}
Aggregations