Search in sources :

Example 6 with TestingFunctionResolution

use of io.trino.metadata.TestingFunctionResolution in project trino by trinodb.

the class TestDeterminismEvaluator method testDeterminismEvaluator.

@Test
public void testDeterminismEvaluator() {
    TestingFunctionResolution functionResolution = new TestingFunctionResolution();
    CallExpression random = new CallExpression(functionResolution.resolveFunction(QualifiedName.of("random"), fromTypes(BIGINT)), singletonList(constant(10L, BIGINT)));
    assertFalse(isDeterministic(random));
    InputReferenceExpression col0 = field(0, BIGINT);
    ResolvedFunction lessThan = functionResolution.resolveOperator(LESS_THAN, ImmutableList.of(BIGINT, BIGINT));
    CallExpression lessThanExpression = new CallExpression(lessThan, ImmutableList.of(col0, constant(10L, BIGINT)));
    assertTrue(isDeterministic(lessThanExpression));
    CallExpression lessThanRandomExpression = new CallExpression(lessThan, ImmutableList.of(col0, random));
    assertFalse(isDeterministic(lessThanRandomExpression));
}
Also used : TestingFunctionResolution(io.trino.metadata.TestingFunctionResolution) ResolvedFunction(io.trino.metadata.ResolvedFunction) Test(org.testng.annotations.Test)

Example 7 with TestingFunctionResolution

use of io.trino.metadata.TestingFunctionResolution in project trino by trinodb.

the class BenchmarkPageProcessor method setup.

@Setup
public void setup() {
    inputPage = createInputPage();
    TestingFunctionResolution functionResolution = new TestingFunctionResolution();
    RowExpression filterExpression = createFilterExpression(functionResolution);
    RowExpression projectExpression = createProjectExpression(functionResolution);
    ExpressionCompiler expressionCompiler = functionResolution.getExpressionCompiler();
    compiledProcessor = expressionCompiler.compilePageProcessor(Optional.of(filterExpression), ImmutableList.of(projectExpression)).get();
}
Also used : TestingFunctionResolution(io.trino.metadata.TestingFunctionResolution) RowExpression(io.trino.sql.relational.RowExpression) Setup(org.openjdk.jmh.annotations.Setup)

Example 8 with TestingFunctionResolution

use of io.trino.metadata.TestingFunctionResolution in project trino by trinodb.

the class TestEvaluateClassifierPredictions method testEvaluateClassifierPredictions.

@Test
public void testEvaluateClassifierPredictions() {
    TestingFunctionResolution functionResolution = new TestingFunctionResolution(extractFunctions(new MLPlugin().getFunctions()));
    TestingAggregationFunction aggregation = functionResolution.getAggregateFunction(QualifiedName.of("evaluate_classifier_predictions"), fromTypes(BIGINT, BIGINT));
    Aggregator aggregator = aggregation.createAggregatorFactory(SINGLE, ImmutableList.of(0, 1), OptionalInt.empty()).createAggregator();
    aggregator.processPage(getPage());
    BlockBuilder finalOut = VARCHAR.createBlockBuilder(null, 1);
    aggregator.evaluate(finalOut);
    Block block = finalOut.build();
    String output = VARCHAR.getSlice(block, 0).toStringUtf8();
    List<String> parts = ImmutableList.copyOf(Splitter.on('\n').omitEmptyStrings().split(output));
    assertEquals(parts.size(), 7, output);
    assertEquals(parts.get(0), "Accuracy: 1/2 (50.00%)");
}
Also used : TestingFunctionResolution(io.trino.metadata.TestingFunctionResolution) Aggregator(io.trino.operator.aggregation.Aggregator) Block(io.trino.spi.block.Block) TestingAggregationFunction(io.trino.operator.aggregation.TestingAggregationFunction) BlockBuilder(io.trino.spi.block.BlockBuilder) Test(org.testng.annotations.Test)

Example 9 with TestingFunctionResolution

use of io.trino.metadata.TestingFunctionResolution in project trino by trinodb.

the class TestScalarStatsCalculator method setUp.

@BeforeClass
public void setUp() {
    functionResolution = new TestingFunctionResolution();
    calculator = new ScalarStatsCalculator(functionResolution.getPlannerContext(), createTestingTypeAnalyzer(functionResolution.getPlannerContext()));
    session = testSessionBuilder().build();
}
Also used : TestingFunctionResolution(io.trino.metadata.TestingFunctionResolution) BeforeClass(org.testng.annotations.BeforeClass)

Example 10 with TestingFunctionResolution

use of io.trino.metadata.TestingFunctionResolution in project trino by trinodb.

the class TestDomainTranslator method setup.

@BeforeClass
public void setup() {
    functionResolution = new TestingFunctionResolution();
    literalEncoder = new LiteralEncoder(functionResolution.getPlannerContext());
    domainTranslator = new DomainTranslator(functionResolution.getPlannerContext());
}
Also used : TestingFunctionResolution(io.trino.metadata.TestingFunctionResolution) BeforeClass(org.testng.annotations.BeforeClass)

Aggregations

TestingFunctionResolution (io.trino.metadata.TestingFunctionResolution)12 Test (org.testng.annotations.Test)9 Page (io.trino.spi.Page)3 RowExpression (io.trino.sql.relational.RowExpression)3 BeforeClass (org.testng.annotations.BeforeClass)3 PageProcessor (io.trino.operator.project.PageProcessor)2 Block (io.trino.spi.block.Block)2 ExpressionCompiler (io.trino.sql.gen.ExpressionCompiler)2 PlanNodeId (io.trino.sql.planner.plan.PlanNodeId)2 StringLiteral (io.trino.sql.tree.StringLiteral)2 TestingTicker (io.airlift.testing.TestingTicker)1 BlockAssertions.createLongSequenceBlock (io.trino.block.BlockAssertions.createLongSequenceBlock)1 BlockAssertions.createSlicesBlock (io.trino.block.BlockAssertions.createSlicesBlock)1 BlockAssertions.createStringsBlock (io.trino.block.BlockAssertions.createStringsBlock)1 ResolvedFunction (io.trino.metadata.ResolvedFunction)1 DriverYieldSignal (io.trino.operator.DriverYieldSignal)1 Aggregator (io.trino.operator.aggregation.Aggregator)1 TestingAggregationFunction (io.trino.operator.aggregation.TestingAggregationFunction)1 BlockBuilder (io.trino.spi.block.BlockBuilder)1 LazyBlock (io.trino.spi.block.LazyBlock)1