use of org.apache.calcite.linq4j.tree.ConstantExpression in project calcite by apache.
the class LixToRelTranslator method translate.
public RelNode translate(Expression expression) {
if (expression instanceof MethodCallExpression) {
final MethodCallExpression call = (MethodCallExpression) expression;
BuiltInMethod method = BuiltInMethod.MAP.get(call.method);
if (method == null) {
throw new UnsupportedOperationException("unknown method " + call.method);
}
RelNode input;
switch(method) {
case SELECT:
input = translate(call.targetExpression);
return LogicalProject.create(input, toRex(input, (FunctionExpression) call.expressions.get(0)), (List<String>) null);
case WHERE:
input = translate(call.targetExpression);
return LogicalFilter.create(input, toRex((FunctionExpression) call.expressions.get(0), input));
case AS_QUERYABLE:
return LogicalTableScan.create(cluster, RelOptTableImpl.create(null, typeFactory.createJavaType(Types.toClass(Types.getElementType(call.targetExpression.getType()))), ImmutableList.<String>of(), call.targetExpression));
case SCHEMA_GET_TABLE:
return LogicalTableScan.create(cluster, RelOptTableImpl.create(null, typeFactory.createJavaType((Class) ((ConstantExpression) call.expressions.get(1)).value), ImmutableList.<String>of(), call.targetExpression));
default:
throw new UnsupportedOperationException("unknown method " + call.method);
}
}
throw new UnsupportedOperationException("unknown expression type " + expression.getNodeType());
}
Aggregations