Search in sources :

Example 1 with BUCKETING_V2

use of io.trino.plugin.hive.util.HiveBucketing.BucketingVersion.BUCKETING_V2 in project trino by trinodb.

the class TestHiveBucketing method assertBucketsEqual.

private static void assertBucketsEqual(List<String> hiveTypeStrings, List<List<Object>> hiveValues, int bucketCount, Optional<Set<Integer>> expectedBucketsV1, Optional<Set<Integer>> expectedBucketsV2) {
    List<HiveType> hiveTypes = hiveTypeStrings.stream().map(HiveType::valueOf).collect(toImmutableList());
    List<TypeInfo> hiveTypeInfos = hiveTypes.stream().map(HiveType::getTypeInfo).collect(toImmutableList());
    List<Type> trinoTypes = hiveTypes.stream().map(type -> type.getType(TESTING_TYPE_MANAGER)).collect(toImmutableList());
    ImmutableList.Builder<List<NullableValue>> values = ImmutableList.builder();
    for (int i = 0; i < hiveValues.size(); i++) {
        List<Object> valueList = hiveValues.get(i);
        Type trinoType = trinoTypes.get(i);
        values.add(valueList.stream().map(value -> new NullableValue(trinoType, toNativeContainerValue(trinoType, value))).collect(toImmutableList()));
    }
    assertEquals(getHiveBuckets(BUCKETING_V1, bucketCount, hiveTypeInfos, values.build()), expectedBucketsV1);
    assertEquals(getHiveBuckets(BUCKETING_V2, bucketCount, hiveTypeInfos, values.build()), expectedBucketsV2);
}
Also used : DateType(io.trino.spi.type.DateType) BUCKETING_V2(io.trino.plugin.hive.util.HiveBucketing.BucketingVersion.BUCKETING_V2) Test(org.testng.annotations.Test) Date(org.apache.hadoop.hive.common.type.Date) BooleanType(io.trino.spi.type.BooleanType) BUCKETING_V1(io.trino.plugin.hive.util.HiveBucketing.BucketingVersion.BUCKETING_V1) Block(io.trino.spi.block.Block) TimestampType.createTimestampType(io.trino.spi.type.TimestampType.createTimestampType) Arrays.asList(java.util.Arrays.asList) Slices(io.airlift.slice.Slices) Map(java.util.Map) AssertionsForClassTypes.assertThatThrownBy(org.assertj.core.api.AssertionsForClassTypes.assertThatThrownBy) ObjectInspector(org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector) Double.longBitsToDouble(java.lang.Double.longBitsToDouble) SmallintType(io.trino.spi.type.SmallintType) RowType(io.trino.spi.type.RowType) ImmutableSet(com.google.common.collect.ImmutableSet) ImmutableMap(com.google.common.collect.ImmutableMap) ImmutableList.toImmutableList(com.google.common.collect.ImmutableList.toImmutableList) Set(java.util.Set) ArrayType(io.trino.spi.type.ArrayType) TypeUtils.writeNativeValue(io.trino.spi.type.TypeUtils.writeNativeValue) List(java.util.List) Lists.newArrayList(com.google.common.collect.Lists.newArrayList) BucketingVersion(io.trino.plugin.hive.util.HiveBucketing.BucketingVersion) Entry(java.util.Map.Entry) Optional(java.util.Optional) TypeInfoFactory.timestampTypeInfo(org.apache.hadoop.hive.serde2.typeinfo.TypeInfoFactory.timestampTypeInfo) TypeInfoUtils(org.apache.hadoop.hive.serde2.typeinfo.TypeInfoUtils) JavaHiveVarcharObjectInspector(org.apache.hadoop.hive.serde2.objectinspector.primitive.JavaHiveVarcharObjectInspector) NullableValue(io.trino.spi.predicate.NullableValue) DoubleType(io.trino.spi.type.DoubleType) Type(io.trino.spi.type.Type) Page(io.trino.spi.Page) Assert.assertEquals(org.testng.Assert.assertEquals) HiveBucketing.getHiveBuckets(io.trino.plugin.hive.util.HiveBucketing.getHiveBuckets) Float.intBitsToFloat(java.lang.Float.intBitsToFloat) ObjectInspectorUtils(org.apache.hadoop.hive.serde2.objectinspector.ObjectInspectorUtils) TimestampType(io.trino.spi.type.TimestampType) ArrayList(java.util.ArrayList) HiveType(io.trino.plugin.hive.HiveType) BigintType(io.trino.spi.type.BigintType) VarcharType(io.trino.spi.type.VarcharType) HiveVarchar(org.apache.hadoop.hive.common.type.HiveVarchar) ImmutableList(com.google.common.collect.ImmutableList) TinyintType(io.trino.spi.type.TinyintType) IntegerType(io.trino.spi.type.IntegerType) MapType(io.trino.spi.type.MapType) TESTING_TYPE_MANAGER(io.trino.type.InternalTypeManager.TESTING_TYPE_MANAGER) Maps(com.google.common.collect.Maps) TypeInfo(org.apache.hadoop.hive.serde2.typeinfo.TypeInfo) RealType(io.trino.spi.type.RealType) BlockBuilder(io.trino.spi.block.BlockBuilder) ImmutableList.toImmutableList(com.google.common.collect.ImmutableList.toImmutableList) ImmutableList(com.google.common.collect.ImmutableList) NullableValue(io.trino.spi.predicate.NullableValue) TypeInfoFactory.timestampTypeInfo(org.apache.hadoop.hive.serde2.typeinfo.TypeInfoFactory.timestampTypeInfo) TypeInfo(org.apache.hadoop.hive.serde2.typeinfo.TypeInfo) DateType(io.trino.spi.type.DateType) BooleanType(io.trino.spi.type.BooleanType) TimestampType.createTimestampType(io.trino.spi.type.TimestampType.createTimestampType) SmallintType(io.trino.spi.type.SmallintType) RowType(io.trino.spi.type.RowType) ArrayType(io.trino.spi.type.ArrayType) DoubleType(io.trino.spi.type.DoubleType) Type(io.trino.spi.type.Type) TimestampType(io.trino.spi.type.TimestampType) HiveType(io.trino.plugin.hive.HiveType) BigintType(io.trino.spi.type.BigintType) VarcharType(io.trino.spi.type.VarcharType) TinyintType(io.trino.spi.type.TinyintType) IntegerType(io.trino.spi.type.IntegerType) MapType(io.trino.spi.type.MapType) RealType(io.trino.spi.type.RealType) Arrays.asList(java.util.Arrays.asList) ImmutableList.toImmutableList(com.google.common.collect.ImmutableList.toImmutableList) List(java.util.List) Lists.newArrayList(com.google.common.collect.Lists.newArrayList) ArrayList(java.util.ArrayList) ImmutableList(com.google.common.collect.ImmutableList) HiveType(io.trino.plugin.hive.HiveType)

Aggregations

ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableList.toImmutableList (com.google.common.collect.ImmutableList.toImmutableList)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 Lists.newArrayList (com.google.common.collect.Lists.newArrayList)1 Maps (com.google.common.collect.Maps)1 Slices (io.airlift.slice.Slices)1 HiveType (io.trino.plugin.hive.HiveType)1 BucketingVersion (io.trino.plugin.hive.util.HiveBucketing.BucketingVersion)1 BUCKETING_V1 (io.trino.plugin.hive.util.HiveBucketing.BucketingVersion.BUCKETING_V1)1 BUCKETING_V2 (io.trino.plugin.hive.util.HiveBucketing.BucketingVersion.BUCKETING_V2)1 HiveBucketing.getHiveBuckets (io.trino.plugin.hive.util.HiveBucketing.getHiveBuckets)1 Page (io.trino.spi.Page)1 Block (io.trino.spi.block.Block)1 BlockBuilder (io.trino.spi.block.BlockBuilder)1 NullableValue (io.trino.spi.predicate.NullableValue)1 ArrayType (io.trino.spi.type.ArrayType)1 BigintType (io.trino.spi.type.BigintType)1 BooleanType (io.trino.spi.type.BooleanType)1 DateType (io.trino.spi.type.DateType)1