Search in sources :

Example 11 with TableField

use of com.hazelcast.sql.impl.schema.TableField in project hazelcast by hazelcast.

the class SqlIndexFromSearchFilterTest method table.

private HazelcastTable table() {
    List<TableField> mapTableFields = asList(new MapTableField("__key", QueryDataType.INT, false, QueryPath.KEY_PATH), new MapTableField("field1", INTEGER.getFieldConverterType(), false, new QueryPath("field1", false)), new MapTableField("field2", INTEGER.getFieldConverterType(), false, new QueryPath("field2", false)));
    HazelcastTable table = partitionedTable(mapName, mapTableFields, getPartitionedMapIndexes(mapContainer(instance().getMap(mapName)), mapTableFields), MAP_SIZE);
    return table;
}
Also used : QueryPath(com.hazelcast.sql.impl.extract.QueryPath) 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)

Example 12 with TableField

use of com.hazelcast.sql.impl.schema.TableField in project hazelcast by hazelcast.

the class KafkaTableTest method test_objectKeyEquality.

@Test
@Parameters(method = "keys")
@SuppressWarnings("checkstyle:ParameterNumber")
public void test_objectKeyEquality(String schema1, String name1, String topic1, String field1, String value1, String schema2, String name2, String topic2, String field2, String value2, boolean expected) {
    KafkaPlanObjectKey k1 = new KafkaPlanObjectKey(schema1, name1, topic1, ImmutableList.of(new TableField(field1, QueryDataType.INT, false)), ImmutableMap.of("key", value1));
    KafkaPlanObjectKey k2 = new KafkaPlanObjectKey(schema2, name2, topic2, singletonList(new TableField(field2, QueryDataType.INT, false)), singletonMap("key", value2));
    assertThat(k1.equals(k2)).isEqualTo(expected);
    assertThat(k1.hashCode() == k2.hashCode()).isEqualTo(expected);
}
Also used : KafkaPlanObjectKey(com.hazelcast.jet.sql.impl.connector.kafka.KafkaTable.KafkaPlanObjectKey) TableField(com.hazelcast.sql.impl.schema.TableField) Parameters(junitparams.Parameters) Test(org.junit.Test)

Example 13 with TableField

use of com.hazelcast.sql.impl.schema.TableField in project hazelcast by hazelcast.

the class SqlIndexResolutionTest method checkIndexUsage.

private void checkIndexUsage(SqlStatement statement, String mapName, Usage expectedIndexUsage) {
    List<QueryDataType> parameterTypes = asList(QueryDataType.INT, QueryDataType.OBJECT, QueryDataType.INT);
    List<TableField> mapTableFields = asList(new MapTableField("__key", QueryDataType.INT, false, QueryPath.KEY_PATH), new MapTableField("field1", type1.getFieldConverterType(), false, new QueryPath("field1", false)), new MapTableField("field2", type2.getFieldConverterType(), false, new QueryPath("field2", false)));
    HazelcastTable table = partitionedTable(mapName, mapTableFields, getPartitionedMapIndexes(mapContainer(instance().getMap(mapName)), mapTableFields), // we can place random number, doesn't matter in current case.
    1);
    OptimizerTestSupport.Result optimizationResult = optimizePhysical(statement.getSql(), parameterTypes, table);
    assertPlan(optimizationResult.getLogical(), plan(planRow(0, FullScanLogicalRel.class)));
    switch(expectedIndexUsage) {
        case NONE:
            assertPlan(optimizationResult.getPhysical(), plan(planRow(0, FullScanPhysicalRel.class)));
            break;
        case ONE:
            assertPlan(optimizationResult.getPhysical(), plan(planRow(0, IndexScanMapPhysicalRel.class)));
            assertNotNull(((IndexScanMapPhysicalRel) optimizationResult.getPhysical()).getRemainderExp());
            break;
        case BOTH:
            assertPlan(optimizationResult.getPhysical(), plan(planRow(0, IndexScanMapPhysicalRel.class)));
            assertNull(((IndexScanMapPhysicalRel) optimizationResult.getPhysical()).getRemainderExp());
            break;
    }
}
Also used : QueryPath(com.hazelcast.sql.impl.extract.QueryPath) QueryDataType(com.hazelcast.sql.impl.type.QueryDataType) OptimizerTestSupport(com.hazelcast.jet.sql.impl.opt.OptimizerTestSupport) 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)

Example 14 with TableField

use of com.hazelcast.sql.impl.schema.TableField in project hazelcast by hazelcast.

