use of io.crate.metadata.table.Operation in project crate by crate.
the class RelationAnalyzer method visitTableFunction.
@Override
public AnalyzedRelation visitTableFunction(TableFunction node, StatementAnalysisContext statementContext) {
RelationAnalysisContext context = statementContext.currentRelationContext();
ExpressionAnalyzer expressionAnalyzer = new ExpressionAnalyzer(functions, statementContext.sessionContext(), statementContext.convertParamFunction(), new FieldProvider() {
@Override
public Symbol resolveField(QualifiedName qualifiedName, Operation operation) {
throw new UnsupportedOperationException("Can only resolve literals");
}
@Override
public Symbol resolveField(QualifiedName qualifiedName, @Nullable List path, Operation operation) {
throw new UnsupportedOperationException("Can only resolve literals");
}
}, null);
Function function = (Function) expressionAnalyzer.convert(node.functionCall(), context.expressionAnalysisContext());
FunctionImplementation functionImplementation = functions.getSafe(function.info().ident());
if (functionImplementation.info().type() != FunctionInfo.Type.TABLE) {
throw new UnsupportedFeatureException("Non table function " + function.info().ident().name() + " is not supported in from clause");
}
TableFunctionImplementation tableFunction = (TableFunctionImplementation) functionImplementation;
TableInfo tableInfo = tableFunction.createTableInfo(clusterService);
Operation.blockedRaiseException(tableInfo, statementContext.currentOperation());
TableRelation tableRelation = new TableFunctionRelation(tableInfo, tableFunction, function);
context.addSourceRelation(node.name(), tableRelation);
return tableRelation;
}
Aggregations