use of com.hazelcast.sql.impl.schema.map.MapTableField in project hazelcast by hazelcast.
the class KvMetadataJsonResolverTest 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(JsonQueryTargetDescriptor.INSTANCE);
assertThat(metadata.getUpsertTargetDescriptor()).isEqualTo(JsonUpsertTargetDescriptor.INSTANCE);
}
use of com.hazelcast.sql.impl.schema.map.MapTableField in project hazelcast by hazelcast.
the class KvMetadataJsonResolverTest 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 KvMetadataJavaResolverTest method test_resolveMetadata.
@Test
@Parameters({ "true, __key", "false, this" })
public void test_resolveMetadata(boolean key, String prefix) {
Map<String, String> options = ImmutableMap.of((key ? OPTION_KEY_FORMAT : OPTION_VALUE_FORMAT), JAVA_FORMAT, (key ? OPTION_KEY_CLASS : OPTION_VALUE_CLASS), Type.class.getName());
KvMetadata metadata = INSTANCE.resolveMetadata(key, singletonList(field("field", QueryDataType.INT, prefix + ".field")), options, 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(GenericQueryTargetDescriptor.DEFAULT);
assertThat(metadata.getUpsertTargetDescriptor()).isEqualToComparingFieldByField(new PojoUpsertTargetDescriptor(Type.class.getName(), ImmutableMap.of("field", int.class.getName())));
}
use of com.hazelcast.sql.impl.schema.map.MapTableField in project hazelcast by hazelcast.
the class SqlCreateIndexTest method checkPlan.
private void checkPlan(boolean withIndex, boolean sorted, String sql, String mapName) {
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(map), mapTableFields), map.size());
assertThat(table.getProjects().size()).isEqualTo(2);
OptimizerTestSupport.Result optimizationResult = optimizePhysical(sql, parameterTypes, table);
if (sorted) {
if (withIndex) {
assertPlan(optimizationResult.getPhysical(), plan(planRow(0, IndexScanMapPhysicalRel.class)));
} else {
assertPlan(optimizationResult.getPhysical(), plan(planRow(0, SortPhysicalRel.class), planRow(1, FullScanPhysicalRel.class)));
}
} else {
assertPlan(optimizationResult.getLogical(), plan(planRow(0, FullScanLogicalRel.class)));
assertPlan(optimizationResult.getPhysical(), plan(planRow(0, withIndex ? IndexScanMapPhysicalRel.class : FullScanPhysicalRel.class)));
}
}
use of com.hazelcast.sql.impl.schema.map.MapTableField 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)));
}
Aggregations