use of com.facebook.presto.common.type.TestingTypeManager in project presto by prestodb.
the class TestRange 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)));
Range range = Range.all(BIGINT);
assertEquals(range, mapper.readValue(mapper.writeValueAsString(range), Range.class));
range = Range.equal(DOUBLE, 0.123);
assertEquals(range, mapper.readValue(mapper.writeValueAsString(range), Range.class));
range = Range.greaterThan(BIGINT, 0L);
assertEquals(range, mapper.readValue(mapper.writeValueAsString(range), Range.class));
range = Range.greaterThanOrEqual(VARCHAR, utf8Slice("abc"));
assertEquals(range, mapper.readValue(mapper.writeValueAsString(range), Range.class));
range = Range.lessThan(BIGINT, Long.MAX_VALUE);
assertEquals(range, mapper.readValue(mapper.writeValueAsString(range), Range.class));
range = Range.lessThanOrEqual(DOUBLE, Double.MAX_VALUE);
assertEquals(range, mapper.readValue(mapper.writeValueAsString(range), Range.class));
}
use of com.facebook.presto.common.type.TestingTypeManager in project presto by prestodb.
the class TestEquatableValueSet 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)));
EquatableValueSet set = EquatableValueSet.all(TestingIdType.ID);
assertEquals(set, mapper.readValue(mapper.writeValueAsString(set), EquatableValueSet.class));
set = EquatableValueSet.none(TestingIdType.ID);
assertEquals(set, mapper.readValue(mapper.writeValueAsString(set), EquatableValueSet.class));
set = EquatableValueSet.of(TestingIdType.ID, 1L);
assertEquals(set, mapper.readValue(mapper.writeValueAsString(set), EquatableValueSet.class));
set = EquatableValueSet.of(TestingIdType.ID, 1L, 2L);
assertEquals(set, mapper.readValue(mapper.writeValueAsString(set), EquatableValueSet.class));
set = EquatableValueSet.of(TestingIdType.ID, 1L, 2L).complement();
assertEquals(set, mapper.readValue(mapper.writeValueAsString(set), EquatableValueSet.class));
}
use of com.facebook.presto.common.type.TestingTypeManager in project presto by prestodb.
the class TestMarker 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)));
Marker marker = Marker.above(BIGINT, 0L);
assertEquals(marker, mapper.readValue(mapper.writeValueAsString(marker), Marker.class));
marker = Marker.exactly(VARCHAR, utf8Slice("abc"));
assertEquals(marker, mapper.readValue(mapper.writeValueAsString(marker), Marker.class));
marker = Marker.below(DOUBLE, 0.123);
assertEquals(marker, mapper.readValue(mapper.writeValueAsString(marker), Marker.class));
marker = Marker.exactly(BOOLEAN, true);
assertEquals(marker, mapper.readValue(mapper.writeValueAsString(marker), Marker.class));
marker = Marker.upperUnbounded(BIGINT);
assertEquals(marker, mapper.readValue(mapper.writeValueAsString(marker), Marker.class));
marker = Marker.lowerUnbounded(BIGINT);
assertEquals(marker, mapper.readValue(mapper.writeValueAsString(marker), Marker.class));
}
use of com.facebook.presto.common.type.TestingTypeManager in project presto by prestodb.
the class TestHiveMetadata method testColumnMetadataGetter.
@Test
public void testColumnMetadataGetter() {
TypeManager mockTypeManager = new TestingTypeManager();
Column column1 = new Column("c1", HIVE_INT, Optional.empty(), Optional.of("some-metadata"));
HiveColumnHandle hiveColumnHandle1 = new HiveColumnHandle(column1.getName(), HiveType.HIVE_INT, TypeSignature.parseTypeSignature("int"), 0, HiveColumnHandle.ColumnType.REGULAR, Optional.empty(), Optional.empty());
HiveColumnHandle hidden = new HiveColumnHandle(HiveColumnHandle.PATH_COLUMN_NAME, HiveType.HIVE_INT, TypeSignature.parseTypeSignature("int"), 0, HiveColumnHandle.ColumnType.SYNTHESIZED, Optional.empty(), Optional.empty());
Column partitionColumn = new Column("ds", HIVE_STRING, Optional.empty(), Optional.empty());
Table mockTable = new Table("schema", "table", "user", PrestoTableType.MANAGED_TABLE, new Storage(fromHiveStorageFormat(ORC), "location", Optional.of(new HiveBucketProperty(ImmutableList.of(column1.getName()), 100, ImmutableList.of(), HIVE_COMPATIBLE, Optional.empty())), false, ImmutableMap.of(), ImmutableMap.of()), ImmutableList.of(column1), ImmutableList.of(partitionColumn), ImmutableMap.of(), Optional.empty(), Optional.empty());
ColumnMetadata actual = HiveMetadata.columnMetadataGetter(mockTable, mockTypeManager, new HiveColumnConverter()).apply(hiveColumnHandle1);
ColumnMetadata expected = new ColumnMetadata("c1", IntegerType.INTEGER);
assertEquals(actual, expected);
actual = HiveMetadata.columnMetadataGetter(mockTable, mockTypeManager, new TestColumnConverter()).apply(hidden);
expected = ColumnMetadata.builder().setName(HiveColumnHandle.PATH_COLUMN_NAME).setType(IntegerType.INTEGER).setHidden(true).build();
assertEquals(actual, expected);
}
use of com.facebook.presto.common.type.TestingTypeManager in project presto by prestodb.
the class TestHivePageSourceProvider method testNotUseRecordReaderWithInputFormatAnnotationWithoutCustomSplit.
@Test
public void testNotUseRecordReaderWithInputFormatAnnotationWithoutCustomSplit() {
StorageFormat storageFormat = StorageFormat.create(ParquetHiveSerDe.class.getName(), HoodieParquetInputFormat.class.getName(), "");
Storage storage = new Storage(storageFormat, "test", Optional.empty(), true, ImmutableMap.of(), ImmutableMap.of());
HiveRecordCursorProvider recordCursorProvider = new MockHiveRecordCursorProvider();
HiveBatchPageSourceFactory hiveBatchPageSourceFactory = new MockHiveBatchPageSourceFactory();
Optional<ConnectorPageSource> pageSource = HivePageSourceProvider.createHivePageSource(ImmutableSet.of(recordCursorProvider), ImmutableSet.of(hiveBatchPageSourceFactory), new Configuration(), new TestingConnectorSession(new HiveSessionProperties(new HiveClientConfig().setUseRecordPageSourceForCustomSplit(true), new OrcFileWriterConfig(), new ParquetFileWriterConfig(), new CacheConfig()).getSessionProperties()), new Path("/test/"), OptionalInt.empty(), 0, 100, 200, Instant.now().toEpochMilli(), storage, TupleDomain.none(), ImmutableList.of(), ImmutableMap.of(), ImmutableList.of(), DateTimeZone.UTC, new TestingTypeManager(), new SchemaTableName("test", "test"), ImmutableList.of(), ImmutableList.of(), ImmutableMap.of(), 0, TableToPartitionMapping.empty(), Optional.empty(), false, null, null, false, null, Optional.empty(), ImmutableMap.of());
assertTrue(pageSource.isPresent());
assertTrue(pageSource.get() instanceof HivePageSource);
}
Aggregations