use of com.facebook.presto.common.type.TestingTypeManager in project presto by prestodb.
the class TestHiveMaterializedViewUtils method testMaterializedDataPredicatesWithIntParitionType.
@Test
public void testMaterializedDataPredicatesWithIntParitionType() {
TestingTypeManager typeManager = new TestingTypeManager();
TestingSemiTransactionalHiveMetastore testMetastore = TestingSemiTransactionalHiveMetastore.create();
List<String> keys = ImmutableList.of("ds", "code");
Column dsColumn = new Column("ds", HIVE_STRING, Optional.empty(), Optional.empty());
Column codeColumn = new Column("code", HIVE_INT, Optional.empty(), Optional.empty());
List<Column> partitionColumns = ImmutableList.of(dsColumn, codeColumn);
List<String> partitions = ImmutableList.of("ds=2021-01-01/code=1", "ds=2021-01-01/code=2", "ds=2021-01-02/code=1", "ds=2021-01-02/code=2");
testMetastore.setPartitionNames(partitions);
ImmutableList.Builder<List<TestingPartitionResult>> partitionResults = ImmutableList.builder();
partitionResults.add(ImmutableList.of(new TestingPartitionResult("ds", VARCHAR, "CAST('2021-01-01' AS varchar)"), new TestingPartitionResult("code", INTEGER, "1")));
partitionResults.add(ImmutableList.of(new TestingPartitionResult("ds", VARCHAR, "CAST('2021-01-01' AS varchar)"), new TestingPartitionResult("code", INTEGER, "2")));
partitionResults.add(ImmutableList.of(new TestingPartitionResult("ds", VARCHAR, "CAST('2021-01-02' AS varchar)"), new TestingPartitionResult("code", INTEGER, "1")));
partitionResults.add(ImmutableList.of(new TestingPartitionResult("ds", VARCHAR, "CAST('2021-01-02' AS varchar)"), new TestingPartitionResult("code", INTEGER, "2")));
MaterializedDataPredicates materializedDataPredicates = getMaterializedDataPredicates(testMetastore, metastoreContext, typeManager, getTable(partitionColumns), DateTimeZone.UTC);
comparePredicates(materializedDataPredicates, keys, partitionResults.build());
}
use of com.facebook.presto.common.type.TestingTypeManager in project presto by prestodb.
the class TestHiveMaterializedViewUtils method testDifferenceDataPredicatesWithDifferentExtraPartitions.
@Test
public void testDifferenceDataPredicatesWithDifferentExtraPartitions() {
TestingTypeManager typeManager = new TestingTypeManager();
TestingSemiTransactionalHiveMetastore testMetastore = TestingSemiTransactionalHiveMetastore.create();
List<String> keys = ImmutableList.of("ds", "shipmode");
Column dsColumn = new Column("ds", HIVE_STRING, Optional.empty(), Optional.empty());
Column shipmodeColumn = new Column("shipmode", HIVE_STRING, Optional.empty(), Optional.empty());
List<Column> partitionColumns = ImmutableList.of(dsColumn, shipmodeColumn);
List<String> partitions = ImmutableList.of("ds=2020-01-01/shipmode=air", "ds=2020-01-01/shipmode=road", "ds=2020-01-02/shipmode=air", "ds=2020-01-02/shipmode=road");
testMetastore.setPartitionNames(partitions);
MaterializedDataPredicates baseDataPredicates = getMaterializedDataPredicates(testMetastore, metastoreContext, typeManager, getTable(partitionColumns), DateTimeZone.UTC);
Column viewShipModeColumn = new Column("view_shipmode", HIVE_STRING, Optional.empty(), Optional.empty());
List<Column> viewPartitionColumns = ImmutableList.of(dsColumn, viewShipModeColumn);
List<String> viewPartitions = ImmutableList.of("ds=2020-01-01/view_shipmode=air", "ds=2020-01-01/view_shipmode=road");
testMetastore.setPartitionNames(viewPartitions);
MaterializedDataPredicates materializedDataPredicates = getMaterializedDataPredicates(testMetastore, metastoreContext, typeManager, getTable(viewPartitionColumns), DateTimeZone.UTC);
Map<String, String> materializedViewToBaseColumnMap = ImmutableMap.of("ds", "ds");
ImmutableList.Builder<List<TestingPartitionResult>> partitionResults = ImmutableList.builder();
partitionResults.add(ImmutableList.of(new TestingPartitionResult("ds", VARCHAR, "CAST('2020-01-02' AS varchar)"), new TestingPartitionResult("shipmode", VARCHAR, "CAST('air' AS varchar)")));
partitionResults.add(ImmutableList.of(new TestingPartitionResult("ds", VARCHAR, "CAST('2020-01-02' AS varchar)"), new TestingPartitionResult("shipmode", VARCHAR, "CAST('road' AS varchar)")));
MaterializedDataPredicates diffDataPredicates = differenceDataPredicates(baseDataPredicates, materializedDataPredicates, materializedViewToBaseColumnMap);
comparePredicates(diffDataPredicates, keys, partitionResults.build());
}
use of com.facebook.presto.common.type.TestingTypeManager in project presto by prestodb.
the class TestAllOrNoneValueSet method testJsonSerialization.
@Test
public void testJsonSerialization() throws Exception {
TestingTypeManager typeManager = new TestingTypeManager();
ObjectMapper mapper = new JsonObjectMapperProvider().get().registerModule(new SimpleModule().addDeserializer(Type.class, new TestingTypeDeserializer(typeManager)));
AllOrNoneValueSet all = AllOrNoneValueSet.all(HYPER_LOG_LOG);
assertEquals(all, mapper.readValue(mapper.writeValueAsString(all), AllOrNoneValueSet.class));
AllOrNoneValueSet none = AllOrNoneValueSet.none(HYPER_LOG_LOG);
assertEquals(none, mapper.readValue(mapper.writeValueAsString(none), AllOrNoneValueSet.class));
}
use of com.facebook.presto.common.type.TestingTypeManager in project presto by prestodb.
the class TestSortedRangeSet method testJsonSerialization.
@Test
public void testJsonSerialization() throws Exception {
TestingTypeManager typeManager = new TestingTypeManager();
TestingBlockEncodingSerde blockEncodingSerde = new TestingBlockEncodingSerde();
ObjectMapper mapper = new JsonObjectMapperProvider().get().registerModule(new SimpleModule().addDeserializer(Type.class, new TestingTypeDeserializer(typeManager)).addSerializer(Block.class, new TestingBlockJsonSerde.Serializer(blockEncodingSerde)).addDeserializer(Block.class, new TestingBlockJsonSerde.Deserializer(blockEncodingSerde)));
SortedRangeSet set = SortedRangeSet.all(BIGINT);
assertEquals(set, mapper.readValue(mapper.writeValueAsString(set), SortedRangeSet.class));
set = SortedRangeSet.none(DOUBLE);
assertEquals(set, mapper.readValue(mapper.writeValueAsString(set), SortedRangeSet.class));
set = SortedRangeSet.of(VARCHAR, utf8Slice("abc"));
assertEquals(set, mapper.readValue(mapper.writeValueAsString(set), SortedRangeSet.class));
set = SortedRangeSet.of(Range.equal(BOOLEAN, true), Range.equal(BOOLEAN, false));
assertEquals(set, mapper.readValue(mapper.writeValueAsString(set), SortedRangeSet.class));
}
use of com.facebook.presto.common.type.TestingTypeManager in project presto by prestodb.
the class TestDomain method testJsonSerialization.
@Test
public void testJsonSerialization() throws Exception {
TestingTypeManager typeManager = new TestingTypeManager();
TestingBlockEncodingSerde blockEncodingSerde = new TestingBlockEncodingSerde();
ObjectMapper mapper = new JsonObjectMapperProvider().get().registerModule(new SimpleModule().addDeserializer(Type.class, new TestingTypeDeserializer(typeManager)).addSerializer(Block.class, new TestingBlockJsonSerde.Serializer(blockEncodingSerde)).addDeserializer(Block.class, new TestingBlockJsonSerde.Deserializer(blockEncodingSerde)));
Domain domain = Domain.all(BIGINT);
assertEquals(domain, mapper.readValue(mapper.writeValueAsString(domain), Domain.class));
domain = Domain.none(DOUBLE);
assertEquals(domain, mapper.readValue(mapper.writeValueAsString(domain), Domain.class));
domain = Domain.notNull(BOOLEAN);
assertEquals(domain, mapper.readValue(mapper.writeValueAsString(domain), Domain.class));
domain = Domain.notNull(HYPER_LOG_LOG);
assertEquals(domain, mapper.readValue(mapper.writeValueAsString(domain), Domain.class));
domain = Domain.onlyNull(VARCHAR);
assertEquals(domain, mapper.readValue(mapper.writeValueAsString(domain), Domain.class));
domain = Domain.onlyNull(HYPER_LOG_LOG);
assertEquals(domain, mapper.readValue(mapper.writeValueAsString(domain), Domain.class));
domain = Domain.singleValue(BIGINT, Long.MIN_VALUE);
assertEquals(domain, mapper.readValue(mapper.writeValueAsString(domain), Domain.class));
domain = Domain.singleValue(ID, Long.MIN_VALUE);
assertEquals(domain, mapper.readValue(mapper.writeValueAsString(domain), Domain.class));
domain = Domain.create(ValueSet.ofRanges(Range.lessThan(BIGINT, 0L), Range.equal(BIGINT, 1L), Range.range(BIGINT, 2L, true, 3L, true)), true);
assertEquals(domain, mapper.readValue(mapper.writeValueAsString(domain), Domain.class));
}
Aggregations