use of io.crate.analyze.ParamTypeHints in project crate by crate.
the class CreateViewPlan method ensureFormattedQueryCanStillBeAnalyzed.
private static void ensureFormattedQueryCanStillBeAnalyzed(RelationName viewName, NodeContext nodeCtx, Schemas schemas, CoordinatorTxnCtx txnCtx, String formattedQuery, boolean replaceExisting) {
RelationAnalyzer analyzer = new RelationAnalyzer(nodeCtx, schemas);
Query query = (Query) SqlParser.createStatement(formattedQuery);
if (replaceExisting) {
new EnsureNoSelfReference(viewName, txnCtx.sessionContext().searchPath()).raiseOnSelfReference(query);
}
analyzer.analyze(query, txnCtx, new ParamTypeHints(List.of()) {
@Override
public Symbol apply(@Nullable ParameterExpression input) {
throw new UnsupportedOperationException("View definition must not contain any parameter placeholders");
}
});
}
use of io.crate.analyze.ParamTypeHints in project crate by crate.
the class Session method analyze.
public void analyze(String statementName, Statement statement, List<DataType> paramTypes, @Nullable String query) {
AnalyzedStatement analyzedStatement;
DataType[] parameterTypes;
try {
analyzedStatement = analyzer.analyze(statement, sessionContext, new ParamTypeHints(paramTypes));
parameterTypes = parameterTypeExtractor.getParameterTypes(x -> Relations.traverseDeepSymbols(analyzedStatement, x));
} catch (Throwable t) {
jobsLogs.logPreExecutionFailure(UUIDs.dirtyUUID(), query == null ? statementName : query, SQLExceptions.messageOf(t), sessionContext.sessionUser());
throw t;
}
preparedStatements.put(statementName, new PreparedStmt(statement, analyzedStatement, query, parameterTypes));
}
Aggregations