static org.apache.samza.sql.data.Expression createSamzaExpressionFromCalcite(ParameterExpression executionContext,
      ParameterExpression context, ParameterExpression dataContext, ParameterExpression inputValues,
      ParameterExpression outputValues, BlockStatement block) {
    final List<MemberDeclaration> declarations = Lists.newArrayList();

    // public void execute(Object[] inputValues, Object[] outputValues)
    declarations.add(
        Expressions.methodDecl(Modifier.PUBLIC, void.class, SamzaBuiltInMethod.EXPR_EXECUTE2.method.getName(),
            ImmutableList.of(executionContext, context, dataContext, inputValues, outputValues), block));

    final ClassDeclaration classDeclaration = Expressions.classDecl(Modifier.PUBLIC, "SqlExpression", null,
        ImmutableList.<Type>of(org.apache.samza.sql.data.Expression.class), declarations);
    String s = Expressions.toString(declarations, "\n", false);

    log.info("Generated code for expression: {}", s);

    try {
      return getExpression(classDeclaration, s);
    } catch (Exception e) {
      throw new SamzaException("Expression compilation failure.", e);
    }
  }
This method takes the java statement block, inputs, outputs needed by the statement block to create an object
of class that implements the interface {@link Expression}

for e.g.
  Query : select id from profile
     where profile table has relational schema with id(NUMBER) and name(VARCHAR) columns.
   This query will result in the following relational plan
     LogicalProject(id=[$1])
       LogicalTableScan(table=[[profile]])


   And the corresponding expressions are
      inputs : EnumerableTableScan (Which is the output of LogicalTableScan)
      nodes : [$1] Which essentially means take pick the first column from the input

   This expression corresponding to the logicalProject "[$1]" gets converted into a java statement block
   {
     outputValues[0] = (Integer) inputValues[1];
   }

   This method converts this statement block into an equivalent {@link Expression} object whose execute methods
   execute the above java statement block
samza-sql/src/main/java/org/apache/samza/sql/data/RexToJavaCompiler.java