Search in sources :

Example 1 with FilterTypeValidator

use of io.confluent.ksql.analyzer.FilterTypeValidator in project ksql by confluentinc.

the class LogicalPlanner method buildFilterNode.

private FilterNode buildFilterNode(final PlanNode sourcePlanNode, final Expression filterExpression) {
    final FilterTypeValidator validator = new FilterTypeValidator(sourcePlanNode.getSchema(), metaStore, FilterType.WHERE);
    validator.validateFilterExpression(filterExpression);
    return new FilterNode(new PlanNodeId("WhereFilter"), sourcePlanNode, filterExpression);
}
Also used : PlanNodeId(io.confluent.ksql.planner.plan.PlanNodeId) FilterNode(io.confluent.ksql.planner.plan.FilterNode) QueryFilterNode(io.confluent.ksql.planner.plan.QueryFilterNode) FilterTypeValidator(io.confluent.ksql.analyzer.FilterTypeValidator)

Example 2 with FilterTypeValidator

use of io.confluent.ksql.analyzer.FilterTypeValidator in project ksql by confluentinc.

the class LogicalPlanner method buildQueryLogicalPlan.

public OutputNode buildQueryLogicalPlan(final QueryPlannerOptions queryPlannerOptions, final boolean isScalablePush) {
    final boolean isWindowed = analysis.getFrom().getDataSource().getKsqlTopic().getKeyFormat().isWindowed();
    PlanNode currentNode = buildSourceNode(isWindowed);
    if (analysis.getWhereExpression().isPresent()) {
        final Expression whereExpression = analysis.getWhereExpression().get();
        final FilterTypeValidator validator = new FilterTypeValidator(currentNode.getSchema(), metaStore, FilterType.WHERE);
        validator.validateFilterExpression(whereExpression);
        currentNode = new QueryFilterNode(new PlanNodeId("WhereFilter"), currentNode, whereExpression, metaStore, ksqlConfig, isWindowed, queryPlannerOptions);
    } else {
        if (!queryPlannerOptions.getTableScansEnabled()) {
            throw QueryFilterNode.invalidWhereClauseException("Missing WHERE clause", isWindowed);
        }
    }
    if (!isScalablePush && analysis.getLimitClause().isPresent()) {
        currentNode = buildLimitNode(currentNode, analysis.getLimitClause().getAsInt());
    }
    currentNode = new QueryProjectNode(new PlanNodeId("Project"), currentNode, analysis.getSelectItems(), metaStore, ksqlConfig, analysis, isWindowed, queryPlannerOptions, isScalablePush);
    return buildOutputNode(currentNode);
}
Also used : PlanNodeId(io.confluent.ksql.planner.plan.PlanNodeId) QueryProjectNode(io.confluent.ksql.planner.plan.QueryProjectNode) SingleSourcePlanNode(io.confluent.ksql.planner.plan.SingleSourcePlanNode) PlanNode(io.confluent.ksql.planner.plan.PlanNode) Expression(io.confluent.ksql.execution.expression.tree.Expression) WindowExpression(io.confluent.ksql.parser.tree.WindowExpression) KsqlWindowExpression(io.confluent.ksql.execution.windows.KsqlWindowExpression) SelectExpression(io.confluent.ksql.execution.plan.SelectExpression) FilterTypeValidator(io.confluent.ksql.analyzer.FilterTypeValidator) QueryFilterNode(io.confluent.ksql.planner.plan.QueryFilterNode)

Example 3 with FilterTypeValidator

use of io.confluent.ksql.analyzer.FilterTypeValidator in project ksql by confluentinc.

the class LogicalPlanner method buildAggregateNode.

private AggregateNode buildAggregateNode(final PlanNode sourcePlanNode) {
    final GroupBy groupBy = analysis.getGroupBy().orElseThrow(IllegalStateException::new);
    final List<SelectExpression> projectionExpressions = SelectionUtil.buildSelectExpressions(sourcePlanNode, analysis.getSelectItems(), getTargetSchema());
    final RewrittenAggregateAnalysis aggregateAnalysis = new RewrittenAggregateAnalysis(aggregateAnalyzer.analyze(analysis, projectionExpressions), refRewriter::process);
    final LogicalSchema schema = buildAggregateSchema(sourcePlanNode, groupBy, projectionExpressions);
    if (analysis.getHavingExpression().isPresent()) {
        final FilterTypeValidator validator = new FilterTypeValidator(sourcePlanNode.getSchema(), metaStore, FilterType.HAVING);
        validator.validateFilterExpression(analysis.getHavingExpression().get());
    }
    return new AggregateNode(new PlanNodeId("Aggregate"), sourcePlanNode, schema, groupBy, metaStore, analysis, aggregateAnalysis, projectionExpressions, analysis.getInto().isPresent(), ksqlConfig);
}
Also used : PlanNodeId(io.confluent.ksql.planner.plan.PlanNodeId) GroupBy(io.confluent.ksql.parser.tree.GroupBy) AggregateNode(io.confluent.ksql.planner.plan.AggregateNode) LogicalSchema(io.confluent.ksql.schema.ksql.LogicalSchema) SelectExpression(io.confluent.ksql.execution.plan.SelectExpression) FilterTypeValidator(io.confluent.ksql.analyzer.FilterTypeValidator)

Aggregations

FilterTypeValidator (io.confluent.ksql.analyzer.FilterTypeValidator)3 PlanNodeId (io.confluent.ksql.planner.plan.PlanNodeId)3 SelectExpression (io.confluent.ksql.execution.plan.SelectExpression)2 QueryFilterNode (io.confluent.ksql.planner.plan.QueryFilterNode)2 Expression (io.confluent.ksql.execution.expression.tree.Expression)1 KsqlWindowExpression (io.confluent.ksql.execution.windows.KsqlWindowExpression)1 GroupBy (io.confluent.ksql.parser.tree.GroupBy)1 WindowExpression (io.confluent.ksql.parser.tree.WindowExpression)1 AggregateNode (io.confluent.ksql.planner.plan.AggregateNode)1 FilterNode (io.confluent.ksql.planner.plan.FilterNode)1 PlanNode (io.confluent.ksql.planner.plan.PlanNode)1 QueryProjectNode (io.confluent.ksql.planner.plan.QueryProjectNode)1 SingleSourcePlanNode (io.confluent.ksql.planner.plan.SingleSourcePlanNode)1 LogicalSchema (io.confluent.ksql.schema.ksql.LogicalSchema)1