Search in sources :

Example 1 with QueryAnalyzer

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

the class QueryEngine method buildQueryLogicalPlan.

private PlanNode buildQueryLogicalPlan(String sqlExpression, final Query query, final MetaStore tempMetaStore) {
    final QueryAnalyzer queryAnalyzer = new QueryAnalyzer(tempMetaStore, ksqlEngine.getFunctionRegistry());
    final Analysis analysis = queryAnalyzer.analyze(sqlExpression, query);
    final AggregateAnalysis aggAnalysis = queryAnalyzer.analyzeAggregate(query, analysis);
    final PlanNode logicalPlan = new LogicalPlanner(analysis, aggAnalysis, ksqlEngine.getFunctionRegistry()).buildPlan();
    if (logicalPlan instanceof KsqlStructuredDataOutputNode) {
        KsqlStructuredDataOutputNode ksqlStructuredDataOutputNode = (KsqlStructuredDataOutputNode) logicalPlan;
        StructuredDataSource structuredDataSource = new KsqlStream(sqlExpression, ksqlStructuredDataOutputNode.getId().toString(), ksqlStructuredDataOutputNode.getSchema(), ksqlStructuredDataOutputNode.getKeyField(), ksqlStructuredDataOutputNode.getTimestampField() == null ? ksqlStructuredDataOutputNode.getTheSourceNode().getTimestampField() : ksqlStructuredDataOutputNode.getTimestampField(), ksqlStructuredDataOutputNode.getKsqlTopic());
        tempMetaStore.putTopic(ksqlStructuredDataOutputNode.getKsqlTopic());
        tempMetaStore.putSource(structuredDataSource.cloneWithTimeKeyColumns());
    }
    return logicalPlan;
}
Also used : StructuredDataSource(io.confluent.ksql.metastore.StructuredDataSource) KsqlStream(io.confluent.ksql.metastore.KsqlStream) PlanNode(io.confluent.ksql.planner.plan.PlanNode) LogicalPlanner(io.confluent.ksql.planner.LogicalPlanner) Analysis(io.confluent.ksql.analyzer.Analysis) AggregateAnalysis(io.confluent.ksql.analyzer.AggregateAnalysis) QueryAnalyzer(io.confluent.ksql.analyzer.QueryAnalyzer) AggregateAnalysis(io.confluent.ksql.analyzer.AggregateAnalysis) KsqlStructuredDataOutputNode(io.confluent.ksql.planner.plan.KsqlStructuredDataOutputNode)

Aggregations

AggregateAnalysis (io.confluent.ksql.analyzer.AggregateAnalysis)1 Analysis (io.confluent.ksql.analyzer.Analysis)1 QueryAnalyzer (io.confluent.ksql.analyzer.QueryAnalyzer)1 KsqlStream (io.confluent.ksql.metastore.KsqlStream)1 StructuredDataSource (io.confluent.ksql.metastore.StructuredDataSource)1 LogicalPlanner (io.confluent.ksql.planner.LogicalPlanner)1 KsqlStructuredDataOutputNode (io.confluent.ksql.planner.plan.KsqlStructuredDataOutputNode)1 PlanNode (io.confluent.ksql.planner.plan.PlanNode)1