core/src/main/java/com/orientechnologies/orient/core/sql/executor/OSelectExecutionPlanner.java
private static void splitLet(QueryPlanningInfo info, OCommandContext ctx) {
    if (info.perRecordLetClause != null && info.perRecordLetClause.getItems() != null) {
      Iterator<OLetItem> iterator = info.perRecordLetClause.getItems().iterator();
      while (iterator.hasNext()) {
        OLetItem item = iterator.next();
        if (item.getExpression() != null && item.getExpression().isEarlyCalculated(ctx)) {
          iterator.remove();
          addGlobalLet(info, item.getVarName(), item.getExpression());
        } else if (item.getQuery() != null && !item.getQuery().refersToParent()) {
          iterator.remove();
          addGlobalLet(info, item.getVarName(), item.getQuery());
        }
      }
    }
  }
private static void splitLet(QueryPlanningInfo info, OCommandContext ctx) {
    if (info.perRecordLetClause != null && info.perRecordLetClause.getItems() != null) {
      Iterator<OLetItem> iterator = info.perRecordLetClause.getItems().iterator();
      while (iterator.hasNext()) {
        OLetItem item = iterator.next();
        if (item.getExpression() != null && item.getExpression().isEarlyCalculated(ctx)) {
          iterator.remove();
          addGlobalLet(info, item.getVarName(), item.getExpression());
        } else if (item.getQuery() != null && !item.getQuery().refersToParent()) {
          iterator.remove();
          addGlobalLet(info, item.getVarName(), item.getQuery());
        }
      }
    }
  }
private static void splitLet ( QueryPlanningInfo info , OCommandContext ctx ) { if ( info . perRecordLetClause != null && info . perRecordLetClause . getItems ( ) != null ) { Iterator < OLetItem > iterator = info . perRecordLetClause . getItems ( ) . iterator ( ) ; while ( iterator . hasNext ( ) ) { OLetItem item = iterator . next ( ) ; if ( item . getExpression ( ) != null && item . getExpression ( ) . isEarlyCalculated ( ctx ) ) { iterator . remove ( ) ; addGlobalLet ( info , item . getVarName ( ) , item . getExpression ( ) ) ; } else if ( item . getQuery ( ) != null && ! item . getQuery ( ) . refersToParent ( ) ) { iterator . remove ( ) ; addGlobalLet ( info , item . getVarName ( ) , item . getQuery ( ) ) ; } } } }
splits LET clauses in global (executed once) and local (executed once per record)
splits LET clauses in global ( executed once ) and local ( executed once per record )