Search in sources :

Example 1 with HazelcastSchema

use of com.hazelcast.jet.sql.impl.schema.HazelcastSchema in project hazelcast by hazelcast.

the class OptimizerTestSupport method optimizeLogical.

protected RelNode optimizeLogical(String sql, HazelcastTable... tables) {
    HazelcastSchema schema = schema(tables);
    OptimizerContext context = context(schema);
    return optimizeLogicalInternal(sql, context);
}
Also used : HazelcastSchema(com.hazelcast.jet.sql.impl.schema.HazelcastSchema) OptimizerContext(com.hazelcast.jet.sql.impl.OptimizerContext)

Example 2 with HazelcastSchema

use of com.hazelcast.jet.sql.impl.schema.HazelcastSchema in project hazelcast by hazelcast.

the class OptimizerTestSupport method context.

private static OptimizerContext context(HazelcastSchema schema, QueryDataType... parameterTypes) {
    OptimizerContext context = OptimizerContext.create(HazelcastSchemaUtils.createCatalog(schema), QueryUtils.prepareSearchPaths(null, null), emptyList(), 1, name -> null);
    ParameterConverter[] parameterConverters = IntStream.range(0, parameterTypes.length).mapToObj(i -> new StrictParameterConverter(i, SqlParserPos.ZERO, parameterTypes[i])).toArray(ParameterConverter[]::new);
    QueryParameterMetadata parameterMetadata = new QueryParameterMetadata(parameterConverters);
    context.setParameterMetadata(parameterMetadata);
    return context;
}
Also used : IntStream(java.util.stream.IntStream) OptimizerContext(com.hazelcast.jet.sql.impl.OptimizerContext) LogicalRules(com.hazelcast.jet.sql.impl.opt.logical.LogicalRules) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) QueryDataType(com.hazelcast.sql.impl.type.QueryDataType) PhysicalRules(com.hazelcast.jet.sql.impl.opt.physical.PhysicalRules) SCHEMA_NAME_PUBLIC(com.hazelcast.jet.sql.impl.schema.TableResolverImpl.SCHEMA_NAME_PUBLIC) RelOptUtil(org.apache.calcite.plan.RelOptUtil) QueryParameterMetadata(com.hazelcast.sql.impl.QueryParameterMetadata) HazelcastTable(com.hazelcast.jet.sql.impl.schema.HazelcastTable) ParameterConverter(com.hazelcast.sql.impl.ParameterConverter) Collectors.toMap(java.util.stream.Collectors.toMap) LogicalRel(com.hazelcast.jet.sql.impl.opt.logical.LogicalRel) Arrays.asList(java.util.Arrays.asList) ConstantTableStatistics(com.hazelcast.sql.impl.schema.ConstantTableStatistics) HazelcastSchemaUtils(com.hazelcast.jet.sql.impl.schema.HazelcastSchemaUtils) QueryUtils(com.hazelcast.sql.impl.QueryUtils) PartitionedMapTable(com.hazelcast.sql.impl.schema.map.PartitionedMapTable) SqlParserPos(org.apache.calcite.sql.parser.SqlParserPos) StrictParameterConverter(com.hazelcast.jet.sql.impl.validate.param.StrictParameterConverter) HazelcastTableStatistic(com.hazelcast.jet.sql.impl.schema.HazelcastTableStatistic) Collections.emptyList(java.util.Collections.emptyList) SqlTestSupport(com.hazelcast.jet.sql.SqlTestSupport) SqlExplainLevel(org.apache.calcite.sql.SqlExplainLevel) RelNode(org.apache.calcite.rel.RelNode) HazelcastSchema(com.hazelcast.jet.sql.impl.schema.HazelcastSchema) Objects(java.util.Objects) TableField(com.hazelcast.sql.impl.schema.TableField) List(java.util.List) Collectors.toList(java.util.stream.Collectors.toList) StringReader(java.io.StringReader) QueryParseResult(com.hazelcast.jet.sql.impl.parse.QueryParseResult) MapTableIndex(com.hazelcast.sql.impl.schema.map.MapTableIndex) Function.identity(java.util.function.Function.identity) BufferedReader(java.io.BufferedReader) Arrays.stream(java.util.Arrays.stream) PhysicalRel(com.hazelcast.jet.sql.impl.opt.physical.PhysicalRel) StrictParameterConverter(com.hazelcast.jet.sql.impl.validate.param.StrictParameterConverter) ParameterConverter(com.hazelcast.sql.impl.ParameterConverter) StrictParameterConverter(com.hazelcast.jet.sql.impl.validate.param.StrictParameterConverter) QueryParameterMetadata(com.hazelcast.sql.impl.QueryParameterMetadata) OptimizerContext(com.hazelcast.jet.sql.impl.OptimizerContext)

