Search in sources :

Example 1 with RelationAnalyzer

use of io.crate.analyze.relations.RelationAnalyzer 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");
        }
    });
}
Also used : Query(io.crate.sql.tree.Query) RelationAnalyzer(io.crate.analyze.relations.RelationAnalyzer) Symbol(io.crate.expression.symbol.Symbol) ParameterExpression(io.crate.sql.tree.ParameterExpression) ParamTypeHints(io.crate.analyze.ParamTypeHints)

Aggregations

ParamTypeHints (io.crate.analyze.ParamTypeHints)1 RelationAnalyzer (io.crate.analyze.relations.RelationAnalyzer)1 Symbol (io.crate.expression.symbol.Symbol)1 ParameterExpression (io.crate.sql.tree.ParameterExpression)1 Query (io.crate.sql.tree.Query)1