use of io.trino.spi.type.TestingTypeManager in project trino by trinodb.
the class TestIcebergSplitSource method testIncompleteDynamicFilterTimeout.
@Test(timeOut = 30_000)
public void testIncompleteDynamicFilterTimeout() throws Exception {
long startMillis = System.currentTimeMillis();
SchemaTableName schemaTableName = new SchemaTableName("tpch", "nation");
IcebergTableHandle tableHandle = new IcebergTableHandle(schemaTableName.getSchemaName(), schemaTableName.getTableName(), TableType.DATA, Optional.empty(), TupleDomain.all(), TupleDomain.all(), ImmutableSet.of(), Optional.empty());
Table nationTable = catalog.loadTable(SESSION, schemaTableName);
IcebergSplitSource splitSource = new IcebergSplitSource(tableHandle, nationTable.newScan(), Optional.empty(), new DynamicFilter() {
@Override
public Set<ColumnHandle> getColumnsCovered() {
return ImmutableSet.of();
}
@Override
public CompletableFuture<?> isBlocked() {
return CompletableFuture.runAsync(() -> {
try {
TimeUnit.HOURS.sleep(1);
} catch (InterruptedException e) {
throw new IllegalStateException(e);
}
});
}
@Override
public boolean isComplete() {
return false;
}
@Override
public boolean isAwaitable() {
return true;
}
@Override
public TupleDomain<ColumnHandle> getCurrentPredicate() {
return TupleDomain.all();
}
}, new Duration(2, SECONDS), alwaysTrue(), new TestingTypeManager(), false);
ImmutableList.Builder<IcebergSplit> splits = ImmutableList.builder();
while (!splitSource.isFinished()) {
splitSource.getNextBatch(null, 100).get().getSplits().stream().map(IcebergSplit.class::cast).forEach(splits::add);
}
assertThat(splits.build().size()).isGreaterThan(0);
assertTrue(splitSource.isFinished());
assertThat(System.currentTimeMillis() - startMillis).as("IcebergSplitSource failed to wait for dynamicFilteringWaitTimeout").isGreaterThanOrEqualTo(2000);
}
use of io.trino.spi.type.TestingTypeManager in project trino by trinodb.
the class TestIcebergV2 method updateTableToV2.
private Table updateTableToV2(String tableName) {
IcebergTableOperationsProvider tableOperationsProvider = new FileMetastoreTableOperationsProvider(new HdfsFileIoProvider(hdfsEnvironment));
TrinoCatalog catalog = new TrinoHiveCatalog(new CatalogName("hive"), CachingHiveMetastore.memoizeMetastore(metastore, 1000), hdfsEnvironment, new TestingTypeManager(), tableOperationsProvider, "test", false, false, false);
BaseTable table = (BaseTable) loadIcebergTable(catalog, tableOperationsProvider, SESSION, new SchemaTableName("tpch", tableName));
TableOperations operations = table.operations();
TableMetadata currentMetadata = operations.current();
operations.commit(currentMetadata, currentMetadata.upgradeToFormatVersion(2));
return table;
}
use of io.trino.spi.type.TestingTypeManager in project trino by trinodb.
the class TestAvroSchemaConverter method testSimpleSchema.
@Test
public void testSimpleSchema() {
Schema schema = Schema.create(Schema.Type.LONG);
AvroSchemaConverter avroSchemaConverter = new AvroSchemaConverter(new TestingTypeManager(), IGNORE);
List<Type> types = avroSchemaConverter.convertAvroSchema(schema);
assertEquals(getOnlyElement(types), BIGINT);
}
use of io.trino.spi.type.TestingTypeManager in project trino by trinodb.
the class TestAvroSchemaConverter method testNullableColumns.
@Test
public void testNullableColumns() {
Schema schema = SchemaBuilder.record(RECORD_NAME).fields().name("bool_col").type().nullable().booleanType().noDefault().name("int_col").type().nullable().intType().noDefault().name("long_col").type().nullable().longType().noDefault().name("float_col").type().nullable().floatType().noDefault().name("double_col").type().nullable().doubleType().noDefault().name("string_col").type().nullable().stringType().noDefault().name("enum_col").type().nullable().enumeration("colors").symbols("blue", "red", "yellow").noDefault().name("bytes_col").type().nullable().bytesType().noDefault().name("fixed_col").type().nullable().fixed("fixed").size(5).noDefault().name("union_col").type().unionOf().nullType().and().floatType().and().doubleType().endUnion().noDefault().name("union_col2").type().unionOf().nullType().and().intType().and().longType().endUnion().noDefault().name("union_col3").type().unionOf().nullType().and().bytesType().and().type("fixed").endUnion().noDefault().name("union_col4").type().unionOf().nullType().and().type("colors").and().stringType().endUnion().noDefault().name("list_col").type().nullable().array().items().intType().noDefault().name("map_col").type().nullable().map().values().intType().noDefault().name("record_col").type().nullable().record("record_col").fields().name("nested_list").type().nullable().array().items().map().values().stringType().noDefault().name("nested_map").type().nullable().map().values().array().items().stringType().noDefault().endRecord().noDefault().endRecord();
AvroSchemaConverter avroSchemaConverter = new AvroSchemaConverter(new TestingTypeManager(), IGNORE);
List<Type> types = avroSchemaConverter.convertAvroSchema(schema);
List<Type> expected = ImmutableList.<Type>builder().add(BOOLEAN).add(INTEGER).add(BIGINT).add(REAL).add(DOUBLE).add(VARCHAR).add(VARCHAR).add(VARBINARY).add(VARBINARY).add(DOUBLE).add(BIGINT).add(VARBINARY).add(VARCHAR).add(new ArrayType(INTEGER)).add(createType(INTEGER)).add(RowType.from(ImmutableList.<RowType.Field>builder().add(new RowType.Field(Optional.of("nested_list"), new ArrayType(createType(VARCHAR)))).add(new RowType.Field(Optional.of("nested_map"), createType(new ArrayType(VARCHAR)))).build())).build();
assertEquals(types, expected);
}
use of io.trino.spi.type.TestingTypeManager in project trino by trinodb.
the class TestAvroSchemaConverter method testEmptyFieldStrategyForEmptySchema.
@Test
public void testEmptyFieldStrategyForEmptySchema() {
Schema schema = SchemaBuilder.record(RECORD_NAME).fields().name("my_record").type().record("nested_record").fields().endRecord().noDefault().name("my_array").type().array().items().type("nested_record").noDefault().name("my_map").type().map().values().type("nested_record").noDefault().endRecord();
assertThatThrownBy(() -> new AvroSchemaConverter(new TestingTypeManager(), IGNORE).convertAvroSchema(schema)).isInstanceOf(IllegalStateException.class).hasMessage("Schema has no valid fields: '%s'", schema);
assertThatThrownBy(() -> new AvroSchemaConverter(new TestingTypeManager(), FAIL).convertAvroSchema(schema)).isInstanceOf(IllegalStateException.class).hasMessage("Struct type has no valid fields for schema: '%s'", SchemaBuilder.record("nested_record").fields().endRecord());
List<Type> typesForAddDummyStrategy = ImmutableList.<Type>builder().add(RowType.from(ImmutableList.<RowType.Field>builder().add(new RowType.Field(Optional.of(DUMMY_FIELD_NAME), BOOLEAN)).build())).add(new ArrayType(RowType.from(ImmutableList.<RowType.Field>builder().add(new RowType.Field(Optional.of(DUMMY_FIELD_NAME), BOOLEAN)).build()))).add(createType(RowType.from(ImmutableList.<RowType.Field>builder().add(new RowType.Field(Optional.of(DUMMY_FIELD_NAME), BOOLEAN)).build()))).build();
assertEquals(new AvroSchemaConverter(new TestingTypeManager(), ADD_DUMMY).convertAvroSchema(schema), typesForAddDummyStrategy);
}
Aggregations