use of io.trino.plugin.tpch.TpchTableHandle in project trino by trinodb.
the class TestLogicalPlanner method testLikePredicate.
@Test
public void testLikePredicate() {
assertPlan("SELECT type FROM part WHERE type LIKE 'LARGE PLATED %'", anyTree(tableScan(tableHandle -> {
Map<ColumnHandle, Domain> domains = ((TpchTableHandle) tableHandle).getConstraint().getDomains().orElseThrow(() -> new AssertionError("Unexpected none TupleDomain"));
Domain domain = domains.entrySet().stream().filter(entry -> ((TpchColumnHandle) entry.getKey()).getColumnName().equals("type")).map(Entry::getValue).collect(toOptional()).orElseThrow(() -> new AssertionError("No domain for 'type'"));
assertEquals(domain, Domain.multipleValues(createVarcharType(25), ImmutableList.of("LARGE PLATED BRASS", "LARGE PLATED COPPER", "LARGE PLATED NICKEL", "LARGE PLATED STEEL", "LARGE PLATED TIN").stream().map(Slices::utf8Slice).collect(toImmutableList())));
return true;
}, TupleDomain.withColumnDomains(ImmutableMap.of(tableHandle -> ((TpchColumnHandle) tableHandle).getColumnName().equals("type"), Domain.create(ValueSet.ofRanges(Range.range(createVarcharType(25), utf8Slice("LARGE PLATED "), true, utf8Slice("LARGE PLATED!"), false)), false))), ImmutableMap.of())));
}
use of io.trino.plugin.tpch.TpchTableHandle in project trino by trinodb.
the class H2QueryRunner method insertRows.
private void insertRows(TpchMetadata tpchMetadata, TpchTable<?> tpchTable) {
TpchTableHandle tableHandle = tpchMetadata.getTableHandle(null, new SchemaTableName(TINY_SCHEMA_NAME, tpchTable.getTableName()));
insertRows(tpchMetadata.getTableMetadata(null, tableHandle), handle, createTpchRecordSet(tpchTable, tableHandle.getScaleFactor()));
}
use of io.trino.plugin.tpch.TpchTableHandle in project trino by trinodb.
the class TestRemoveUnsupportedDynamicFilters method setup.
@BeforeClass
public void setup() {
plannerContext = getQueryRunner().getPlannerContext();
metadata = plannerContext.getMetadata();
builder = new PlanBuilder(new PlanNodeIdAllocator(), metadata, TEST_SESSION);
CatalogName catalogName = getCurrentConnectorId();
lineitemTableHandle = new TableHandle(catalogName, new TpchTableHandle("sf1", "lineitem", 1.0), TestingTransactionHandle.create());
lineitemOrderKeySymbol = builder.symbol("LINEITEM_OK", BIGINT);
lineitemTableScanNode = builder.tableScan(lineitemTableHandle, ImmutableList.of(lineitemOrderKeySymbol), ImmutableMap.of(lineitemOrderKeySymbol, new TpchColumnHandle("orderkey", BIGINT)));
TableHandle ordersTableHandle = new TableHandle(catalogName, new TpchTableHandle("sf1", "orders", 1.0), TestingTransactionHandle.create());
ordersOrderKeySymbol = builder.symbol("ORDERS_OK", BIGINT);
ordersTableScanNode = builder.tableScan(ordersTableHandle, ImmutableList.of(ordersOrderKeySymbol), ImmutableMap.of(ordersOrderKeySymbol, new TpchColumnHandle("orderkey", BIGINT)));
}
use of io.trino.plugin.tpch.TpchTableHandle in project trino by trinodb.
the class TestRuleTester method testReportNoFireWithTableScan.
@Test
public void testReportNoFireWithTableScan() {
try (RuleTester tester = defaultRuleTester()) {
RuleAssert ruleAssert = tester.assertThat(rule("testReportNoFireWithTableScan rule", Pattern.typeOf(PlanNode.class), (node, captures, context) -> Result.empty())).on(p -> p.tableScan(new TableHandle(tester.getCurrentConnectorId(), new TpchTableHandle("sf1", "nation", 1.0), TestingTransactionHandle.create()), List.of(p.symbol("x")), Map.of(p.symbol("x"), new TestingColumnHandle("column"))));
PlanMatchPattern expected = values(List.of("whatever"), List.of());
assertThatThrownBy(() -> ruleAssert.matches(expected)).isInstanceOf(AssertionError.class).hasMessageMatching("testReportNoFireWithTableScan rule did not fire for:\n" + "(?s:.*)" + "\\QEstimates: {rows: 25 (225B), cpu: 225, memory: 0B, network: 0B}\\E\n" + "(?s:.*)");
}
}
use of io.trino.plugin.tpch.TpchTableHandle in project trino by trinodb.
the class TestRemoveRedundantPredicateAboveTableScan method setUpBeforeClass.
@BeforeClass
public void setUpBeforeClass() {
removeRedundantPredicateAboveTableScan = new RemoveRedundantPredicateAboveTableScan(tester().getPlannerContext(), tester().getTypeAnalyzer());
CatalogName catalogName = tester().getCurrentConnectorId();
TpchTableHandle nation = new TpchTableHandle("sf1", "nation", 1.0);
nationTableHandle = new TableHandle(catalogName, nation, TpchTransactionHandle.INSTANCE);
TpchTableHandle orders = new TpchTableHandle("sf1", "orders", 1.0);
ordersTableHandle = new TableHandle(catalogName, orders, TpchTransactionHandle.INSTANCE);
}
Aggregations