use of io.trino.sql.planner.iterative.rule.PushPredicateIntoTableScan in project trino by trinodb.
the class TestConnectorPushdownRulesWithHive method testPredicatePushdown.
@Test
public void testPredicatePushdown() {
String tableName = "predicate_test";
tester().getQueryRunner().execute(format("CREATE TABLE %s (a, b) AS SELECT 5, 6", tableName));
PushPredicateIntoTableScan pushPredicateIntoTableScan = new PushPredicateIntoTableScan(tester().getPlannerContext(), tester().getTypeAnalyzer());
HiveTableHandle hiveTable = new HiveTableHandle(SCHEMA_NAME, tableName, ImmutableMap.of(), ImmutableList.of(), ImmutableList.of(), Optional.empty());
TableHandle table = new TableHandle(new CatalogName(HIVE_CATALOG_NAME), hiveTable, new HiveTransactionHandle(false));
HiveColumnHandle column = createBaseColumn("a", 0, HIVE_INT, INTEGER, REGULAR, Optional.empty());
tester().assertThat(pushPredicateIntoTableScan).on(p -> p.filter(PlanBuilder.expression("a = 5"), p.tableScan(table, ImmutableList.of(p.symbol("a", INTEGER)), ImmutableMap.of(p.symbol("a", INTEGER), column)))).matches(filter("a = 5", tableScan(tableHandle -> ((HiveTableHandle) tableHandle).getCompactEffectivePredicate().getDomains().get().equals(ImmutableMap.of(column, Domain.singleValue(INTEGER, 5L))), TupleDomain.all(), ImmutableMap.of("a", column::equals))));
metastore.dropTable(SCHEMA_NAME, tableName, true);
}
Aggregations