Search in sources :

Example 1 with SqlCreateMapping

use of com.hazelcast.jet.sql.impl.parse.SqlCreateMapping 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());
    }
}
Also used : SqlCreateView(com.hazelcast.jet.sql.impl.parse.SqlCreateView) SqlDropView(com.hazelcast.jet.sql.impl.parse.SqlDropView) SqlDropJob(com.hazelcast.jet.sql.impl.parse.SqlDropJob) SqlAlterJob(com.hazelcast.jet.sql.impl.parse.SqlAlterJob) SqlDropMapping(com.hazelcast.jet.sql.impl.parse.SqlDropMapping) SqlCreateSnapshot(com.hazelcast.jet.sql.impl.parse.SqlCreateSnapshot) SqlCreateMapping(com.hazelcast.jet.sql.impl.parse.SqlCreateMapping) SqlDropIndex(com.hazelcast.jet.sql.impl.parse.SqlDropIndex) SqlCreateJob(com.hazelcast.jet.sql.impl.parse.SqlCreateJob) PlanKey(com.hazelcast.sql.impl.optimizer.PlanKey) SqlDropSnapshot(com.hazelcast.jet.sql.impl.parse.SqlDropSnapshot) QueryConvertResult(com.hazelcast.jet.sql.impl.parse.QueryConvertResult) SqlShowStatement(com.hazelcast.jet.sql.impl.parse.SqlShowStatement) SqlExplainStatement(com.hazelcast.jet.sql.impl.parse.SqlExplainStatement) SqlCreateIndex(com.hazelcast.jet.sql.impl.parse.SqlCreateIndex) SqlNode(org.apache.calcite.sql.SqlNode)

Example 2 with SqlCreateMapping

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

the class CalciteSqlOptimizer method toCreateMappingPlan.

