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);
}
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);
}
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);
}
Aggregations