use of io.prestosql.connector.informationschema.InformationSchemaMetadata in project hetu-core by openlookeng.
the class TestInformationSchemaMetadata method testInformationSchemaPredicatePushdownWithConstraintPredicate.
@Test
public void testInformationSchemaPredicatePushdownWithConstraintPredicate() {
TransactionId transactionId = transactionManager.beginTransaction(false);
Constraint constraint = new Constraint(TupleDomain.all(), // test_schema has a table named "another_table" and we filter that out in this predicate
bindings -> {
NullableValue catalog = bindings.get(new InformationSchemaColumnHandle("table_catalog"));
NullableValue schema = bindings.get(new InformationSchemaColumnHandle("table_schema"));
NullableValue table = bindings.get(new InformationSchemaColumnHandle("table_name"));
boolean isValid = true;
if (catalog != null) {
isValid = ((Slice) catalog.getValue()).toStringUtf8().equals("test_catalog");
}
if (schema != null) {
isValid &= ((Slice) schema.getValue()).toStringUtf8().equals("test_schema");
}
if (table != null) {
isValid &= ((Slice) table.getValue()).toStringUtf8().equals("test_view");
}
return isValid;
});
ConnectorSession session = createNewSession(transactionId);
ConnectorMetadata connectorMetadata = new InformationSchemaMetadata("test_catalog", this.metadata);
InformationSchemaTableHandle tableHandle = (InformationSchemaTableHandle) connectorMetadata.getTableHandle(session, new SchemaTableName("information_schema", "views"));
tableHandle = connectorMetadata.applyFilter(session, tableHandle, constraint).map(ConstraintApplicationResult::getHandle).map(InformationSchemaTableHandle.class::cast).orElseThrow(AssertionError::new);
assertEquals(tableHandle.getPrefixes(), ImmutableSet.of(new QualifiedTablePrefix("test_catalog", "test_schema", "test_view")));
}
use of io.prestosql.connector.informationschema.InformationSchemaMetadata in project hetu-core by openlookeng.
the class TestInformationSchemaMetadata method testInformationSchemaPredicatePushdown.
/**
* Tests information schema predicate pushdown when both schema and table name are specified.
*/
@Test
public void testInformationSchemaPredicatePushdown() {
TransactionId transactionId = transactionManager.beginTransaction(false);
ImmutableMap.Builder<ColumnHandle, Domain> domains = new ImmutableMap.Builder<>();
domains.put(new InformationSchemaColumnHandle("table_schema"), Domain.singleValue(VARCHAR, Slices.utf8Slice("test_schema")));
domains.put(new InformationSchemaColumnHandle("table_name"), Domain.singleValue(VARCHAR, Slices.utf8Slice("test_view")));
Constraint constraint = new Constraint(TupleDomain.withColumnDomains(domains.build()));
ConnectorSession session = createNewSession(transactionId);
ConnectorMetadata connectorMetadata = new InformationSchemaMetadata("test_catalog", this.metadata);
InformationSchemaTableHandle tableHandle = (InformationSchemaTableHandle) connectorMetadata.getTableHandle(session, new SchemaTableName("information_schema", "views"));
tableHandle = connectorMetadata.applyFilter(session, tableHandle, constraint).map(ConstraintApplicationResult::getHandle).map(InformationSchemaTableHandle.class::cast).orElseThrow(AssertionError::new);
assertEquals(tableHandle.getPrefixes(), ImmutableSet.of(new QualifiedTablePrefix("test_catalog", "test_schema", "test_view")));
}
Aggregations