Search in sources :

Example 1 with QueryParseResult

use of com.hazelcast.jet.sql.impl.parse.QueryParseResult in project hazelcast by hazelcast.

the class CalciteSqlOptimizer method prepare.

@Override
public SqlPlan prepare(OptimizationTask task) {
    // 1. Prepare context.
    int memberCount = nodeEngine.getClusterService().getSize(MemberSelectors.DATA_MEMBER_SELECTOR);
    OptimizerContext context = OptimizerContext.create(task.getSchema(), task.getSearchPaths(), task.getArguments(), memberCount, iMapResolver);
    // 2. Parse SQL string and validate it.
    QueryParseResult parseResult = context.parse(task.getSql());
    // 3. Create plan.
    return createPlan(task, parseResult, context);
}
Also used : QueryParseResult(com.hazelcast.jet.sql.impl.parse.QueryParseResult)

Example 2 with QueryParseResult

use of com.hazelcast.jet.sql.impl.parse.QueryParseResult in project hazelcast by hazelcast.

the class OptimizerTestSupport method optimizeLogicalInternal.

private static LogicalRel optimizeLogicalInternal(String sql, OptimizerContext context) {
    QueryParseResult parseResult = context.parse(sql);
    RelNode rel = context.convert(parseResult.getNode()).getRel();
    return (LogicalRel) context.optimize(rel, LogicalRules.getRuleSet(), OptUtils.toLogicalConvention(rel.getTraitSet()));
}
Also used : RelNode(org.apache.calcite.rel.RelNode) LogicalRel(com.hazelcast.jet.sql.impl.opt.logical.LogicalRel) QueryParseResult(com.hazelcast.jet.sql.impl.parse.QueryParseResult)

Example 3 with QueryParseResult

use of com.hazelcast.jet.sql.impl.parse.QueryParseResult in project hazelcast by hazelcast.

the class CalciteSqlOptimizer method toCreateJobPlan.

private SqlPlan toCreateJobPlan(PlanKey planKey, QueryParseResult parseResult, OptimizerContext context, String query) {
    SqlCreateJob sqlCreateJob = (SqlCreateJob) parseResult.getNode();
    SqlNode source = sqlCreateJob.dmlStatement();
    QueryParseResult dmlParseResult = new QueryParseResult(source, parseResult.getParameterMetadata(), false);
    QueryConvertResult dmlConvertedResult = context.convert(dmlParseResult.getNode());
    SqlPlanImpl dmlPlan = toPlan(null, parseResult.getParameterMetadata(), dmlConvertedResult.getRel(), dmlConvertedResult.getFieldNames(), context, dmlParseResult.isInfiniteRows(), true, query);
    assert dmlPlan instanceof DmlPlan && ((DmlPlan) dmlPlan).getOperation() == Operation.INSERT;
    return new CreateJobPlan(planKey, sqlCreateJob.jobConfig(), sqlCreateJob.ifNotExists(), (DmlPlan) dmlPlan, query, parseResult.isInfiniteRows(), planExecutor);
}
Also used : SqlCreateJob(com.hazelcast.jet.sql.impl.parse.SqlCreateJob) DmlPlan(com.hazelcast.jet.sql.impl.SqlPlanImpl.DmlPlan) QueryConvertResult(com.hazelcast.jet.sql.impl.parse.QueryConvertResult) CreateJobPlan(com.hazelcast.jet.sql.impl.SqlPlanImpl.CreateJobPlan) QueryParseResult(com.hazelcast.jet.sql.impl.parse.QueryParseResult) SqlNode(org.apache.calcite.sql.SqlNode)

Aggregations

QueryParseResult (com.hazelcast.jet.sql.impl.parse.QueryParseResult)3 CreateJobPlan (com.hazelcast.jet.sql.impl.SqlPlanImpl.CreateJobPlan)1 DmlPlan (com.hazelcast.jet.sql.impl.SqlPlanImpl.DmlPlan)1 LogicalRel (com.hazelcast.jet.sql.impl.opt.logical.LogicalRel)1 QueryConvertResult (com.hazelcast.jet.sql.impl.parse.QueryConvertResult)1 SqlCreateJob (com.hazelcast.jet.sql.impl.parse.SqlCreateJob)1 RelNode (org.apache.calcite.rel.RelNode)1 SqlNode (org.apache.calcite.sql.SqlNode)1