Search in sources :

Example 36 with ArrayType

use of com.facebook.presto.common.type.ArrayType in project presto by prestodb.

the class TestStructuredColumnMismatchResolver method testResolveArray.

@Test
public void testResolveArray() {
    ArrayColumnChecksum checksum1 = new ArrayColumnChecksum(binary(0xa), binary(0xb), 1);
    ArrayColumnChecksum checksum2 = new ArrayColumnChecksum(binary(0x1a), binary(0xb), 1);
    ArrayColumnChecksum checksum3 = new ArrayColumnChecksum(binary(0xa), binary(0x1b), 1);
    ArrayColumnChecksum checksum4 = new ArrayColumnChecksum(binary(0xa), binary(0xb), 2);
    // resolved
    assertResolved(createMismatchedColumn(new ArrayType(DOUBLE), checksum1, checksum2));
    assertResolved(createMismatchedColumn(new ArrayType(REAL), checksum1, checksum2));
    assertResolved(createMismatchedColumn(new ArrayType(new ArrayType(DOUBLE)), checksum1, checksum2));
    // not resolved, contains no floating point types
    assertNotResolved(createMismatchedColumn(new ArrayType(INTEGER), checksum1, checksum2));
    assertNotResolved(createMismatchedColumn(new ArrayType(new ArrayType(INTEGER)), checksum1, checksum2));
    // not resolved, cardinality mismatches
    assertNotResolved(createMismatchedColumn(new ArrayType(DOUBLE), checksum1, checksum3));
    assertNotResolved(createMismatchedColumn(new ArrayType(DOUBLE), checksum1, checksum4));
}
Also used : ArrayType(com.facebook.presto.common.type.ArrayType) ArrayColumnChecksum(com.facebook.presto.verifier.checksum.ArrayColumnChecksum) Test(org.testng.annotations.Test)

Example 37 with ArrayType

use of com.facebook.presto.common.type.ArrayType in project presto by prestodb.

the class TestDictionaryColumnWriter method verifyIntegerInList.

@Test
public void verifyIntegerInList() throws IOException {
    List<List<Integer>> values = new ArrayList<>();
    for (int i = 0; i < 50_000; i++) {
        int childSize = i % 5;
        if (childSize == 4) {
            values.add(null);
        } else {
            List<Integer> childList = new ArrayList<>();
            for (int j = 0; j < childSize; j++) {
                childList.add(i + j);
            }
            values.add(childList);
        }
    }
    DirectConversionTester directConversionTester = new DirectConversionTester();
    Type listType = new ArrayType(INTEGER);
    testDictionary(listType, DWRF, true, true, directConversionTester, values);
}
Also used : ArrayType(com.facebook.presto.common.type.ArrayType) ArrayType(com.facebook.presto.common.type.ArrayType) Type(com.facebook.presto.common.type.Type) Lists.newArrayList(com.google.common.collect.Lists.newArrayList) ArrayList(java.util.ArrayList) List(java.util.List) Lists.newArrayList(com.google.common.collect.Lists.newArrayList) ArrayList(java.util.ArrayList) ImmutableList(com.google.common.collect.ImmutableList) Test(org.testng.annotations.Test)

Example 38 with ArrayType

use of com.facebook.presto.common.type.ArrayType in project presto by prestodb.

the class TestDictionaryColumnWriter method verifyStringInList.

@Test
public void verifyStringInList() throws IOException {
    List<List<String>> values = new ArrayList<>();
    for (int i = 0; i < 50_000; i++) {
        int childSize = i % 5;
        if (childSize == 4) {
            values.add(null);
        } else {
            List<String> childList = new ArrayList<>();
            for (int j = 0; j < childSize; j++) {
                childList.add(Integer.toString(i + j));
            }
            values.add(childList);
        }
    }
    DirectConversionTester directConversionTester = new DirectConversionTester();
    Type listType = new ArrayType(VARCHAR);
    testDictionary(listType, DWRF, true, true, directConversionTester, values);
}
Also used : ArrayType(com.facebook.presto.common.type.ArrayType) ArrayType(com.facebook.presto.common.type.ArrayType) Type(com.facebook.presto.common.type.Type) Lists.newArrayList(com.google.common.collect.Lists.newArrayList) ArrayList(java.util.ArrayList) List(java.util.List) Lists.newArrayList(com.google.common.collect.Lists.newArrayList) ArrayList(java.util.ArrayList) ImmutableList(com.google.common.collect.ImmutableList) Test(org.testng.annotations.Test)

Example 39 with ArrayType

use of com.facebook.presto.common.type.ArrayType in project presto by prestodb.

the class TestAvroDecoder method testArrayDecodedAsArray.

@Test
public void testArrayDecodedAsArray() throws Exception {
    DecoderTestColumnHandle row = new DecoderTestColumnHandle(0, "row", new ArrayType(BIGINT), "array_field", null, null, false, false, false);
    Map<DecoderColumnHandle, FieldValueProvider> decodedRow = buildAndDecodeColumn(row, "array_field", "{\"type\": \"array\", \"items\": \"long\"}", ImmutableList.of(114L, 136L));
    checkArrayValue(decodedRow, row, new long[] { 114, 136 });
}
Also used : ArrayType(com.facebook.presto.common.type.ArrayType) DecoderTestColumnHandle(com.facebook.presto.decoder.DecoderTestColumnHandle) FieldValueProvider(com.facebook.presto.decoder.FieldValueProvider) DecoderColumnHandle(com.facebook.presto.decoder.DecoderColumnHandle) Test(org.testng.annotations.Test)

Example 40 with ArrayType

use of com.facebook.presto.common.type.ArrayType 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 });
}
Also used : ArrayType(com.facebook.presto.common.type.ArrayType) DecoderTestColumnHandle(com.facebook.presto.decoder.DecoderTestColumnHandle) FieldValueProvider(com.facebook.presto.decoder.FieldValueProvider) ArrayList(java.util.ArrayList) DecoderColumnHandle(com.facebook.presto.decoder.DecoderColumnHandle) Test(org.testng.annotations.Test)

Aggregations

ArrayType (com.facebook.presto.common.type.ArrayType)287 Test (org.testng.annotations.Test)219 Type (com.facebook.presto.common.type.Type)99 RowType (com.facebook.presto.common.type.RowType)79 ArrayList (java.util.ArrayList)58 ImmutableList (com.google.common.collect.ImmutableList)54 List (java.util.List)51 MapType (com.facebook.presto.common.type.MapType)39 DecimalType.createDecimalType (com.facebook.presto.common.type.DecimalType.createDecimalType)36 Arrays.asList (java.util.Arrays.asList)34 Collections.singletonList (java.util.Collections.singletonList)33 MessageType (org.apache.parquet.schema.MessageType)30 BlockBuilder (com.facebook.presto.common.block.BlockBuilder)28 VarcharType.createUnboundedVarcharType (com.facebook.presto.common.type.VarcharType.createUnboundedVarcharType)27 MessageTypeParser.parseMessageType (org.apache.parquet.schema.MessageTypeParser.parseMessageType)27 InternalAggregationFunction (com.facebook.presto.operator.aggregation.InternalAggregationFunction)26 PrimitiveType (org.apache.parquet.schema.PrimitiveType)26 StructuralTestUtil.mapType (com.facebook.presto.tests.StructuralTestUtil.mapType)24 Block (com.facebook.presto.common.block.Block)23 DecimalType (com.facebook.presto.common.type.DecimalType)17