Search in sources :

Example 1 with JaninoRexCompiler

use of org.apache.calcite.interpreter.JaninoRexCompiler in project spf4j by zolyfarkas.

the class InterpreterUtils method toScalar.

@Nullable
public static Scalar toScalar(final List<RexNode> filters, final RelDataType rowType, final DataContext dataContext) {
    if (filters.isEmpty()) {
        return null;
    } else {
        RexBuilder rb = new RexBuilder(dataContext.getTypeFactory());
        JaninoRexCompiler compiler = new JaninoRexCompiler(rb);
        try {
            return compiler.compile(filters, rowType).apply(dataContext);
        } catch (UnsupportedOperationException ex) {
            LOG.warn("Unable to compile filter: {}", filters, ex);
            return null;
        }
    }
}
Also used : RexBuilder(org.apache.calcite.rex.RexBuilder) JaninoRexCompiler(org.apache.calcite.interpreter.JaninoRexCompiler) Nullable(javax.annotation.Nullable)

Aggregations

Nullable (javax.annotation.Nullable)1 JaninoRexCompiler (org.apache.calcite.interpreter.JaninoRexCompiler)1 RexBuilder (org.apache.calcite.rex.RexBuilder)1