Example 3 with HazelcastSchema

use of com.hazelcast.jet.sql.impl.schema.HazelcastSchema in project hazelcast by hazelcast.

the class OptimizerTestSupport method optimizeLogical.

protected RelNode optimizeLogical(String sql, boolean requiresJob, HazelcastTable... tables) {
    HazelcastSchema schema = schema(tables);
    OptimizerContext context = context(schema);
    context.setRequiresJob(requiresJob);
    return optimizeLogicalInternal(sql, context);
}
Also used : HazelcastSchema(com.hazelcast.jet.sql.impl.schema.HazelcastSchema) OptimizerContext(com.hazelcast.jet.sql.impl.OptimizerContext)

Example 4 with HazelcastSchema

use of com.hazelcast.jet.sql.impl.schema.HazelcastSchema in project hazelcast by hazelcast.

the class OptimizerTestSupport method optimizePhysical.

protected Result optimizePhysical(String sql, List<QueryDataType> parameterTypes, HazelcastTable... tables) {
    HazelcastSchema schema = schema(tables);
    OptimizerContext context = context(schema, parameterTypes.toArray(new QueryDataType[0]));
    return optimizePhysicalInternal(sql, context);
}
Also used : QueryDataType(com.hazelcast.sql.impl.type.QueryDataType) HazelcastSchema(com.hazelcast.jet.sql.impl.schema.HazelcastSchema) OptimizerContext(com.hazelcast.jet.sql.impl.OptimizerContext)

Aggregations

OptimizerContext (com.hazelcast.jet.sql.impl.OptimizerContext)4 HazelcastSchema (com.hazelcast.jet.sql.impl.schema.HazelcastSchema)4 QueryDataType (com.hazelcast.sql.impl.type.QueryDataType)2 SqlTestSupport (com.hazelcast.jet.sql.SqlTestSupport)1 LogicalRel (com.hazelcast.jet.sql.impl.opt.logical.LogicalRel)1 LogicalRules (com.hazelcast.jet.sql.impl.opt.logical.LogicalRules)1 PhysicalRel (com.hazelcast.jet.sql.impl.opt.physical.PhysicalRel)1 PhysicalRules (com.hazelcast.jet.sql.impl.opt.physical.PhysicalRules)1 QueryParseResult (com.hazelcast.jet.sql.impl.parse.QueryParseResult)1 HazelcastSchemaUtils (com.hazelcast.jet.sql.impl.schema.HazelcastSchemaUtils)1 HazelcastTable (com.hazelcast.jet.sql.impl.schema.HazelcastTable)1 HazelcastTableStatistic (com.hazelcast.jet.sql.impl.schema.HazelcastTableStatistic)1 SCHEMA_NAME_PUBLIC (com.hazelcast.jet.sql.impl.schema.TableResolverImpl.SCHEMA_NAME_PUBLIC)1 StrictParameterConverter (com.hazelcast.jet.sql.impl.validate.param.StrictParameterConverter)1 ParameterConverter (com.hazelcast.sql.impl.ParameterConverter)1 QueryParameterMetadata (com.hazelcast.sql.impl.QueryParameterMetadata)1 QueryUtils (com.hazelcast.sql.impl.QueryUtils)1 ConstantTableStatistics (com.hazelcast.sql.impl.schema.ConstantTableStatistics)1 TableField (com.hazelcast.sql.impl.schema.TableField)1 MapTableIndex (com.hazelcast.sql.impl.schema.map.MapTableIndex)1