use of com.facebook.presto.spi.relation.VariableReferenceExpression in project presto by prestodb.
the class TestVerifyNoOriginalExpression method testValidateForWindow.
@Test
public void testValidateForWindow() {
Optional<VariableReferenceExpression> startValue = Optional.of(VARIABLE_REFERENCE_EXPRESSION);
Optional<VariableReferenceExpression> endValue = Optional.of(VARIABLE_REFERENCE_EXPRESSION);
Optional<String> originalStartValue = Optional.of("count");
Optional<String> originalEndValue = Optional.of("count");
WindowNode.Frame frame = new WindowNode.Frame(WindowNode.Frame.WindowType.RANGE, WindowNode.Frame.BoundType.UNBOUNDED_FOLLOWING, startValue, WindowNode.Frame.BoundType.UNBOUNDED_FOLLOWING, endValue, originalStartValue, originalEndValue);
WindowNode.Function function = new WindowNode.Function(comparisonCallExpression, frame, false);
ImmutableList<VariableReferenceExpression> partitionBy = ImmutableList.of(VARIABLE_REFERENCE_EXPRESSION);
Optional<OrderingScheme> orderingScheme = Optional.empty();
ImmutableMap<VariableReferenceExpression, WindowNode.Function> functions = ImmutableMap.of(VARIABLE_REFERENCE_EXPRESSION, function);
WindowNode windowNode = builder.window(new WindowNode.Specification(partitionBy, orderingScheme), functions, valuesNode);
testValidation(windowNode);
}
use of com.facebook.presto.spi.relation.VariableReferenceExpression in project presto by prestodb.
the class TestVerifyNoOriginalExpression method testAggregation.
@Test
public void testAggregation() {
ImmutableList<VariableReferenceExpression> groupingKeys = ImmutableList.of(VARIABLE_REFERENCE_EXPRESSION);
int groupingSetCount = 1;
ImmutableMap<VariableReferenceExpression, SortOrder> orderings = ImmutableMap.of(VARIABLE_REFERENCE_EXPRESSION, SortOrder.ASC_NULLS_FIRST);
OrderingScheme orderingScheme = new OrderingScheme(groupingKeys.stream().map(variable -> new Ordering(variable, orderings.get(variable))).collect(toImmutableList()));
ImmutableMap<VariableReferenceExpression, AggregationNode.Aggregation> aggregations = ImmutableMap.of(VARIABLE_REFERENCE_EXPRESSION, new AggregationNode.Aggregation(comparisonCallExpression, Optional.of(comparisonCallExpression), Optional.of(orderingScheme), false, Optional.of(new VariableReferenceExpression(Optional.empty(), "orderkey", BIGINT))));
ImmutableSet<Integer> globalGroupingSets = ImmutableSet.of(1);
AggregationNode.GroupingSetDescriptor groupingSets = new AggregationNode.GroupingSetDescriptor(groupingKeys, groupingSetCount, globalGroupingSets);
ImmutableList<VariableReferenceExpression> preGroupedVariables = ImmutableList.of();
Optional<VariableReferenceExpression> hashVariable = Optional.of(VARIABLE_REFERENCE_EXPRESSION);
Optional<VariableReferenceExpression> groupIdVariable = Optional.of(VARIABLE_REFERENCE_EXPRESSION);
AggregationNode aggregationNode = new AggregationNode(Optional.empty(), new PlanNodeId("1"), valuesNode, aggregations, groupingSets, preGroupedVariables, AggregationNode.Step.SINGLE, hashVariable, groupIdVariable);
testValidation(aggregationNode);
}
use of com.facebook.presto.spi.relation.VariableReferenceExpression in project presto by prestodb.
the class TestVerifyNoOriginalExpression method testValidateFailedCompound.
@Test(expectedExceptions = IllegalArgumentException.class)
public void testValidateFailedCompound() {
Expression predicate = COMPARISON_EXPRESSION;
RowExpression rowExpression = castToRowExpression(predicate);
FilterNode filterNode = builder.filter(rowExpression, valuesNode);
ImmutableMap<VariableReferenceExpression, RowExpression> map = ImmutableMap.of(VARIABLE_REFERENCE_EXPRESSION, castToRowExpression(new SymbolReference("count")));
ProjectNode projectNode = builder.project(new Assignments(map), filterNode);
testValidation(projectNode);
}
use of com.facebook.presto.spi.relation.VariableReferenceExpression in project presto by prestodb.
the class TestVerifyNoOriginalExpression method testValidateForApplyFailed.
@Test(expectedExceptions = IllegalArgumentException.class)
public void testValidateForApplyFailed() {
ImmutableMap<VariableReferenceExpression, RowExpression> map = ImmutableMap.of(VARIABLE_REFERENCE_EXPRESSION, castToRowExpression(new SymbolReference("count")));
Assignments assignments = new Assignments(map);
ImmutableList<VariableReferenceExpression> variableReferenceExpressions = ImmutableList.of(VARIABLE_REFERENCE_EXPRESSION);
ApplyNode applyNode = builder.apply(assignments, variableReferenceExpressions, valuesNode, valuesNode);
testValidation(applyNode);
}
use of com.facebook.presto.spi.relation.VariableReferenceExpression in project presto by prestodb.
the class TestVerifyOnlyOneOutputNode method testValidateFailed.
@Test(expectedExceptions = IllegalStateException.class)
public void testValidateFailed() {
// random plan with 2 output nodes
PlanNode root = new OutputNode(Optional.empty(), idAllocator.getNextId(), new ExplainAnalyzeNode(Optional.empty(), idAllocator.getNextId(), new OutputNode(Optional.empty(), idAllocator.getNextId(), new ProjectNode(idAllocator.getNextId(), new ValuesNode(Optional.empty(), idAllocator.getNextId(), ImmutableList.of(), ImmutableList.of()), Assignments.of()), ImmutableList.of(), ImmutableList.of()), new VariableReferenceExpression(Optional.empty(), "a", BIGINT), false), ImmutableList.of(), ImmutableList.of());
new VerifyOnlyOneOutputNode().validate(root, null, null, null, null, WarningCollector.NOOP);
}
Aggregations