use of com.hazelcast.jet.sql.impl.parse.SqlCreateJob in project hazelcast by hazelcast.
the class CalciteSqlOptimizer method createPlan.
@SuppressWarnings("checkstyle:returncount")
private SqlPlan createPlan(OptimizationTask task, QueryParseResult parseResult, OptimizerContext context) {
// TODO [sasha] : refactor this.
SqlNode node = parseResult.getNode();
PlanKey planKey = new PlanKey(task.getSearchPaths(), task.getSql());
if (node instanceof SqlCreateMapping) {
return toCreateMappingPlan(planKey, (SqlCreateMapping) node);
} else if (node instanceof SqlDropMapping) {
return toDropMappingPlan(planKey, (SqlDropMapping) node);
} else if (node instanceof SqlCreateIndex) {
return toCreateIndexPlan(planKey, (SqlCreateIndex) node);
} else if (node instanceof SqlDropIndex) {
return toDropIndexPlan(planKey, (SqlDropIndex) node);
} else if (node instanceof SqlCreateJob) {
return toCreateJobPlan(planKey, parseResult, context, task.getSql());
} else if (node instanceof SqlAlterJob) {
return toAlterJobPlan(planKey, (SqlAlterJob) node);
} else if (node instanceof SqlDropJob) {
return toDropJobPlan(planKey, (SqlDropJob) node);
} else if (node instanceof SqlCreateSnapshot) {
return toCreateSnapshotPlan(planKey, (SqlCreateSnapshot) node);
} else if (node instanceof SqlDropSnapshot) {
return toDropSnapshotPlan(planKey, (SqlDropSnapshot) node);
} else if (node instanceof SqlCreateView) {
return toCreateViewPlan(planKey, context, (SqlCreateView) node);
} else if (node instanceof SqlDropView) {
return toDropViewPlan(planKey, (SqlDropView) node);
} else if (node instanceof SqlShowStatement) {
return toShowStatementPlan(planKey, (SqlShowStatement) node);
} else if (node instanceof SqlExplainStatement) {
return toExplainStatementPlan(planKey, context, parseResult);
} else {
QueryConvertResult convertResult = context.convert(parseResult.getNode());
return toPlan(planKey, parseResult.getParameterMetadata(), convertResult.getRel(), convertResult.getFieldNames(), context, parseResult.isInfiniteRows(), false, task.getSql());
}
}
use of com.hazelcast.jet.sql.impl.parse.SqlCreateJob 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);
}
use of com.hazelcast.jet.sql.impl.parse.SqlCreateJob in project hazelcast by hazelcast.
the class HazelcastSqlValidator method validate.
@Override
public SqlNode validate(SqlNode topNode) {
if (topNode instanceof SqlCreateJob) {
isCreateJob = true;
}
if (topNode instanceof SqlDropView) {
return topNode;
}
if (topNode.getKind().belongsTo(SqlKind.DDL)) {
topNode.validate(this, getEmptyScope());
return topNode;
}
if (topNode instanceof SqlShowStatement) {
return topNode;
}
if (topNode instanceof SqlExplainStatement) {
/*
* Just FYI, why do we do set validated explicandum back.
*
* There was a corner case with queries where ORDER BY is present.
* SqlOrderBy is present as AST node (or SqlNode),
* but then it becomes embedded as part of SqlSelect AST node,
* and node itself is removed in `performUnconditionalRewrites().
* As a result, ORDER BY is absent as operator
* on the next validation & optimization phases
* and also doesn't present in SUPPORTED_KINDS.
*
* Explain query contains explicandum query, and
* performUnconditionalRewrites() doesn't rewrite anything for EXPLAIN.
* It's a reason why we do it (extraction, validation & re-setting) manually.
*/
SqlExplainStatement explainStatement = (SqlExplainStatement) topNode;
SqlNode explicandum = explainStatement.getExplicandum();
explicandum = super.validate(explicandum);
explainStatement.setExplicandum(explicandum);
return explainStatement;
}
return super.validate(topNode);
}
Aggregations