use of io.trino.plugin.hive.util.HiveBucketing.BucketingVersion.BUCKETING_V1 in project trino by trinodb.
the class AbstractTestHive method prepareInvalidBuckets.
private void prepareInvalidBuckets(HiveStorageFormat storageFormat, SchemaTableName tableName) throws Exception {
createEmptyTable(tableName, storageFormat, ImmutableList.of(new Column("id", HIVE_LONG, Optional.empty()), new Column("name", HIVE_STRING, Optional.empty())), ImmutableList.of(), Optional.of(new HiveBucketProperty(ImmutableList.of("id"), BUCKETING_V1, 8, ImmutableList.of())));
MaterializedResult.Builder dataBuilder = MaterializedResult.resultBuilder(SESSION, BIGINT, VARCHAR);
for (long id = 0; id < 100; id++) {
dataBuilder.row(id, String.valueOf(id));
}
insertData(tableName, dataBuilder.build());
try (Transaction transaction = newTransaction()) {
Set<String> files = listAllDataFiles(transaction, tableName.getSchemaName(), tableName.getTableName());
Path bucket2 = files.stream().map(Path::new).filter(path -> path.getName().startsWith("000002_0_")).collect(onlyElement());
Path bucket5 = files.stream().map(Path::new).filter(path -> path.getName().startsWith("000005_0_")).collect(onlyElement());
HdfsContext context = new HdfsContext(newSession());
FileSystem fileSystem = hdfsEnvironment.getFileSystem(context, bucket2);
fileSystem.delete(bucket2, false);
fileSystem.rename(bucket5, bucket2);
}
}
use of io.trino.plugin.hive.util.HiveBucketing.BucketingVersion.BUCKETING_V1 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);
}
Aggregations