private SqlPlan toCreateMappingPlan(PlanKey planKey, SqlCreateMapping sqlCreateMapping) {
    List<MappingField> mappingFields = sqlCreateMapping.columns().map(field -> new MappingField(field.name(), field.type(), field.externalName())).collect(toList());
    Mapping mapping = new Mapping(sqlCreateMapping.nameWithoutSchema(), sqlCreateMapping.externalName(), sqlCreateMapping.type(), mappingFields, sqlCreateMapping.options());
    return new CreateMappingPlan(planKey, mapping, sqlCreateMapping.getReplace(), sqlCreateMapping.ifNotExists(), planExecutor);
}
Also used : SelectByKeyMapPhysicalRel(com.hazelcast.jet.sql.impl.opt.physical.SelectByKeyMapPhysicalRel) DropViewPlan(com.hazelcast.jet.sql.impl.SqlPlanImpl.DropViewPlan) SelectPlan(com.hazelcast.jet.sql.impl.SqlPlanImpl.SelectPlan) SqlCreateIndex(com.hazelcast.jet.sql.impl.parse.SqlCreateIndex) CreateDagVisitor(com.hazelcast.jet.sql.impl.opt.physical.CreateDagVisitor) Operation(org.apache.calcite.rel.core.TableModify.Operation) SqlRowMetadata(com.hazelcast.sql.SqlRowMetadata) QueryParameterMetadata(com.hazelcast.sql.impl.QueryParameterMetadata) Collections.singletonList(java.util.Collections.singletonList) AbstractMapTable(com.hazelcast.sql.impl.schema.map.AbstractMapTable) SlidingWindow(com.hazelcast.jet.sql.impl.opt.SlidingWindow) TableModify(org.apache.calcite.rel.core.TableModify) QueryUtils(com.hazelcast.sql.impl.QueryUtils) OptimizationTask(com.hazelcast.sql.impl.optimizer.OptimizationTask) CreateJobPlan(com.hazelcast.jet.sql.impl.SqlPlanImpl.CreateJobPlan) CreateMappingPlan(com.hazelcast.jet.sql.impl.SqlPlanImpl.CreateMappingPlan) RootRel(com.hazelcast.jet.sql.impl.opt.physical.RootRel) RelTraitSet(org.apache.calcite.plan.RelTraitSet) DropMappingPlan(com.hazelcast.jet.sql.impl.SqlPlanImpl.DropMappingPlan) SqlOptimizer(com.hazelcast.sql.impl.optimizer.SqlOptimizer) RelVisitor(org.apache.calcite.rel.RelVisitor) IMapUpdatePlan(com.hazelcast.jet.sql.impl.SqlPlanImpl.IMapUpdatePlan) IMapSelectPlan(com.hazelcast.jet.sql.impl.SqlPlanImpl.IMapSelectPlan) PlanKey(com.hazelcast.sql.impl.optimizer.PlanKey) SinkMapPhysicalRel(com.hazelcast.jet.sql.impl.opt.physical.SinkMapPhysicalRel) Permission(java.security.Permission) SqlCreateJob(com.hazelcast.jet.sql.impl.parse.SqlCreateJob) DeleteByKeyMapPhysicalRel(com.hazelcast.jet.sql.impl.opt.physical.DeleteByKeyMapPhysicalRel) SqlDropView(com.hazelcast.jet.sql.impl.parse.SqlDropView) PhysicalRules(com.hazelcast.jet.sql.impl.opt.physical.PhysicalRules) SqlColumnMetadata(com.hazelcast.sql.SqlColumnMetadata) IMapSinkPlan(com.hazelcast.jet.sql.impl.SqlPlanImpl.IMapSinkPlan) SqlConnectorCache(com.hazelcast.jet.sql.impl.connector.SqlConnectorCache) RelOptTable(org.apache.calcite.plan.RelOptTable) ArrayList(java.util.ArrayList) LogicalRel(com.hazelcast.jet.sql.impl.opt.logical.LogicalRel) DropIndexPlan(com.hazelcast.jet.sql.impl.SqlPlanImpl.DropIndexPlan) IMapInsertPlan(com.hazelcast.jet.sql.impl.SqlPlanImpl.IMapInsertPlan) SqlDropJob(com.hazelcast.jet.sql.impl.parse.SqlDropJob) ActionConstants(com.hazelcast.security.permission.ActionConstants) Nullable(javax.annotation.Nullable) SqlCreateMapping(com.hazelcast.jet.sql.impl.parse.SqlCreateMapping) HazelcastRelMetadataQuery(com.hazelcast.jet.sql.impl.opt.metadata.HazelcastRelMetadataQuery) DropSnapshotPlan(com.hazelcast.jet.sql.impl.SqlPlanImpl.DropSnapshotPlan) Aggregate(org.apache.calcite.rel.core.Aggregate) ShowStatementPlan(com.hazelcast.jet.sql.impl.SqlPlanImpl.ShowStatementPlan) ExplainStatementPlan(com.hazelcast.jet.sql.impl.SqlPlanImpl.ExplainStatementPlan) SqlCreateView(com.hazelcast.jet.sql.impl.parse.SqlCreateView) MetadataResolver(com.hazelcast.jet.sql.impl.connector.map.MetadataResolver) Conventions(com.hazelcast.jet.sql.impl.opt.Conventions) Convention(org.apache.calcite.plan.Convention) QueryConvertResult(com.hazelcast.jet.sql.impl.parse.QueryConvertResult) LogicalRules(com.hazelcast.jet.sql.impl.opt.logical.LogicalRules) RelShuttleImpl(org.apache.calcite.rel.RelShuttleImpl) CreateIndexPlan(com.hazelcast.jet.sql.impl.SqlPlanImpl.CreateIndexPlan) HazelcastTable(com.hazelcast.jet.sql.impl.schema.HazelcastTable) SqlNode(org.apache.calcite.sql.SqlNode) SqlExplainStatement(com.hazelcast.jet.sql.impl.parse.SqlExplainStatement) ViewTable(com.hazelcast.jet.sql.impl.connector.virtual.ViewTable) AlterJobPlan(com.hazelcast.jet.sql.impl.SqlPlanImpl.AlterJobPlan) QueryResultRegistry(com.hazelcast.sql.impl.state.QueryResultRegistry) PostgresqlSqlDialect(org.apache.calcite.sql.dialect.PostgresqlSqlDialect) Objects(java.util.Objects) TableResolver(com.hazelcast.sql.impl.schema.TableResolver) List(java.util.List) SqlDropIndex(com.hazelcast.jet.sql.impl.parse.SqlDropIndex) DropJobPlan(com.hazelcast.jet.sql.impl.SqlPlanImpl.DropJobPlan) MemberSelectors(com.hazelcast.cluster.memberselector.MemberSelectors) DmlPlan(com.hazelcast.jet.sql.impl.SqlPlanImpl.DmlPlan) SqlDropMapping(com.hazelcast.jet.sql.impl.parse.SqlDropMapping) RelDataTypeField(org.apache.calcite.rel.type.RelDataTypeField) QueryParseResult(com.hazelcast.jet.sql.impl.parse.QueryParseResult) VolcanoPlanner(org.apache.calcite.plan.volcano.VolcanoPlanner) SqlString(org.apache.calcite.sql.util.SqlString) TablesStorage(com.hazelcast.jet.sql.impl.schema.TablesStorage) MapPermission(com.hazelcast.security.permission.MapPermission) Project(org.apache.calcite.rel.core.Project) TableScan(org.apache.calcite.rel.core.TableScan) WatermarkedFields(com.hazelcast.jet.sql.impl.opt.metadata.WatermarkedFields) QueryDataType(com.hazelcast.sql.impl.type.QueryDataType) SqlShowStatement(com.hazelcast.jet.sql.impl.parse.SqlShowStatement) RelOptUtil(org.apache.calcite.plan.RelOptUtil) ILogger(com.hazelcast.logging.ILogger) IMapDeletePlan(com.hazelcast.jet.sql.impl.SqlPlanImpl.IMapDeletePlan) SqlCreateSnapshot(com.hazelcast.jet.sql.impl.parse.SqlCreateSnapshot) QueryException(com.hazelcast.sql.impl.QueryException) SqlPlan(com.hazelcast.sql.impl.optimizer.SqlPlan) SqlDropSnapshot(com.hazelcast.jet.sql.impl.parse.SqlDropSnapshot) SqlAlterJob(com.hazelcast.jet.sql.impl.parse.SqlAlterJob) NodeEngine(com.hazelcast.spi.impl.NodeEngine) CreateViewPlan(com.hazelcast.jet.sql.impl.SqlPlanImpl.CreateViewPlan) TableResolverImpl(com.hazelcast.jet.sql.impl.schema.TableResolverImpl) OptUtils(com.hazelcast.jet.sql.impl.opt.OptUtils) InsertMapPhysicalRel(com.hazelcast.jet.sql.impl.opt.physical.InsertMapPhysicalRel) RelNode(org.apache.calcite.rel.RelNode) CreateSnapshotPlan(com.hazelcast.jet.sql.impl.SqlPlanImpl.CreateSnapshotPlan) IMapResolver(com.hazelcast.sql.impl.schema.IMapResolver) Mapping(com.hazelcast.sql.impl.schema.Mapping) Collectors.toList(java.util.stream.Collectors.toList) MappingField(com.hazelcast.sql.impl.schema.MappingField) UpdateByKeyMapPhysicalRel(com.hazelcast.jet.sql.impl.opt.physical.UpdateByKeyMapPhysicalRel) PhysicalRel(com.hazelcast.jet.sql.impl.opt.physical.PhysicalRel) SqlCreateMapping(com.hazelcast.jet.sql.impl.parse.SqlCreateMapping) SqlDropMapping(com.hazelcast.jet.sql.impl.parse.SqlDropMapping) Mapping(com.hazelcast.sql.impl.schema.Mapping) CreateMappingPlan(com.hazelcast.jet.sql.impl.SqlPlanImpl.CreateMappingPlan) MappingField(com.hazelcast.sql.impl.schema.MappingField)

