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));
}
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();
}
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%)");
}
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();
}
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());
}
Aggregations