use of com.facebook.presto.connector.informationSchema.InformationSchemaMetadata in project presto by prestodb.
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<ColumnHandle> constraint = new Constraint<>(TupleDomain.withColumnDomains(domains.build()));
InformationSchemaMetadata informationSchemaMetadata = new InformationSchemaMetadata("test_catalog", metadata);
List<ConnectorTableLayoutResult> layoutResults = informationSchemaMetadata.getTableLayouts(createNewSession(transactionId), new InformationSchemaTableHandle("test_catalog", "information_schema", "views"), constraint, Optional.empty());
assertEquals(layoutResults.size(), 1);
ConnectorTableLayoutHandle handle = layoutResults.get(0).getTableLayout().getHandle();
assertTrue(handle instanceof InformationSchemaTableLayoutHandle);
InformationSchemaTableLayoutHandle tableHandle = (InformationSchemaTableLayoutHandle) handle;
assertEquals(tableHandle.getPrefixes(), ImmutableSet.of(new QualifiedTablePrefix("test_catalog", "test_schema", "test_view")));
}
use of com.facebook.presto.connector.informationSchema.InformationSchemaMetadata in project presto by prestodb.
the class TestInformationSchemaMetadata method testInformationSchemaPredicatePushdownWithConstraintPredicate.
@Test
public void testInformationSchemaPredicatePushdownWithConstraintPredicate() {
TransactionId transactionId = transactionManager.beginTransaction(false);
Constraint<ColumnHandle> 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;
});
InformationSchemaMetadata informationSchemaMetadata = new InformationSchemaMetadata("test_catalog", metadata);
List<ConnectorTableLayoutResult> layoutResults = informationSchemaMetadata.getTableLayouts(createNewSession(transactionId), new InformationSchemaTableHandle("test_catalog", "information_schema", "views"), constraint, Optional.empty());
assertEquals(layoutResults.size(), 1);
ConnectorTableLayoutHandle handle = layoutResults.get(0).getTableLayout().getHandle();
assertTrue(handle instanceof InformationSchemaTableLayoutHandle);
InformationSchemaTableLayoutHandle tableHandle = (InformationSchemaTableLayoutHandle) handle;
assertEquals(tableHandle.getPrefixes(), ImmutableSet.of(new QualifiedTablePrefix("test_catalog", "test_schema", "test_view")));
}
Aggregations