Search in sources :

Example 31 with HazelcastTable

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

the class LogicalSelectTest method test_selectByKeyAndKey.

@Test
public void test_selectByKeyAndKey() {
    HazelcastTable table = partitionedTable("m", asList(field(KEY, INT), field(VALUE, VARCHAR)), 10);
    assertPlan(optimizeLogical("SELECT * FROM m WHERE __key = 1 AND __key = 2", table), plan(planRow(0, ValuesLogicalRel.class)));
}
Also used : HazelcastTable(com.hazelcast.jet.sql.impl.schema.HazelcastTable) Test(org.junit.Test)

Example 32 with HazelcastTable

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

the class LogicalSelectTest method test_selectByKeyWithDynamicParam.

@Test
@Parameters(method = "types")
public void test_selectByKeyWithDynamicParam(QueryDataType type) {
    HazelcastTable table = partitionedTable("m", asList(field(KEY, type), field(VALUE, VARCHAR)), 1);
    assertPlan(optimizeLogical("SELECT * FROM m WHERE __key = ?", table), plan(planRow(0, SelectByKeyMapLogicalRel.class)));
}
Also used : HazelcastTable(com.hazelcast.jet.sql.impl.schema.HazelcastTable) Parameters(junitparams.Parameters) Test(org.junit.Test)

Example 33 with HazelcastTable

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

the class LogicalSelectTest method test_selectByKeyOrKey.

@Test
public void test_selectByKeyOrKey() {
    HazelcastTable table = partitionedTable("m", asList(field(KEY, INT), field(VALUE, VARCHAR)), 10);
    assertPlan(optimizeLogical("SELECT * FROM m WHERE __key = 1 OR __key = 2", table), plan(planRow(0, FullScanLogicalRel.class)));
}
Also used : HazelcastTable(com.hazelcast.jet.sql.impl.schema.HazelcastTable) Test(org.junit.Test)

Example 34 with HazelcastTable

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

the class SqlIndexAbstractTest method checkPlan.

private void checkPlan(boolean withIndex, String sql) {
    List<QueryDataType> parameterTypes = asList(QueryDataType.INT, f1.getFieldConverterType(), f2.getFieldConverterType());
    List<TableField> mapTableFields = asList(new MapTableField("__key", QueryDataType.INT, false, QueryPath.KEY_PATH), new MapTableField("field1", f1.getFieldConverterType(), false, new QueryPath("field1", false)), new MapTableField("field2", f2.getFieldConverterType(), false, new QueryPath("field2", false)));
    HazelcastTable table = partitionedTable(mapName, mapTableFields, getPartitionedMapIndexes(mapContainer(map), mapTableFields), map.size());
    OptimizerTestSupport.Result optimizationResult = optimizePhysical(sql, parameterTypes, table);
    assertPlan(optimizationResult.getLogical(), plan(planRow(0, FullScanLogicalRel.class)));
    assertPlan(optimizationResult.getPhysical(), plan(planRow(0, withIndex ? IndexScanMapPhysicalRel.class : FullScanPhysicalRel.class)));
}
Also used : QueryPath(com.hazelcast.sql.impl.extract.QueryPath) IndexScanMapPhysicalRel(com.hazelcast.jet.sql.impl.opt.physical.IndexScanMapPhysicalRel) QueryDataType(com.hazelcast.sql.impl.type.QueryDataType) FullScanPhysicalRel(com.hazelcast.jet.sql.impl.opt.physical.FullScanPhysicalRel) OptimizerTestSupport(com.hazelcast.jet.sql.impl.opt.OptimizerTestSupport) MapTableField(com.hazelcast.sql.impl.schema.map.MapTableField) TableField(com.hazelcast.sql.impl.schema.TableField) HazelcastTable(com.hazelcast.jet.sql.impl.schema.HazelcastTable) MapTableField(com.hazelcast.sql.impl.schema.map.MapTableField)

Example 35 with HazelcastTable

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

the class SqlIndexCastTest method checkIndexUsage.

private void checkIndexUsage(SqlStatement statement, ExpressionType<?> field, boolean expectedIndexUsage) {
    List<QueryDataType> parameterTypes = asList(QueryDataType.INT, field.getFieldConverterType());
    List<TableField> mapTableFields = asList(new MapTableField("__key", QueryDataType.INT, false, QueryPath.KEY_PATH), new MapTableField("field1", field.getFieldConverterType(), false, new QueryPath("field1", false)));
    HazelcastTable table = partitionedTable(MAP_NAME, mapTableFields, getPartitionedMapIndexes(mapContainer(instance().getMap(MAP_NAME)), mapTableFields), 1);
    Result optimizationResult = optimizePhysical(statement.getSql(), parameterTypes, table);
    assertPlan(optimizationResult.getLogical(), plan(planRow(0, FullScanLogicalRel.class)));
    assertPlan(optimizationResult.getPhysical(), plan(planRow(0, expectedIndexUsage ? IndexScanMapPhysicalRel.class : FullScanPhysicalRel.class)));
}
Also used : QueryPath(com.hazelcast.sql.impl.extract.QueryPath) IndexScanMapPhysicalRel(com.hazelcast.jet.sql.impl.opt.physical.IndexScanMapPhysicalRel) QueryDataType(com.hazelcast.sql.impl.type.QueryDataType) FullScanPhysicalRel(com.hazelcast.jet.sql.impl.opt.physical.FullScanPhysicalRel) TableField(com.hazelcast.sql.impl.schema.TableField) MapTableField(com.hazelcast.sql.impl.schema.map.MapTableField) HazelcastTable(com.hazelcast.jet.sql.impl.schema.HazelcastTable) MapTableField(com.hazelcast.sql.impl.schema.map.MapTableField)

Aggregations

HazelcastTable (com.hazelcast.jet.sql.impl.schema.HazelcastTable)70 Test (org.junit.Test)48 TableField (com.hazelcast.sql.impl.schema.TableField)8 MapTableField (com.hazelcast.sql.impl.schema.map.MapTableField)8 QueryDataType (com.hazelcast.sql.impl.type.QueryDataType)8 IndexScanMapPhysicalRel (com.hazelcast.jet.sql.impl.opt.physical.IndexScanMapPhysicalRel)7 RexNode (org.apache.calcite.rex.RexNode)7 QueryPath (com.hazelcast.sql.impl.extract.QueryPath)6 Parameters (junitparams.Parameters)6 OptimizerTestSupport (com.hazelcast.jet.sql.impl.opt.OptimizerTestSupport)5 HazelcastRelOptTable (com.hazelcast.jet.sql.impl.schema.HazelcastRelOptTable)5 ArrayList (java.util.ArrayList)5 FullScanPhysicalRel (com.hazelcast.jet.sql.impl.opt.physical.FullScanPhysicalRel)4 RelOptTable (org.apache.calcite.plan.RelOptTable)4 RelTraitSet (org.apache.calcite.plan.RelTraitSet)3 RelCollation (org.apache.calcite.rel.RelCollation)3 RelNode (org.apache.calcite.rel.RelNode)3 SqlIdentifier (org.apache.calcite.sql.SqlIdentifier)3 SqlValidatorTable (org.apache.calcite.sql.validate.SqlValidatorTable)3 RexBuilder (org.apache.calcite.rex.RexBuilder)2