@@ -0,0 +1,2386 @@
+/*%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A *     http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0Apackage com.facebook.presto.sql.planner.iterative.rule;%0A%0Aimport com.facebook.presto.spi.type.BigintType;%0Aimport com.facebook.presto.spi.type.Type;%0Aimport com.facebook.presto.sql.planner.Symbol;%0Aimport com.facebook.presto.sql.planner.SymbolAllocator;%0Aimport com.facebook.presto.sql.tree.BindExpression;%0Aimport com.facebook.presto.sql.tree.Identifier;%0Aimport com.facebook.presto.sql.tree.LambdaArgumentDeclaration;%0Aimport com.facebook.presto.sql.tree.LambdaExpression;%0Aimport com.google.common.collect.ImmutableList;%0Aimport com.google.common.collect.ImmutableMap;%0Aimport org.testng.annotations.Test;%0A%0Aimport java.util.Map;%0Aimport java.util.stream.Stream;%0A%0Aimport static com.facebook.presto.sql.planner.iterative.rule.LambdaCaptureDesugaringRewriter.rewrite;%0Aimport static com.facebook.presto.sql.planner.iterative.rule.test.PlanBuilder.expression;%0Aimport static java.util.stream.Collectors.toList;%0Aimport static org.testng.Assert.assertEquals;%0A%0Apublic class TestLambdaCaptureDesugaringRewriter%0A%7B%0A    @Test%0A    public void testRewriteBasicLambda()%0A            throws Exception%0A    %7B%0A        final Map%3CSymbol, Type%3E symbols = ImmutableMap.of(new Symbol(%22a%22), BigintType.BIGINT);%0A        final SymbolAllocator allocator = new SymbolAllocator(symbols);%0A%0A        assertEquals(rewrite(expression(%22x -%3E a + x%22), symbols, allocator),%0A                     new BindExpression(%0A                             ImmutableList.of(expression(%22a%22)),%0A                             new LambdaExpression(%0A                                     Stream.of(%22a_0%22, %22x%22)%0A                                             .map(Identifier::new)%0A                                             .map(LambdaArgumentDeclaration::new)%0A                                             .collect(toList()),%0A                                     expression(%22a_0 + x%22))));%0A    %7D%0A%7D%0A

Add test for LambdaCaptureDesugaringRewriter