use of com.facebook.presto.decoder.DecoderTestColumnHandle in project presto by prestodb.
the class TestAvroDecoder method testSchemaEvolutionToIncompatibleType.
@Test
public void testSchemaEvolutionToIncompatibleType() throws Exception {
byte[] originalIntData = buildAvroData(new Schema.Parser().parse(getAvroSchema("int_to_string_field", "\"int\"")), "int_to_string_field", 100);
DecoderTestColumnHandle stringColumnReadingIntData = new DecoderTestColumnHandle(0, "row0", VARCHAR, "int_to_string_field", null, null, false, false, false);
String changedTypeSchema = getAvroSchema("int_to_string_field", "\"string\"");
assertThatThrownBy(() -> decodeRow(originalIntData, ImmutableSet.of(stringColumnReadingIntData), ImmutableMap.of(DATA_SCHEMA, changedTypeSchema))).isInstanceOf(PrestoException.class).hasCauseExactlyInstanceOf(AvroTypeException.class).hasStackTraceContaining("Found int, expecting string").hasMessageMatching("Decoding Avro record failed.");
}
use of com.facebook.presto.decoder.DecoderTestColumnHandle in project presto by prestodb.
the class TestAvroDecoder method testStringDecodedAsVarcharN.
@Test
public void testStringDecodedAsVarcharN() throws Exception {
DecoderTestColumnHandle row = new DecoderTestColumnHandle(0, "row", createVarcharType(10), "varcharn_field", null, null, false, false, false);
Map<DecoderColumnHandle, FieldValueProvider> decodedRow = buildAndDecodeColumn(row, "varcharn_field", "\"string\"", "abcdefghijklmno");
checkValue(decodedRow, row, "abcdefghij");
}
use of com.facebook.presto.decoder.DecoderTestColumnHandle in project presto by prestodb.
the class TestAvroDecoder method testIntDecodedAsSmallInt.
@Test
public void testIntDecodedAsSmallInt() {
DecoderTestColumnHandle row = new DecoderTestColumnHandle(0, "row", SMALLINT, "id", null, null, false, false, false);
Map<DecoderColumnHandle, FieldValueProvider> decodedRow = buildAndDecodeColumn(row, "id", "\"int\"", 1000);
checkValue(decodedRow, row, 1000);
}
use of com.facebook.presto.decoder.DecoderTestColumnHandle in project presto by prestodb.
the class TestAvroDecoder method testRuntimeDecodingFailure.
@Test
public void testRuntimeDecodingFailure() {
DecoderTestColumnHandle booleanColumn = new DecoderTestColumnHandle(0, "some_column", BOOLEAN, "long_field", null, null, false, false, false);
Map<DecoderColumnHandle, FieldValueProvider> decodedRow = buildAndDecodeColumn(booleanColumn, "long_field", "\"long\"", (long) 1);
assertThatThrownBy(decodedRow.get(booleanColumn)::getBoolean).isInstanceOf(PrestoException.class).hasMessageMatching("cannot decode object of 'class java.lang.Long' as 'boolean' for column 'some_column'");
}
Aggregations