the class SqlSecurityCallbackTest method checkIndexUsage.

private void checkIndexUsage(String sql, boolean expectedIndexUsage) {
    List<QueryDataType> parameterTypes = asList(QueryDataType.INT, QueryDataType.INT);
    List<TableField> mapTableFields = asList(new MapTableField("__key", QueryDataType.INT, false, QueryPath.KEY_PATH), new MapTableField("this", QueryDataType.INT, false, QueryPath.VALUE_PATH));
    HazelcastTable table = partitionedTable(mapName, mapTableFields, getPartitionedMapIndexes(mapContainer(instance().getMap(mapName)), mapTableFields), mapSize);
    OptimizerTestSupport.Result optimizationResult = optimizePhysical(sql, parameterTypes, table);
    assertPlan(optimizationResult.getLogical(), plan(planRow(0, FullScanLogicalRel.class)));
    assertPlan(optimizationResult.getPhysical(), plan(planRow(0, expectedIndexUsage ? IndexScanMapPhysicalRel.class : FullScanPhysicalRel.class)));
}
Also used : 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) 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)

Example 15 with TableField

use of com.hazelcast.sql.impl.schema.TableField in project hazelcast by hazelcast.

the class SqlNoSerializationTest method checkIndexUsage.

private void checkIndexUsage(SqlStatement statement, boolean expectedIndexUsage) {
    List<QueryDataType> parameterTypes = asList(QueryDataType.INT, QueryDataType.OBJECT, QueryDataType.INT);
    List<TableField> mapTableFields = asList(new MapTableField("__key", QueryDataType.INT, false, QueryPath.KEY_PATH), new MapTableField("this", QueryDataType.OBJECT, false, QueryPath.VALUE_PATH), new MapTableField("val", QueryDataType.INT, false, new QueryPath("val", false)));
    HazelcastTable table = partitionedTable(MAP_NAME, mapTableFields, getPartitionedMapIndexes(mapContainer(instance().getMap(MAP_NAME)), mapTableFields), KEY_COUNT);
    OptimizerTestSupport.Result optimizationResult = optimizePhysical(statement.getSql(), parameterTypes, table);
    assertPlan(optimizationResult.getLogical(), plan(planRow(0, FullScanLogicalRel.class)));
    if (expectedIndexUsage) {
        assertPlan(optimizationResult.getPhysical(), plan(planRow(0, IndexScanMapPhysicalRel.class)));
    } else {
        assertPlan(optimizationResult.getPhysical(), plan(planRow(0, FullScanPhysicalRel.class)));
    }
}
Also used : QueryPath(com.hazelcast.sql.impl.extract.QueryPath) QueryDataType(com.hazelcast.sql.impl.type.QueryDataType) OptimizerTestSupport(com.hazelcast.jet.sql.impl.opt.OptimizerTestSupport) 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

TableField (com.hazelcast.sql.impl.schema.TableField)22 MapTableField (com.hazelcast.sql.impl.schema.map.MapTableField)15 QueryPath (com.hazelcast.sql.impl.extract.QueryPath)13 QueryDataType (com.hazelcast.sql.impl.type.QueryDataType)12 ArrayList (java.util.ArrayList)10 HazelcastTable (com.hazelcast.jet.sql.impl.schema.HazelcastTable)8 MappingField (com.hazelcast.sql.impl.schema.MappingField)7 KvMetadata (com.hazelcast.jet.sql.impl.connector.keyvalue.KvMetadata)5 OptimizerTestSupport (com.hazelcast.jet.sql.impl.opt.OptimizerTestSupport)5 FullScanPhysicalRel (com.hazelcast.jet.sql.impl.opt.physical.FullScanPhysicalRel)4 IndexScanMapPhysicalRel (com.hazelcast.jet.sql.impl.opt.physical.IndexScanMapPhysicalRel)4 Nonnull (javax.annotation.Nonnull)3 Test (org.junit.Test)3 ConstantTableStatistics (com.hazelcast.sql.impl.schema.ConstantTableStatistics)2 Parameters (junitparams.Parameters)2 RelDataTypeField (org.apache.calcite.rel.type.RelDataTypeField)2 ImmutableList (com.google.common.collect.ImmutableList)1 InternalSerializationService (com.hazelcast.internal.serialization.InternalSerializationService)1 Schema (com.hazelcast.internal.serialization.impl.compact.Schema)1 FilePlanObjectKey (com.hazelcast.jet.sql.impl.connector.file.FileTable.FilePlanObjectKey)1