use of io.crate.exceptions.RelationValidationException in project crate by crate.
the class AccessControlMaySeeTest method testTableScopeException.
@Test
public void testTableScopeException() throws Exception {
accessControl.ensureMaySee(new RelationValidationException(List.of(RelationName.fromIndexName("users"), RelationName.fromIndexName("my_schema.foo")), "bla"));
assertAskedAnyForTable("doc.users");
assertAskedAnyForTable("my_schema.foo");
}
use of io.crate.exceptions.RelationValidationException in project crate by crate.
the class RelationAnalyzer method visitJoin.
@Override
protected AnalyzedRelation visitJoin(Join node, StatementAnalysisContext statementContext) {
AnalyzedRelation leftRel = node.getLeft().accept(this, statementContext);
AnalyzedRelation rightRel = node.getRight().accept(this, statementContext);
RelationAnalysisContext relationContext = statementContext.currentRelationContext();
Optional<JoinCriteria> optCriteria = node.getCriteria();
Symbol joinCondition = null;
if (optCriteria.isPresent()) {
JoinCriteria joinCriteria = optCriteria.get();
if (joinCriteria instanceof JoinOn || joinCriteria instanceof JoinUsing) {
final CoordinatorTxnCtx coordinatorTxnCtx = statementContext.transactionContext();
ExpressionAnalyzer expressionAnalyzer = new ExpressionAnalyzer(coordinatorTxnCtx, nodeCtx, statementContext.paramTyeHints(), new FullQualifiedNameFieldProvider(relationContext.sources(), relationContext.parentSources(), coordinatorTxnCtx.sessionContext().searchPath().currentSchema()), new SubqueryAnalyzer(this, statementContext));
Expression expr;
if (joinCriteria instanceof JoinOn) {
expr = ((JoinOn) joinCriteria).getExpression();
} else {
expr = JoinUsing.toExpression(leftRel.relationName().toQualifiedName(), rightRel.relationName().toQualifiedName(), ((JoinUsing) joinCriteria).getColumns());
}
try {
joinCondition = expressionAnalyzer.convert(expr, relationContext.expressionAnalysisContext());
} catch (RelationUnknown e) {
throw new RelationValidationException(e.getTableIdents(), String.format(Locale.ENGLISH, "missing FROM-clause entry for relation '%s'", e.getTableIdents()));
}
} else {
throw new UnsupportedOperationException(String.format(Locale.ENGLISH, "join criteria %s not supported", joinCriteria.getClass().getSimpleName()));
}
}
relationContext.addJoinType(JoinType.values()[node.getType().ordinal()], joinCondition);
return null;
}
Aggregations