use of com.facebook.presto.spi.relation.RowExpression in project presto by prestodb.
the class TestPinotExpressionConverters method testAggregationProjectUnsupported.
private void testAggregationProjectUnsupported(String sqlExpression, SessionHolder sessionHolder) {
try {
RowExpression pushDownExpression = getRowExpression(sqlExpression, sessionHolder);
String actualPinotExpression = pushDownExpression.accept(new PinotAggregationProjectConverter(functionAndTypeManager, functionAndTypeManager, standardFunctionResolution, sessionHolder.getConnectorSession()), testInput).getDefinition();
fail("expected to not reach here: Generated " + actualPinotExpression);
} catch (PinotException e) {
assertEquals(e.getErrorCode(), PINOT_UNSUPPORTED_EXPRESSION.toErrorCode());
}
}
use of com.facebook.presto.spi.relation.RowExpression in project presto by prestodb.
the class TestPinotExpressionConverters method testFilter.
private void testFilter(String sqlExpression, String expectedPinotExpression, SessionHolder sessionHolder) {
RowExpression pushDownExpression = getRowExpression(sqlExpression, sessionHolder);
String actualPinotExpression = pushDownExpression.accept(new PinotFilterExpressionConverter(functionAndTypeManager, functionAndTypeManager, standardFunctionResolution), testInputFunction).getDefinition();
assertEquals(actualPinotExpression, expectedPinotExpression);
}
use of com.facebook.presto.spi.relation.RowExpression in project presto by prestodb.
the class TestPinotExpressionConverters method testAggregationProject.
private void testAggregationProject(String sqlExpression, String expectedPinotExpression, SessionHolder sessionHolder) {
RowExpression pushDownExpression = getRowExpression(sqlExpression, sessionHolder);
String actualPinotExpression = pushDownExpression.accept(new PinotAggregationProjectConverter(functionAndTypeManager, functionAndTypeManager, standardFunctionResolution, sessionHolder.getConnectorSession()), testInput).getDefinition();
assertEquals(actualPinotExpression, expectedPinotExpression);
}
use of com.facebook.presto.spi.relation.RowExpression in project presto by prestodb.
the class DruidProjectExpressionConverter method handleCast.
private DruidExpression handleCast(CallExpression cast, Map<VariableReferenceExpression, Selection> context) {
if (cast.getArguments().size() == 1) {
RowExpression input = cast.getArguments().get(0);
Type expectedType = cast.getType();
if (isImplicitCast(input.getType(), expectedType)) {
return input.accept(this, context);
}
throw new PrestoException(DRUID_PUSHDOWN_UNSUPPORTED_EXPRESSION, "Non implicit casts not supported: " + cast);
}
throw new PrestoException(DRUID_PUSHDOWN_UNSUPPORTED_EXPRESSION, "This type of CAST operator not supported: " + cast);
}
use of com.facebook.presto.spi.relation.RowExpression in project presto by prestodb.
the class SubfieldExtractor method toRowExpression.
private RowExpression toRowExpression(Subfield subfield, List<Type> types) {
List<Subfield.PathElement> path = subfield.getPath();
if (path.isEmpty()) {
return new VariableReferenceExpression(Optional.empty(), subfield.getRootName(), types.get(0));
}
RowExpression base = toRowExpression(new Subfield(subfield.getRootName(), path.subList(0, path.size() - 1)), types.subList(0, types.size() - 1));
Type baseType = types.get(types.size() - 2);
Subfield.PathElement pathElement = path.get(path.size() - 1);
if (pathElement instanceof Subfield.LongSubscript) {
Type indexType = baseType instanceof MapType ? ((MapType) baseType).getKeyType() : BIGINT;
FunctionHandle functionHandle = functionResolution.subscriptFunction(baseType, indexType);
ConstantExpression index = new ConstantExpression(base.getSourceLocation(), ((Subfield.LongSubscript) pathElement).getIndex(), indexType);
return new CallExpression(base.getSourceLocation(), SUBSCRIPT.name(), functionHandle, types.get(types.size() - 1), ImmutableList.of(base, index));
}
if (pathElement instanceof Subfield.StringSubscript) {
Type indexType = ((MapType) baseType).getKeyType();
FunctionHandle functionHandle = functionResolution.subscriptFunction(baseType, indexType);
ConstantExpression index = new ConstantExpression(base.getSourceLocation(), Slices.utf8Slice(((Subfield.StringSubscript) pathElement).getIndex()), indexType);
return new CallExpression(base.getSourceLocation(), SUBSCRIPT.name(), functionHandle, types.get(types.size() - 1), ImmutableList.of(base, index));
}
if (pathElement instanceof Subfield.NestedField) {
Subfield.NestedField nestedField = (Subfield.NestedField) pathElement;
return new SpecialFormExpression(base.getSourceLocation(), DEREFERENCE, types.get(types.size() - 1), base, new ConstantExpression(base.getSourceLocation(), getFieldIndex((RowType) baseType, nestedField.getName()), INTEGER));
}
verify(false, "Unexpected path element: " + pathElement);
return null;
}
Aggregations