Search in sources :

Example 1 with CreateMappingPlan

use of com.hazelcast.jet.sql.impl.SqlPlanImpl.CreateMappingPlan in project hazelcast by hazelcast.

the class PlanExecutorTest method test_createMappingExecution.

@Test
@Parameters({ "true, false", "false, true" })
public void test_createMappingExecution(boolean replace, boolean ifNotExists) {
    // given
    Mapping mapping = mapping();
    CreateMappingPlan plan = new CreateMappingPlan(planKey(), mapping, replace, ifNotExists, planExecutor);
    // when
    SqlResult result = planExecutor.execute(plan);
    // then
    assertThat(result.updateCount()).isEqualTo(0);
    verify(catalog).createMapping(mapping, replace, ifNotExists);
}
Also used : SqlResult(com.hazelcast.sql.SqlResult) Mapping(com.hazelcast.sql.impl.schema.Mapping) CreateMappingPlan(com.hazelcast.jet.sql.impl.SqlPlanImpl.CreateMappingPlan) Parameters(junitparams.Parameters) Test(org.junit.Test)

Example 2 with CreateMappingPlan

use of com.hazelcast.jet.sql.impl.SqlPlanImpl.CreateMappingPlan 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

CreateMappingPlan (com.hazelcast.jet.sql.impl.SqlPlanImpl.CreateMappingPlan)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 CreateSnapshotPlan (com.hazelcast.jet.sql.impl.SqlPlanImpl.CreateSnapshotPlan)1 CreateViewPlan (com.hazelcast.jet.sql.impl.SqlPlanImpl.CreateViewPlan)1 DmlPlan (com.hazelcast.jet.sql.impl.SqlPlanImpl.DmlPlan)1 DropIndexPlan (com.hazelcast.jet.sql.impl.SqlPlanImpl.DropIndexPlan)1 DropJobPlan (com.hazelcast.jet.sql.impl.SqlPlanImpl.DropJobPlan)1 DropMappingPlan (com.hazelcast.jet.sql.impl.SqlPlanImpl.DropMappingPlan)1 DropSnapshotPlan (com.hazelcast.jet.sql.impl.SqlPlanImpl.DropSnapshotPlan)1 DropViewPlan (com.hazelcast.jet.sql.impl.SqlPlanImpl.DropViewPlan)1 ExplainStatementPlan (com.hazelcast.jet.sql.impl.SqlPlanImpl.ExplainStatementPlan)1 IMapDeletePlan (com.hazelcast.jet.sql.impl.SqlPlanImpl.IMapDeletePlan)1 IMapInsertPlan (com.hazelcast.jet.sql.impl.SqlPlanImpl.IMapInsertPlan)1 IMapSelectPlan (com.hazelcast.jet.sql.impl.SqlPlanImpl.IMapSelectPlan)1 IMapSinkPlan (com.hazelcast.jet.sql.impl.SqlPlanImpl.IMapSinkPlan)1 IMapUpdatePlan (com.hazelcast.jet.sql.impl.SqlPlanImpl.IMapUpdatePlan)1 SelectPlan (com.hazelcast.jet.sql.impl.SqlPlanImpl.SelectPlan)1