use of com.facebook.presto.decoder.DecoderTestColumnHandle in project presto by prestodb.
the class TestAvroDecoder method testMapWithNull.
@Test
public void testMapWithNull() throws Exception {
DecoderTestColumnHandle row = new DecoderTestColumnHandle(0, "row", VACHAR_MAP_TYPE, "map_field", null, null, false, false, false);
Map<String, String> expectedValues = new HashMap<>();
expectedValues.put("key1", null);
Map<DecoderColumnHandle, FieldValueProvider> decodedRow = buildAndDecodeColumn(row, "map_field", "{\"type\": \"map\", \"values\": \"null\"}", expectedValues);
checkMapValue(decodedRow, row, expectedValues);
}
use of com.facebook.presto.decoder.DecoderTestColumnHandle in project presto by prestodb.
the class TestAvroDecoder method testArrayWithNulls.
@Test
public void testArrayWithNulls() throws Exception {
DecoderTestColumnHandle row = new DecoderTestColumnHandle(0, "row", new ArrayType(BIGINT), "array_field", null, null, false, false, false);
List<Long> values = new ArrayList<>();
values.add(null);
Map<DecoderColumnHandle, FieldValueProvider> decodedRow = buildAndDecodeColumn(row, "array_field", "{\"type\": \"array\", \"items\": \"null\"}", values);
checkArrayItemIsNull(decodedRow, row, new long[] { 0 });
}
use of com.facebook.presto.decoder.DecoderTestColumnHandle in project presto by prestodb.
the class TestAvroDecoder method testMapDecodedAsMap.
@Test
public void testMapDecodedAsMap() throws Exception {
DecoderTestColumnHandle row = new DecoderTestColumnHandle(0, "row", VACHAR_MAP_TYPE, "map_field", null, null, false, false, false);
Map<DecoderColumnHandle, FieldValueProvider> decodedRow = buildAndDecodeColumn(row, "map_field", "{\"type\": \"map\", \"values\": \"string\"}", ImmutableMap.of("key1", "abc", "key2", "def", "key3", "zyx"));
checkMapValue(decodedRow, row, ImmutableMap.of("key1", "abc", "key2", "def", "key3", "zyx"));
}
use of com.facebook.presto.decoder.DecoderTestColumnHandle in project presto by prestodb.
the class TestAvroDecoder method testIntDecodedAsInteger.
@Test
public void testIntDecodedAsInteger() {
DecoderTestColumnHandle row = new DecoderTestColumnHandle(0, "row", INTEGER, "id", null, null, false, false, false);
Map<DecoderColumnHandle, FieldValueProvider> decodedRow = buildAndDecodeColumn(row, "id", "\"int\"", 100_000);
checkValue(decodedRow, row, 100_000);
}
use of com.facebook.presto.decoder.DecoderTestColumnHandle in project presto by prestodb.
the class TestAvroDecoder method testSchemaEvolutionRemovingColumn.
@Test
public void testSchemaEvolutionRemovingColumn() throws Exception {
byte[] originalData = buildAvroData(new Schema.Parser().parse(getAvroSchema(ImmutableMap.of("string_field", "\"string\"", "string_field_to_be_removed", "[\"null\", \"string\"]"))), ImmutableMap.of("string_field", "string_field_value", "string_field_to_be_removed", "removed_field_value"));
DecoderTestColumnHandle evolvedColumn = new DecoderTestColumnHandle(0, "row0", VARCHAR, "string_field", null, null, false, false, false);
String removedColumnSchema = getAvroSchema("string_field", "\"string\"");
Map<DecoderColumnHandle, FieldValueProvider> decodedEvolvedRow = decodeRow(originalData, ImmutableSet.of(evolvedColumn), ImmutableMap.of(DATA_SCHEMA, removedColumnSchema));
assertEquals(decodedEvolvedRow.size(), 1);
checkValue(decodedEvolvedRow, evolvedColumn, "string_field_value");
}
Aggregations