use of com.hazelcast.sql.impl.schema.map.MapTableField in project hazelcast by hazelcast.
the class KvMetadataJavaResolverTest method test_resolvePrimitiveMetadata.
@Test
@Parameters({ "true, __key", "false, this" })
public void test_resolvePrimitiveMetadata(boolean key, String path) {
Map<String, String> options = ImmutableMap.of((key ? OPTION_KEY_FORMAT : OPTION_VALUE_FORMAT), JAVA_FORMAT, (key ? OPTION_KEY_CLASS : OPTION_VALUE_CLASS), int.class.getName());
KvMetadata metadata = INSTANCE.resolveMetadata(key, singletonList(field(path, QueryDataType.INT, path)), options, null);
assertThat(metadata.getFields()).containsExactly(new MapTableField(path, QueryDataType.INT, false, QueryPath.create(path)));
assertThat(metadata.getQueryTargetDescriptor()).isEqualTo(GenericQueryTargetDescriptor.DEFAULT);
assertThat(metadata.getUpsertTargetDescriptor()).isEqualTo(PrimitiveUpsertTargetDescriptor.INSTANCE);
}
use of com.hazelcast.sql.impl.schema.map.MapTableField in project hazelcast by hazelcast.
the class KvMetadataJavaResolverTest method when_noKeyOrThisPrefixInExternalName_then_usesValue.
@Test
@Parameters({ "true", "false" })
public void when_noKeyOrThisPrefixInExternalName_then_usesValue(boolean key) {
Map<String, String> options = ImmutableMap.of((key ? OPTION_KEY_FORMAT : OPTION_VALUE_FORMAT), JAVA_FORMAT, (key ? OPTION_KEY_CLASS : OPTION_VALUE_CLASS), Object.class.getName());
KvMetadata metadata = INSTANCE.resolveMetadata(key, singletonList(field("field", QueryDataType.INT, "extField")), options, null);
assertThat(metadata.getFields()).containsExactly(key ? new MapTableField[] { new MapTableField("__key", QueryDataType.OBJECT, true, QueryPath.KEY_PATH) } : new MapTableField[] { new MapTableField("field", QueryDataType.INT, false, new QueryPath("extField", false)), new MapTableField("this", QueryDataType.OBJECT, true, QueryPath.VALUE_PATH) });
}
use of com.hazelcast.sql.impl.schema.map.MapTableField in project hazelcast by hazelcast.
the class MetadataJsonResolverTest method test_resolveMetadata.
@Test
@Parameters({ "true, __key", "false, this" })
public void test_resolveMetadata(boolean key, String prefix) {
KvMetadata metadata = INSTANCE.resolveMetadata(key, singletonList(field("field", QueryDataType.INT, prefix + ".field")), emptyMap(), null);
assertThat(metadata.getFields()).containsExactly(new MapTableField("field", QueryDataType.INT, false, QueryPath.create(prefix + ".field")), new MapTableField(prefix, QueryDataType.OBJECT, true, QueryPath.create(prefix)));
assertThat(metadata.getQueryTargetDescriptor()).isEqualTo(HazelcastJsonQueryTargetDescriptor.INSTANCE);
assertThat(metadata.getUpsertTargetDescriptor()).isEqualTo(HazelcastJsonUpsertTargetDescriptor.INSTANCE);
}
use of com.hazelcast.sql.impl.schema.map.MapTableField in project hazelcast by hazelcast.
the class MetadataJsonResolverTest method when_noKeyOrThisPrefixInExternalName_then_usesValue.
@Test
@Parameters({ "true", "false" })
public void when_noKeyOrThisPrefixInExternalName_then_usesValue(boolean key) {
KvMetadata metadata = INSTANCE.resolveMetadata(key, singletonList(field("field", QueryDataType.INT, "extField")), emptyMap(), null);
assertThat(metadata.getFields()).containsExactly(key ? new MapTableField[] { new MapTableField("__key", QueryDataType.OBJECT, true, QueryPath.KEY_PATH) } : new MapTableField[] { new MapTableField("field", QueryDataType.INT, false, new QueryPath("extField", false)), new MapTableField("this", QueryDataType.OBJECT, true, QueryPath.VALUE_PATH) });
}
use of com.hazelcast.sql.impl.schema.map.MapTableField 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;
}
}
Aggregations