Search in sources :

Example 1 with Domain.singleValue

use of io.trino.spi.predicate.Domain.singleValue 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"))));
}
Also used : AND(io.trino.sql.tree.LogicalExpression.Operator.AND) NullableValue(io.trino.spi.predicate.NullableValue) Test(org.testng.annotations.Test) PlanMatchPattern.filter(io.trino.sql.planner.assertions.PlanMatchPattern.filter) CatalogName(io.trino.connector.CatalogName) VARCHAR(io.trino.spi.type.VarcharType.VARCHAR) FunctionCallBuilder(io.trino.sql.planner.FunctionCallBuilder) ImmutableList(com.google.common.collect.ImmutableList) TpchTableHandle(io.trino.plugin.tpch.TpchTableHandle) Slices(io.airlift.slice.Slices) ColumnHandle(io.trino.spi.connector.ColumnHandle) ArithmeticBinaryExpression(io.trino.sql.tree.ArithmeticBinaryExpression) TpchColumnHandle(io.trino.plugin.tpch.TpchColumnHandle) ImmutableMap(com.google.common.collect.ImmutableMap) BaseRuleTest(io.trino.sql.planner.iterative.rule.test.BaseRuleTest) Domain(io.trino.spi.predicate.Domain) BeforeClass(org.testng.annotations.BeforeClass) TupleDomain(io.trino.spi.predicate.TupleDomain) MODULUS(io.trino.sql.tree.ArithmeticBinaryExpression.Operator.MODULUS) ComparisonExpression(io.trino.sql.tree.ComparisonExpression) TpchTransactionHandle(io.trino.plugin.tpch.TpchTransactionHandle) GenericLiteral(io.trino.sql.tree.GenericLiteral) QualifiedName(io.trino.sql.tree.QualifiedName) EQUAL(io.trino.sql.tree.ComparisonExpression.Operator.EQUAL) TableHandle(io.trino.metadata.TableHandle) BIGINT(io.trino.spi.type.BigintType.BIGINT) SymbolReference(io.trino.sql.tree.SymbolReference) Domain.singleValue(io.trino.spi.predicate.Domain.singleValue) PlanMatchPattern.constrainedTableScanWithTableLayout(io.trino.sql.planner.assertions.PlanMatchPattern.constrainedTableScanWithTableLayout) LogicalExpression(io.trino.sql.tree.LogicalExpression) VarcharType.createVarcharType(io.trino.spi.type.VarcharType.createVarcharType) PlanBuilder.expression(io.trino.sql.planner.iterative.rule.test.PlanBuilder.expression) ColumnHandle(io.trino.spi.connector.ColumnHandle) TpchColumnHandle(io.trino.plugin.tpch.TpchColumnHandle) TpchColumnHandle(io.trino.plugin.tpch.TpchColumnHandle) Test(org.testng.annotations.Test) BaseRuleTest(io.trino.sql.planner.iterative.rule.test.BaseRuleTest)

Aggregations

ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 Slices (io.airlift.slice.Slices)1 CatalogName (io.trino.connector.CatalogName)1 TableHandle (io.trino.metadata.TableHandle)1 TpchColumnHandle (io.trino.plugin.tpch.TpchColumnHandle)1 TpchTableHandle (io.trino.plugin.tpch.TpchTableHandle)1 TpchTransactionHandle (io.trino.plugin.tpch.TpchTransactionHandle)1 ColumnHandle (io.trino.spi.connector.ColumnHandle)1 Domain (io.trino.spi.predicate.Domain)1 Domain.singleValue (io.trino.spi.predicate.Domain.singleValue)1 NullableValue (io.trino.spi.predicate.NullableValue)1 TupleDomain (io.trino.spi.predicate.TupleDomain)1 BIGINT (io.trino.spi.type.BigintType.BIGINT)1 VARCHAR (io.trino.spi.type.VarcharType.VARCHAR)1 VarcharType.createVarcharType (io.trino.spi.type.VarcharType.createVarcharType)1 FunctionCallBuilder (io.trino.sql.planner.FunctionCallBuilder)1 PlanMatchPattern.constrainedTableScanWithTableLayout (io.trino.sql.planner.assertions.PlanMatchPattern.constrainedTableScanWithTableLayout)1 PlanMatchPattern.filter (io.trino.sql.planner.assertions.PlanMatchPattern.filter)1 BaseRuleTest (io.trino.sql.planner.iterative.rule.test.BaseRuleTest)1