use of io.prestosql.connector.informationschema.InformationSchemaTableHandle in project hetu-core by openlookeng.
the class TestInformationSchemaTableHandle method testInformationSchemaSerialize.
@Test
public void testInformationSchemaSerialize() throws Exception {
InformationSchemaTableHandle informationSchemaTableHandle = new InformationSchemaTableHandle("information_schema_catalog", "information_schema_schema", "information_schema_table", ImmutableSet.of(new QualifiedTablePrefix("abc", "xyz")));
assertTrue(objectMapper.canSerialize(InformationSchemaTableHandle.class));
String json = objectMapper.writeValueAsString(informationSchemaTableHandle);
testJsonEquals(json, SCHEMA_AS_MAP);
}
use of io.prestosql.connector.informationschema.InformationSchemaTableHandle 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.InformationSchemaTableHandle 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")));
}
use of io.prestosql.connector.informationschema.InformationSchemaTableHandle in project hetu-core by openlookeng.
the class TestInformationSchemaTableHandle method testInformationSchemaDeserialize.
@Test
public void testInformationSchemaDeserialize() throws Exception {
String json = objectMapper.writeValueAsString(SCHEMA_AS_MAP);
ConnectorTableHandle tableHandle = objectMapper.readValue(json, ConnectorTableHandle.class);
assertEquals(tableHandle.getClass(), InformationSchemaTableHandle.class);
InformationSchemaTableHandle informationSchemaHandle = (InformationSchemaTableHandle) tableHandle;
assertEquals(informationSchemaHandle.getCatalogName(), "information_schema_catalog");
assertEquals(informationSchemaHandle.getSchemaName(), "information_schema_schema");
assertEquals(informationSchemaHandle.getTableName(), "information_schema_table");
}
Aggregations