Source:
<code>private TableView parseSingleCommonTableExpression(boolean isPersistent) { <START> Session targetSession = session; <END> String cteViewName = readIdentifierWithSchema(); Schema schema = getSchema(); Table recursiveTable=null; ArrayList<Column> columns = New.arrayList(); String[] cols = null; Database db = targetSession.getDatabase(); if (readIf("(")) { cols = parseColumnList(); for (String c : cols) { columns.add(new Column(c, Value.STRING)); } } Table oldViewFound = null; if(isPersistent){ oldViewFound = getSchema().findTableOrView(targetSession, cteViewName); } else{ oldViewFound = targetSession.findLocalTempTable(cteViewName); } if (oldViewFound != null) { if (!(oldViewFound instanceof TableView)) { throw DbException.get(ErrorCode.TABLE_OR_VIEW_ALREADY_EXISTS_1, cteViewName); } TableView tv = (TableView) oldViewFound; if (!tv.isTableExpression()) { throw DbException.get(ErrorCode.TABLE_OR_VIEW_ALREADY_EXISTS_1, cteViewName); } if(isPersistent){ oldViewFound.lock(targetSession, true, true); targetSession.getDatabase().removeSchemaObject(targetSession, oldViewFound); }else{ targetSession.removeLocalTempTable(oldViewFound); } oldViewFound=null; } if(oldViewFound == null){ recursiveTable = createShadowTableForRecursiveTableExpression(isPersistent, targetSession, cteViewName, schema, columns, db); } List<Column> columnTemplateList; String[] querySQLOutput = new String[]{null}; try { read("AS"); read("("); Query withQuery = parseSelect(); if(isPersistent){ withQuery.session = targetSession; } read(")"); columnTemplateList = createQueryColumnTemplateList(cols, withQuery, querySQLOutput); } finally { destroyShadowTableForRecursiveExpression(isPersistent, targetSession, recursiveTable); } TableView view = createCTEView(cteViewName, querySQLOutput[0], columnTemplateList, true , true , isPersistent, targetSession); return view; }</code><technical_language>need targetSession anymore, session</technical_language>

Target:
private TableView parseSingleCommonTableExpression(boolean isPersistent) { String cteViewName = readIdentifierWithSchema(); Schema schema = getSchema(); Table recursiveTable = null; ArrayList<Column> columns = New.arrayList(); String[] cols = null; Database db = session.getDatabase(); if (readIf("(")) { cols = parseColumnList(); for (String c : cols) { columns.add(new Column(c, Value.STRING)); } } Table oldViewFound = null; if (isPersistent) { oldViewFound = getSchema().findTableOrView(session, cteViewName); } else { oldViewFound = session.findLocalTempTable(cteViewName); } if (oldViewFound != null) { if (!(oldViewFound instanceof TableView)) { throw DbException.get(ErrorCode.TABLE_OR_VIEW_ALREADY_EXISTS_1, cteViewName); } TableView tv = (TableView) oldViewFound; if (!tv.isTableExpression()) { throw DbException.get(ErrorCode.TABLE_OR_VIEW_ALREADY_EXISTS_1, cteViewName); } if (isPersistent) { oldViewFound.lock(session, true, true); session.getDatabase().removeSchemaObject(session, oldViewFound); } else { session.removeLocalTempTable(oldViewFound); } oldViewFound = null; } if (oldViewFound == null) { recursiveTable = TableView.createShadowTableForRecursiveTableExpression(isPersistent, session, cteViewName, schema, columns, db); } List<Column> columnTemplateList; String[] querySQLOutput = new String[]{null}; try { read("AS"); read("("); Query withQuery = parseSelect(); if (isPersistent) { withQuery.session = session; } read(")"); columnTemplateList = TableView.createQueryColumnTemplateList(cols, withQuery, querySQLOutput); } finally { TableView.destroyShadowTableForRecursiveExpression(isPersistent, session, recursiveTable); } TableView view = createCTEView(cteViewName, querySQLOutput[0], columnTemplateList, true , true , isPersistent, session); return view; }