use of io.trino.spi.type.BigintType.BIGINT in project trino by trinodb.
the class TestRemoveRedundantPredicateAboveTableScan method skipNotFullyExtractedConjunct.
@Test
public void skipNotFullyExtractedConjunct() {
ColumnHandle textColumnHandle = new TpchColumnHandle("name", VARCHAR);
ColumnHandle nationKeyColumnHandle = new TpchColumnHandle("nationkey", BIGINT);
tester().assertThat(removeRedundantPredicateAboveTableScan).on(p -> p.filter(expression("name LIKE 'LARGE PLATED %' AND nationkey = BIGINT '44'"), p.tableScan(nationTableHandle, ImmutableList.of(p.symbol("name", VARCHAR), p.symbol("nationkey", BIGINT)), ImmutableMap.of(p.symbol("name", VARCHAR), textColumnHandle, p.symbol("nationkey", BIGINT), nationKeyColumnHandle), TupleDomain.fromFixedValues(ImmutableMap.of(textColumnHandle, NullableValue.of(VARCHAR, Slices.utf8Slice("value")), nationKeyColumnHandle, NullableValue.of(BIGINT, (long) 44)))))).matches(filter(expression("name LIKE 'LARGE PLATED %'"), constrainedTableScanWithTableLayout("nation", ImmutableMap.of("nationkey", Domain.singleValue(BIGINT, 44L), "name", Domain.singleValue(VARCHAR, Slices.utf8Slice("value"))), ImmutableMap.of("nationkey", "nationkey", "name", "name"))));
}
use of io.trino.spi.type.BigintType.BIGINT in project trino by trinodb.
the class TestRemoveRedundantPredicateAboveTableScan method doesNotFireOnNonDeterministicPredicate.
@Test
public void doesNotFireOnNonDeterministicPredicate() {
ColumnHandle columnHandle = new TpchColumnHandle("nationkey", BIGINT);
tester().assertThat(removeRedundantPredicateAboveTableScan).on(p -> p.filter(new ComparisonExpression(EQUAL, FunctionCallBuilder.resolve(tester().getSession(), tester().getMetadata()).setName(QualifiedName.of("rand")).build(), new GenericLiteral("BIGINT", "42")), p.tableScan(nationTableHandle, ImmutableList.of(p.symbol("nationkey", BIGINT)), ImmutableMap.of(p.symbol("nationkey", BIGINT), columnHandle), TupleDomain.all()))).doesNotFire();
}
use of io.trino.spi.type.BigintType.BIGINT in project trino by trinodb.
the class TestRemoveRedundantPredicateAboveTableScan method doesNotFireOnNoTableScanPredicate.
@Test
public void doesNotFireOnNoTableScanPredicate() {
ColumnHandle columnHandle = new TpchColumnHandle("nationkey", BIGINT);
tester().assertThat(removeRedundantPredicateAboveTableScan).on(p -> p.filter(expression("(nationkey > 3 OR nationkey > 0) AND (nationkey > 3 OR nationkey < 1)"), p.tableScan(nationTableHandle, ImmutableList.of(p.symbol("nationkey", BIGINT)), ImmutableMap.of(p.symbol("nationkey", BIGINT), columnHandle), TupleDomain.all()))).doesNotFire();
}
use of io.trino.spi.type.BigintType.BIGINT in project trino by trinodb.
the class TestRemoveRedundantPredicateAboveTableScan method doesNotConsumeRemainingPredicateIfNewDomainIsWider.
@Test
public void doesNotConsumeRemainingPredicateIfNewDomainIsWider() {
ColumnHandle columnHandle = new TpchColumnHandle("nationkey", BIGINT);
tester().assertThat(removeRedundantPredicateAboveTableScan).on(p -> p.filter(new LogicalExpression(AND, ImmutableList.of(new ComparisonExpression(EQUAL, FunctionCallBuilder.resolve(tester().getSession(), tester().getMetadata()).setName(QualifiedName.of("rand")).build(), new GenericLiteral("BIGINT", "42")), new ComparisonExpression(EQUAL, new ArithmeticBinaryExpression(MODULUS, new SymbolReference("nationkey"), new GenericLiteral("BIGINT", "17")), new GenericLiteral("BIGINT", "44")), LogicalExpression.or(new ComparisonExpression(EQUAL, new SymbolReference("nationkey"), new GenericLiteral("BIGINT", "44")), new ComparisonExpression(EQUAL, new SymbolReference("nationkey"), new GenericLiteral("BIGINT", "45"))))), p.tableScan(nationTableHandle, ImmutableList.of(p.symbol("nationkey", BIGINT)), ImmutableMap.of(p.symbol("nationkey", BIGINT), columnHandle), TupleDomain.fromFixedValues(ImmutableMap.of(columnHandle, NullableValue.of(BIGINT, (long) 44)))))).matches(filter(LogicalExpression.and(new ComparisonExpression(EQUAL, FunctionCallBuilder.resolve(tester().getSession(), tester().getMetadata()).setName(QualifiedName.of("rand")).build(), new GenericLiteral("BIGINT", "42")), new ComparisonExpression(EQUAL, new ArithmeticBinaryExpression(MODULUS, new SymbolReference("nationkey"), new GenericLiteral("BIGINT", "17")), new GenericLiteral("BIGINT", "44"))), constrainedTableScanWithTableLayout("nation", ImmutableMap.of("nationkey", singleValue(BIGINT, (long) 44)), ImmutableMap.of("nationkey", "nationkey"))));
}
use of io.trino.spi.type.BigintType.BIGINT in project trino by trinodb.
the class TestRemoveAggregationInSemiJoin method semiJoinWithAggregationAsFilteringSource.
private static PlanNode semiJoinWithAggregationAsFilteringSource(PlanBuilder p) {
Symbol leftKey = p.symbol("leftKey");
Symbol rightKey = p.symbol("rightKey");
return p.semiJoin(leftKey, rightKey, p.symbol("match"), Optional.empty(), Optional.empty(), p.values(leftKey), p.aggregation(builder -> builder.globalGrouping().addAggregation(rightKey, expression("count(rightValue)"), ImmutableList.of(BIGINT)).source(p.values(p.symbol("rightValue")))));
}
Aggregations