Skip to content

Commit 8642c17

Browse files
committed
Address review comments
1 parent fbd4872 commit 8642c17

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

presto-native-sidecar-plugin/src/test/java/com/facebook/presto/sidecar/expressions/TestNativeExpressionOptimizer.java

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,25 @@ public void tearDown()
8686
@Test
8787
public void testLambdaBodyConstantFolding()
8888
{
89-
assertOptimizedEquals("transform(ARRAY[unbound_long, unbound_long2], x -> 1 + 1)",
89+
// Simple lambda constant folding.
90+
assertOptimizedEquals(
91+
"transform(ARRAY[unbound_long, unbound_long2], x -> 1 + 1)",
9092
"transform(ARRAY[unbound_long, unbound_long2], x -> 2)");
91-
assertOptimizedEquals("transform(ARRAY[unbound_long, unbound_long2], x -> cast('123' AS integer))", "transform(ARRAY[unbound_long, unbound_long2], x -> 123)");
92-
assertOptimizedEquals("transform(ARRAY[unbound_long, unbound_long2], x -> cast(json_parse('[1, 2]') AS ARRAY<INTEGER>)[1] + 1)",
93+
assertOptimizedEquals(
94+
"transform(ARRAY[unbound_long, unbound_long2], x -> cast('123' AS integer))",
95+
"transform(ARRAY[unbound_long, unbound_long2], x -> 123)");
96+
assertOptimizedEquals(
97+
"transform(ARRAY[unbound_long, unbound_long2], x -> cast(json_parse('[1, 2]') AS ARRAY<INTEGER>)[1] + 1)",
9398
"transform(ARRAY[unbound_long, unbound_long2], x -> 2)");
99+
100+
// Nested lambda constant folding.
101+
assertOptimizedEquals(
102+
"transform(ARRAY[unbound_long, unbound_long2], x -> transform(ARRAY[1, 2], y -> 1 + 1))",
103+
"transform(ARRAY[unbound_long, unbound_long2], x -> transform(ARRAY[1, 2], y -> 2))");
104+
// Multiple lambda occurrences constant folding.
105+
assertOptimizedEquals(
106+
"filter(transform(ARRAY[unbound_long, unbound_long2], x -> 1 + 1), x -> true and false)",
107+
"filter(transform(ARRAY[unbound_long, unbound_long2], x -> 2), x -> false)");
94108
}
95109

96110
private void assertOptimizedEquals(@Language("SQL") String actual, @Language("SQL") String expected)

0 commit comments

Comments
 (0)