Aggregations

QueryConvertResult (com.hazelcast.jet.sql.impl.parse.QueryConvertResult)2 SqlAlterJob (com.hazelcast.jet.sql.impl.parse.SqlAlterJob)2 SqlCreateIndex (com.hazelcast.jet.sql.impl.parse.SqlCreateIndex)2 SqlCreateJob (com.hazelcast.jet.sql.impl.parse.SqlCreateJob)2 SqlCreateMapping (com.hazelcast.jet.sql.impl.parse.SqlCreateMapping)2 SqlCreateSnapshot (com.hazelcast.jet.sql.impl.parse.SqlCreateSnapshot)2 SqlCreateView (com.hazelcast.jet.sql.impl.parse.SqlCreateView)2 SqlDropIndex (com.hazelcast.jet.sql.impl.parse.SqlDropIndex)2 SqlDropJob (com.hazelcast.jet.sql.impl.parse.SqlDropJob)2 SqlDropMapping (com.hazelcast.jet.sql.impl.parse.SqlDropMapping)2 SqlDropSnapshot (com.hazelcast.jet.sql.impl.parse.SqlDropSnapshot)2 SqlDropView (com.hazelcast.jet.sql.impl.parse.SqlDropView)2 SqlExplainStatement (com.hazelcast.jet.sql.impl.parse.SqlExplainStatement)2 SqlShowStatement (com.hazelcast.jet.sql.impl.parse.SqlShowStatement)2 PlanKey (com.hazelcast.sql.impl.optimizer.PlanKey)2 SqlNode (org.apache.calcite.sql.SqlNode)2 MemberSelectors (com.hazelcast.cluster.memberselector.MemberSelectors)1 AlterJobPlan (com.hazelcast.jet.sql.impl.SqlPlanImpl.AlterJobPlan)1 CreateIndexPlan (com.hazelcast.jet.sql.impl.SqlPlanImpl.CreateIndexPlan)1 CreateJobPlan (com.hazelcast.jet.sql.impl.SqlPlanImpl.CreateJobPlan)1